我想定义一个带有 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
,它可以工作。
我还尝试了许多单引号和转义双引号的组合。
有谁知道解决方法?
这里有一些带有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"
我能想到的一种解决方法是创建一些 bash 脚本来运行此运行状况检查,并像往常一样将您的秘密数据放入环境中。