[英]CURL from K8S POD
I'm trying to run a curl command by passing a value of an Environment variable as path param.我正在尝试通过将环境变量的值作为路径参数传递来运行 curl 命令。 But somehow value of environment variable is not getting passed instead literal string $CUSTOMER_ID is getting passed.
但不知何故,环境变量的值没有被传递,而是文字字符串$CUSTOMER_ID被传递。 Below is the definition of cron job which I'm trying to configure.
下面是我正在尝试配置的 cron 作业的定义。
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.这里的问题是您需要一个 shell 来评估环境变量。
Your command should look something like this:您的命令应如下所示:
command:
- /bin/sh
- -c
- curl -X DELETE "http://application:8080/api/customer/$CUSTOMER_ID"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.