我想定义一个带有httpHeader的livenessProbe,它的值是secret。
此语法无效:
livenessProbe:
httpGet:
path: /healthz
port: 8080
httpHeaders:
- name: X-Custom-Header
valueFrom:
secretKeyRef:
name: my-secret-key
value: secret如果我将值为secret的my-secret-key指定为名为MY_SECRET_KEY的环境变量,则可以执行以下操作:
livenessProbe:
exec:
command:
- curl
- --fail
- -H
- "X-Custom-Header: $MY_SECRET_KEY"
- 'http://localhost:8080/healthz'不幸的是,这不是由于报价被评估的方式。如果我直接在容器上输入命令curl --fail -H "X-Custom-Header: $MY_SECRET_KEY" http://localhost:8080/healthz,它就可以工作。
我还尝试了许多单引号和转义双引号的组合。
有没有人知道解决办法?
发布于 2017-01-22 20:08:09
我能想到的一个解决办法是创建一些bash脚本来运行此健康检查,并像往常一样将秘密数据放入环境中。
发布于 2019-12-17 22:10:28
下面是一些使用curl和wget的示例:
exec:
command:
- /bin/sh
- -c
- "curl -H 'Authorization: Bearer $(AUTH_TOKEN)' 'http://example.com'"exec:
command:
- /bin/sh
- -c
- "wget --spider --header \"Authorization: Bearer $AUTH_TOKEN\" http://some.api.com/spaces/${SPACE_ID}/entries"https://stackoverflow.com/questions/41774643
复制相似问题