I know this is a repeated question however, I didn't get an answer that satisfies my query. I am trying to create a helm chart for cronjob deployment. I keep the helm chart name as cronjob-example.
Now when I run the command helm install or helm upgrade manually I can install or update the cronjob however when I try to do the same from CICD pipeline it fails with error converting file YAML to JSON on line 19 of templates/cronjob.yaml file.
cronjob.yaml file.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
namespace: {{ .Values.metadata.namespace }}
creationTimestamp: {{ .Values.metadata.creationTimestamp }}
name: {{ .Values.name }}
spec:
jobTemplate:
metadata:
creationTimestamp: {{ .Values.metadata.creationTimestamp }}
name: {{ .Values.name }}
spec:
template:
metadata:
creationTimestamp: {{ .Values.metadata.creationTimestamp }}
spec:
imagePullSecrets:
- name: {{ .Values.image.imagePullSecrets }}
containers:
- image: {{ .Values.image.repository }}
name: {{ .Chart.Name }}
resources: {}
restartPolicy: OnFailure
schedule: '*/1 * * * *'
status: {}
values.yaml file
---
metadata:
namespace: "{{K8S_NS}}"
name: "{{HELM_APP_NAME}}"
#name: "cronjob-example"
nodeLabel: agent
image:
repository: "{{CI_REGISTRY_IMAGE}}/{{CI_COMMIT_REF_SLUG}}:{{CI_COMMIT_SHA}}.{{CI_PIPELINE_IID}}"
pullPolicy: "Always"
imagePullSecrets: git-image-pull-secret-cron
creationTimestamp: null
variables:
- name: "TLS_ENV"
value: "tst"
I am wondering why it is successful when I run it manually and why it fails through CICD pipeline. Everything works in CICD pipeline as is except the deployment stage. There it fails. All I am doing is hard coding the values I get from previous stages in cicd when I am installing/upgrading manually.