From d3fbe3febb7cd7e88c7bea857590ad4b81f42263 Mon Sep 17 00:00:00 2001 From: Om Mishra <32200996+mishraomp@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:59:47 -0700 Subject: [PATCH] Fix/command args (#15) --- .github/workflows/chart-release.yaml | 3 +- charts/component/Chart.yaml | 2 +- charts/component/templates/cronjob.yaml | 47 +++++++++++----------- charts/component/templates/deployment.yaml | 30 ++++++++++---- 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/.github/workflows/chart-release.yaml b/.github/workflows/chart-release.yaml index f836a9f..ac62dc2 100644 --- a/.github/workflows/chart-release.yaml +++ b/.github/workflows/chart-release.yaml @@ -37,7 +37,8 @@ jobs: skip-version-file: 'true' skip-commit: 'true' skip-on-empty: 'false' - git-push: 'true' + git-push: 'false' + - name: Create Release uses: softprops/action-gh-release@v1 if: ${{ steps.changelog.outputs.tag != '' }} diff --git a/charts/component/Chart.yaml b/charts/component/Chart.yaml index 89f1832..03843ab 100644 --- a/charts/component/Chart.yaml +++ b/charts/component/Chart.yaml @@ -15,7 +15,7 @@ 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.0.8 +version: 0.0.9 # 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 diff --git a/charts/component/templates/cronjob.yaml b/charts/component/templates/cronjob.yaml index 64a8d85..9157de9 100644 --- a/charts/component/templates/cronjob.yaml +++ b/charts/component/templates/cronjob.yaml @@ -1,5 +1,4 @@ {{- if and .Values.cronjob .Values.cronjob.enabled }} -{{- $customUser := include "postgresql.v1.username" . }} apiVersion: batch/v1 kind: CronJob metadata: @@ -36,8 +35,19 @@ spec: {{- end }} containers: {{- range .Values.containers }} - - - name: {{ .name }} + - name: {{ .name }} + {{- if .command }} + command: + {{- range .command }} + - "{{ . }}" + {{- end }} + {{- end}} + {{- if .args }} + args: + {{- range .args }} + - "{{ . }}" + {{- end }} + {{- end }} {{- if .securityContext }} securityContext: {{- toYaml .securityContext | nindent 12 }} @@ -47,13 +57,11 @@ spec: {{- if .envFrom }} envFrom: {{- if .envFrom.secretRef }} - - - secretRef: + - secretRef: name: {{ include "component.fullname" $ }} {{- end }} {{- if .envFrom.configMapRef }} - - - configMapRef: + - configMapRef: name: {{ include "component.fullname" $ }} {{- end }} {{- end }} @@ -61,8 +69,7 @@ spec: env: {{- if .env.fromLocalConfigmap }} {{- range $item := .env.fromLocalConfigmap }} # picking individual elements from configmap of individual component (backend, frontend, etc) - - - name: {{$item.name}} # the env variable name + - name: {{$item.name}} # the env variable name valueFrom: configMapKeyRef: name: {{ include "component.fullname" $ }} @@ -71,8 +78,7 @@ spec: {{- end }} {{- if .env.fromGlobalConfigmap }} {{- range $item := .env.fromGlobalConfigmap }} # picking individual elements from global configmap of entire deployment set - - - name: {{$item.name}} # the env variable name + - name: {{$item.name}} # the env variable name valueFrom: configMapKeyRef: name: {{ $.Release.Name }} @@ -81,8 +87,7 @@ spec: {{- end }} {{- if .env.fromLocalSecret }} {{- range $item := .env.fromLocalSecret }} # picking individual elements from secret of individual component (backend, frontend, etc) - - - name: {{$item.name}} # the env variable name + - name: {{$item.name}} # the env variable name valueFrom: secretKeyRef: {{- if $item.secretName }} @@ -95,8 +100,7 @@ spec: {{- end }} {{- if .env.fromGlobalSecret }} {{- range $item := .env.fromGlobalSecret }} # picking individual elements from global secret of entire deployment set - - - name: {{$item.name}} # the env variable name + - name: {{$item.name}} # the env variable name valueFrom: secretKeyRef: {{- if $item.secretName }} @@ -109,14 +113,12 @@ spec: {{- end }} {{- if .env.fromValues }} #this could be pure values based env like DB URLS or DB Host et {{- range $item := .env.fromValues }} # picking individual elements from global secret of entire deployment set - - - name: {{$item.name}} # the env variable name + - name: {{$item.name}} # the env variable name value: {{tpl $item.value $ | quote}} # the value of env variable {{- end }} {{- end }} {{- end }} - {{- if .resources}} {{- with .resources }} resources: @@ -133,10 +135,8 @@ spec: {{- end }} {{- end }} {{- if .volumeMounts }} - {{- with .volumeMounts }} volumeMounts: - {{- toYaml . | nindent 12 }} - {{- end }} + {{- tpl (toYaml .volumeMounts) $ | nindent 12 }} {{- end }} restartPolicy: {{ .Values.cronjob.restartPolicy }} {{- if .Values.cronjob.podSecurityContext.enabled }} @@ -144,10 +144,9 @@ spec: fsGroup: {{ .Values.cronjob.podSecurityContext.fsGroup }} {{- end }} {{- if .Values.cronjob.volumes.enabled }} - {{- with .Values.cronjob.volumes }} + {{- if .Values.cronjob.volumes }} volumes: - {{- toYaml . | nindent 12 }} - + {{- tpl (toYaml .Values.cronjob.volumes) . | nindent 10 }} {{- end }} {{- end }} {{- end}} diff --git a/charts/component/templates/deployment.yaml b/charts/component/templates/deployment.yaml index 6cac8d5..87ac1da 100644 --- a/charts/component/templates/deployment.yaml +++ b/charts/component/templates/deployment.yaml @@ -48,8 +48,17 @@ spec: image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ .tag }}' imagePullPolicy: Always {{- if .command }} - command: {{ .command }} + command: + {{- range .command }} + - "{{ . }}" + {{- end }} {{- end}} + {{- if .args }} + args: + {{- range .args }} + - "{{ . }}" + {{- end }} + {{- end }} {{- if .envFrom }} envFrom: {{- if .envFrom.secretRef }} @@ -138,6 +147,10 @@ spec: cpu: 20m memory: 50Mi {{- end }} + {{- if .volumeMounts }} + volumeMounts: + {{- tpl (toYaml .volumeMounts) $ | nindent 12 }} + {{- end }} {{- end }} {{- end }} containers: @@ -148,14 +161,17 @@ spec: {{- toYaml .securityContext | nindent 12 }} {{- end}} {{- if .command }} - command: {{ .command }} + command: + {{- range .command }} + - "{{ . }}" + {{- end }} {{- end}} - {{- if and .vault .vault.enabled }} + {{- if .args }} args: - - 'sh' - - '-c' - - '{{- range $k := .vault.secretPaths }}source /vault/secrets/{{$k}} && {{- end}}{{ .vault.entrypoint }}' - {{- end}} + {{- range .args }} + - "{{ . }}" + {{- end }} + {{- end }} image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ .tag }}' imagePullPolicy: Always {{- if .envFrom }}