Skip to content

Commit

Permalink
fix: image tag issue (#25)
Browse files Browse the repository at this point in the history
* initial attempt

* fixing HELM to align metabase with versioning.
  • Loading branch information
mishraomp authored Dec 8, 2023
1 parent 6d1319c commit cc96b51
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 131 deletions.
1 change: 1 addition & 0 deletions .github/workflows/metabase-update-on-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
yq eval '.appVersion = $appVersion' -i charts/nr-metabase/Chart.yaml
yq eval '.version = $version' -i charts/nr-metabase/Chart.yaml
yq eval '.metabase.image.tag = $appVersion' -i charts/nr-metabase/values.yaml
yq eval '.global.appVersion = $appVersion' -i charts/nr-metabase/values.yaml
git add charts/nr-metabase/values.yaml charts/nr-metabase/Chart.yaml
git commit -m "Updating the version of the metabase image to $appVersion"
git push origin deps/metabase-version-update-$appVersion
Expand Down
5 changes: 1 addition & 4 deletions charts/nr-metabase/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ version: 0.47.9
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.47.9" # aligned with metabase version.
appVersion: "v0.47.9" # aligned with metabase version. ALso update the global values appversion, there is no way to pass to
dependencies:
- name: metabase
condition: metabase.enabled
version: 0.1.0
- name: database
condition: database.enabled
version: 0.1.0
Expand Down
23 changes: 0 additions & 23 deletions charts/nr-metabase/charts/metabase/.helmignore

This file was deleted.

24 changes: 0 additions & 24 deletions charts/nr-metabase/charts/metabase/Chart.yaml

This file was deleted.

62 changes: 0 additions & 62 deletions charts/nr-metabase/charts/metabase/templates/_helpers.tpl

This file was deleted.

62 changes: 62 additions & 0 deletions charts/nr-metabase/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,65 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
Expand the name of the chart.
*/}}
{{- define "metabase.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "metabase.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s-%s" .Release.Name .Chart.Name .Values.global.zone | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{- define "metabase.route" -}}
{{- if .Values.metabase.routeOverride }}
{{- .Values.metabase.routeOverride }}
{{- else }}
{{- printf "%s-metabase-%s-%s.%s" .Release.Name .Values.global.zone .Release.Namespace .Values.global.domain }}
{{- end }}
{{- end }}

{{/*
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "metabase.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "metabase.labels" -}}
helm.sh/chart: {{ include "metabase.chart" . }}
{{ include "metabase.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app: {{ include "metabase.fullname" . }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "metabase.selectorLabels" -}}
app.kubernetes.io/name: {{ include "metabase.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ metadata:
labels:
{{- include "metabase.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- if not .Values.metabase.autoscaling.enabled }}
replicas: {{ .Values.metabase.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "metabase.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
{{- with .Values.metabase.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "metabase.selectorLabels" . | nindent 8 }}
spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.metabase.podSecurityContext | nindent 8 }}
containers:
- name: {{ include "metabase.fullname" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "image-registry.openshift-image-registry.svc:5000/{{.Release.Namespace}}/{{ include "metabase.fullname" . }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- toYaml .Values.metabase.securityContext | nindent 12 }}
image: "image-registry.openshift-image-registry.svc:5000/{{.Release.Namespace}}/{{ include "metabase.fullname" . }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.metabase.image.pullPolicy }}
env:
- name: MB_DB_DBNAME
valueFrom:
Expand Down Expand Up @@ -65,7 +65,7 @@ spec:
value: strong
ports:
- name: http
containerPort: {{ .Values.service.targetPort }}
containerPort: {{ .Values.metabase.service.targetPort }}
protocol: TCP
livenessProbe:
httpGet:
Expand All @@ -84,17 +84,17 @@ spec:
timeoutSeconds: 3
failureThreshold: 50
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml .Values.metabase.resources | nindent 12 }}

{{- with .Values.nodeSelector }}
{{- with .Values.metabase.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .Values.metabase.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .Values.metabase.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ spec:
lookupPolicy:
local: false
tags:
- name: "{{ .Values.image.tag | default .Chart.AppVersion }}"
- name: "{{ .Chart.AppVersion }}"
from:
kind: DockerImage
name: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
name: "{{ .Values.metabase.image.repository }}:{{ .Chart.AppVersion }}"
referencePolicy:
type: Local
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
labels:
{{- include "metabase.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
type: {{ .Values.metabase.service.type }}
ports:
- port: {{ .Values.service.port }}
- port: {{ .Values.metabase.service.port }}
targetPort: http
protocol: TCP
name: http
Expand Down
3 changes: 3 additions & 0 deletions charts/nr-metabase/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"domain": {
"type": "string",
"default": "apps.silver.devops.gov.bc.ca"
},
"appVersion":{
"type": "string"
}
}
},
Expand Down
3 changes: 1 addition & 2 deletions charts/nr-metabase/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ global:
helm.sh/policy: "keep"
zone: 'prod' # it is required, could be pr-123, dev, test, prod
domain: "apps.silver.devops.gov.bc.ca" # it is required, apps.silver.devops.gov.bc.ca for silver cluster
appVersion: 0.47.9
metabase:
enabled: true
replicaCount: 1
Expand All @@ -19,8 +20,6 @@ metabase:
image:
repository: ghcr.io/bcgov/nr-metabase/metabase
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: 'v0.47.2'
containerPort: 3000
environment: production
service:
Expand Down

0 comments on commit cc96b51

Please sign in to comment.