From de15c573248a574f2336d48cdffd68a8e325355a Mon Sep 17 00:00:00 2001 From: Om Mishra <32200996+mishraomp@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:48:53 -0800 Subject: [PATCH 1/2] initial attempt --- .github/workflows/metabase-update-on-issue.yml | 1 + charts/nr-metabase/Chart.yaml | 2 +- charts/nr-metabase/charts/metabase/templates/_helpers.tpl | 2 +- charts/nr-metabase/charts/metabase/templates/is.yaml | 4 ++-- charts/nr-metabase/values.schema.json | 3 +++ charts/nr-metabase/values.yaml | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/metabase-update-on-issue.yml b/.github/workflows/metabase-update-on-issue.yml index 0d2b6de..2492743 100644 --- a/.github/workflows/metabase-update-on-issue.yml +++ b/.github/workflows/metabase-update-on-issue.yml @@ -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 diff --git a/charts/nr-metabase/Chart.yaml b/charts/nr-metabase/Chart.yaml index 2e2f0d9..df848eb 100644 --- a/charts/nr-metabase/Chart.yaml +++ b/charts/nr-metabase/Chart.yaml @@ -18,7 +18,7 @@ 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 diff --git a/charts/nr-metabase/charts/metabase/templates/_helpers.tpl b/charts/nr-metabase/charts/metabase/templates/_helpers.tpl index a99e543..bb8257c 100644 --- a/charts/nr-metabase/charts/metabase/templates/_helpers.tpl +++ b/charts/nr-metabase/charts/metabase/templates/_helpers.tpl @@ -26,7 +26,7 @@ If release name contains chart name it will be used as a full name. {{- if .Values.routeOverride }} {{- .Values.routeOverride }} {{- else }} -{{- printf "%s-%s.%s" .Release.Name .Values.global.zone .Values.global.domain }} +{{- printf "%s-metabase-%s-%s.%s" .Release.Name .Values.global.zone .Release.Namespace .Values.global.domain }} {{- end }} {{- end }} diff --git a/charts/nr-metabase/charts/metabase/templates/is.yaml b/charts/nr-metabase/charts/metabase/templates/is.yaml index 17e35bf..23c3fb0 100644 --- a/charts/nr-metabase/charts/metabase/templates/is.yaml +++ b/charts/nr-metabase/charts/metabase/templates/is.yaml @@ -9,9 +9,9 @@ spec: lookupPolicy: local: false tags: - - name: "{{ .Values.image.tag | default .Chart.AppVersion }}" + - name: "{{ .Values.global.appVersion }}" from: kind: DockerImage - name: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + name: "{{ .Values.image.repository }}:{{ .Values.global.appVersion }}" referencePolicy: type: Local diff --git a/charts/nr-metabase/values.schema.json b/charts/nr-metabase/values.schema.json index 94ed6d3..adbf016 100644 --- a/charts/nr-metabase/values.schema.json +++ b/charts/nr-metabase/values.schema.json @@ -46,6 +46,9 @@ "domain": { "type": "string", "default": "apps.silver.devops.gov.bc.ca" + }, + "appVersion":{ + "type": "string" } } }, diff --git a/charts/nr-metabase/values.yaml b/charts/nr-metabase/values.yaml index f575e2c..b3690a6 100644 --- a/charts/nr-metabase/values.yaml +++ b/charts/nr-metabase/values.yaml @@ -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 From 2bef740b353f22d079f9356fa551869cfae9a5df Mon Sep 17 00:00:00 2001 From: OMPRAKASH MISHRA Date: Fri, 8 Dec 2023 15:01:21 -0800 Subject: [PATCH 2/2] fixing HELM to align metabase with versioning. --- charts/nr-metabase/Chart.yaml | 3 - .../nr-metabase/charts/metabase/.helmignore | 23 ------- charts/nr-metabase/charts/metabase/Chart.yaml | 24 ------- .../charts/metabase/templates/_helpers.tpl | 62 ------------------- charts/nr-metabase/templates/_helpers.tpl | 62 +++++++++++++++++++ .../metabase}/deployment.yaml | 24 +++---- .../templates => templates/metabase}/is.yaml | 4 +- .../metabase}/route.yaml | 0 .../metabase}/service.yaml | 4 +- charts/nr-metabase/values.yaml | 2 - 10 files changed, 78 insertions(+), 130 deletions(-) delete mode 100644 charts/nr-metabase/charts/metabase/.helmignore delete mode 100644 charts/nr-metabase/charts/metabase/Chart.yaml delete mode 100644 charts/nr-metabase/charts/metabase/templates/_helpers.tpl rename charts/nr-metabase/{charts/metabase/templates => templates/metabase}/deployment.yaml (80%) rename charts/nr-metabase/{charts/metabase/templates => templates/metabase}/is.yaml (70%) rename charts/nr-metabase/{charts/metabase/templates => templates/metabase}/route.yaml (100%) rename charts/nr-metabase/{charts/metabase/templates => templates/metabase}/service.yaml (75%) diff --git a/charts/nr-metabase/Chart.yaml b/charts/nr-metabase/Chart.yaml index df848eb..5ab49da 100644 --- a/charts/nr-metabase/Chart.yaml +++ b/charts/nr-metabase/Chart.yaml @@ -20,9 +20,6 @@ version: 0.47.9 # It is recommended to use it with quotes. 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 diff --git a/charts/nr-metabase/charts/metabase/.helmignore b/charts/nr-metabase/charts/metabase/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/charts/nr-metabase/charts/metabase/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/charts/nr-metabase/charts/metabase/Chart.yaml b/charts/nr-metabase/charts/metabase/Chart.yaml deleted file mode 100644 index 7b39c17..0000000 --- a/charts/nr-metabase/charts/metabase/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: metabase -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# 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: "0.1.0" diff --git a/charts/nr-metabase/charts/metabase/templates/_helpers.tpl b/charts/nr-metabase/charts/metabase/templates/_helpers.tpl deleted file mode 100644 index bb8257c..0000000 --- a/charts/nr-metabase/charts/metabase/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -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.routeOverride }} -{{- .Values.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 }} - - diff --git a/charts/nr-metabase/templates/_helpers.tpl b/charts/nr-metabase/templates/_helpers.tpl index 5fcafd9..c070824 100644 --- a/charts/nr-metabase/templates/_helpers.tpl +++ b/charts/nr-metabase/templates/_helpers.tpl @@ -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 }} + + diff --git a/charts/nr-metabase/charts/metabase/templates/deployment.yaml b/charts/nr-metabase/templates/metabase/deployment.yaml similarity index 80% rename from charts/nr-metabase/charts/metabase/templates/deployment.yaml rename to charts/nr-metabase/templates/metabase/deployment.yaml index 764ee50..36a3cc2 100644 --- a/charts/nr-metabase/charts/metabase/templates/deployment.yaml +++ b/charts/nr-metabase/templates/metabase/deployment.yaml @@ -5,15 +5,15 @@ 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 }} @@ -21,13 +21,13 @@ spec: {{- 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: @@ -65,7 +65,7 @@ spec: value: strong ports: - name: http - containerPort: {{ .Values.service.targetPort }} + containerPort: {{ .Values.metabase.service.targetPort }} protocol: TCP livenessProbe: httpGet: @@ -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 }} diff --git a/charts/nr-metabase/charts/metabase/templates/is.yaml b/charts/nr-metabase/templates/metabase/is.yaml similarity index 70% rename from charts/nr-metabase/charts/metabase/templates/is.yaml rename to charts/nr-metabase/templates/metabase/is.yaml index 23c3fb0..8631944 100644 --- a/charts/nr-metabase/charts/metabase/templates/is.yaml +++ b/charts/nr-metabase/templates/metabase/is.yaml @@ -9,9 +9,9 @@ spec: lookupPolicy: local: false tags: - - name: "{{ .Values.global.appVersion }}" + - name: "{{ .Chart.AppVersion }}" from: kind: DockerImage - name: "{{ .Values.image.repository }}:{{ .Values.global.appVersion }}" + name: "{{ .Values.metabase.image.repository }}:{{ .Chart.AppVersion }}" referencePolicy: type: Local diff --git a/charts/nr-metabase/charts/metabase/templates/route.yaml b/charts/nr-metabase/templates/metabase/route.yaml similarity index 100% rename from charts/nr-metabase/charts/metabase/templates/route.yaml rename to charts/nr-metabase/templates/metabase/route.yaml diff --git a/charts/nr-metabase/charts/metabase/templates/service.yaml b/charts/nr-metabase/templates/metabase/service.yaml similarity index 75% rename from charts/nr-metabase/charts/metabase/templates/service.yaml rename to charts/nr-metabase/templates/metabase/service.yaml index 7927600..1090ccf 100644 --- a/charts/nr-metabase/charts/metabase/templates/service.yaml +++ b/charts/nr-metabase/templates/metabase/service.yaml @@ -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 diff --git a/charts/nr-metabase/values.yaml b/charts/nr-metabase/values.yaml index b3690a6..07214ab 100644 --- a/charts/nr-metabase/values.yaml +++ b/charts/nr-metabase/values.yaml @@ -20,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: