i have a cronjob helm chat, i can define many jobs in values.yaml and cronjob.yaml will provision my jobs. I have faced an issue when setting the image tag id in command line, following command throw no errors but it wont update jobs image tag to new one.
helm upgrade cronjobs cronjobs/ --wait --set job.myservice.image.tag=b70d744
cronjobs will run with old image tag how can i resolve this?
here is my cronjobs.yaml
{{- $chart_name := .Chart.Name }} {{- $chart_version := .Chart.Version | replace "+" "_" }} {{- $release_name := .Release.Name }} {{- range $job := .Values.jobs }} --- apiVersion: batch/v1beta1 kind: CronJob metadata: namespace: "{{ $job.namespace }}" name: "{{ $release_name }}-{{ $job.name }}" labels: chart: "{{ $chart_name }}-{{ $chart_version }}" spec: concurrencyPolicy: {{ $job.concurrencyPolicy }} failedJobsHistoryLimit: {{ $job.failedJobsHistoryLimit }} suspend: {{ $job.suspend }} jobTemplate: spec: template: metadata: labels: app: {{ $release_name }} cron: {{ $job.name }} spec: containers: - image: "{{ $job.image.repository }}:{{ $job.image.tag }}" imagePullPolicy: {{ $job.image.imagePullPolicy }} ports: - name: http containerPort: 80 protocol: TCP name: {{ $job.name }} args: {{ toYaml $job.args | indent 12 }} env: {{ toYaml $job.image.env | indent 12 }} volumeMounts: - name: nfs mountPath: "{{ $job.image.nfslogpath }}" restartPolicy: OnFailure imagePullSecrets: - name: {{ $job.image.secret }} volumes: - name: nfs nfs: server: "{{ $job.image.server }}" path: "{{ $job.image.nfspath }}" readOnly: false schedule: {{ $job.schedule | quote }} successfulJobsHistoryLimit: {{ $job.successfulJobsHistoryLimit }} {{- end }}
here is my values.yaml
jobs: - name: myservice namespace: default image: repository: xxx.com/myservice tag: fe4544 pullPolicy: Always secret: xxx nfslogpath: "/var/logs/" nfsserver: "xxx" nfspath: "/nfs/xxx/cronjobs/" nfsreadonly: false env: schedule: "*/5 * * * *" args: failedJobsHistoryLimit: 1 successfulJobsHistoryLimit: 3 concurrencyPolicy: Forbid suspend: false - name: myservice2 namespace: default image: repository: xxxx/myservice2 tag: 1dff39a pullPolicy: IfNotPresent secret: xxxx nfslogpath: "/var/logs/" nfsserver: "xxxx" nfspath: "/nfs/xxx/cronjobs/" nfsreadonly: false env: schedule: "*/30 * * * *" args: failedJobsHistoryLimit: 1 successfulJobsHistoryLimit: 2 concurrencyPolicy: Forbid suspend: false
This section of the Best Practices Guide deals with creating and using Custom Resource Definition objects. When working with Custom Resource Definitions (CRDs), it is important to distinguish two different pieces: There is a declaration of a CRD.
To perform a helm release upgrade using the CLI, run the following command provided: helm upgrade <release name> <chart directory> -f my-values. yaml using the configuration specified in the customized values. yaml file. After a successful upgrade, the helm will return the following message.
You can use a --values flag in your Helm commands to override the values in a chart and pass in a new file. Specify the name of the new file after the --values flag in the Helm command. Example: helm upgrade --install <service> -f values.
If you need to pass array values you can use curly braces (unix shell require quotes):
--set test={x,y,z} --set "test={x,y,z}"
Result YAML:
test: - x - y - z
Source: https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set
EDITED : added double-quotes for unix shell like bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With