I'm trying to run a curl command by passing a value of an Environment variable as path param. But somehow value of environment variable is not getting passed instead literal string $CUSTOMER_ID is getting passed. Below is the definition of cron job which I'm trying to configure.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: test-cron-job
spec:
schedule: "*/15 * * * *"
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: test-cron-job
image: myImage
command: [
"curl",
"-X",
"DELETE",
"http://application:8080/api/customer/"$CUSTOMER_ID""
]
env:
- name: CUSTOMER_ID
valueFrom:
configMapKeyRef:
name: app-config-map
key: customer_id
volumeMounts:
- name: app-config-map
mountPath: /etc/app-config-map
volumes:
- name: app-config-map
configMap:
name: app-config-map
I'm not sure what is wrong in this. Any pointers will be helpful.
The issue here is that you need a shell to evaluate environment variables.
Your command should look something like this:
command:
- /bin/sh
- -c
- curl -X DELETE "http://application:8080/api/customer/$CUSTOMER_ID"