我试图使用curl为我的pod添加一个poststart钩子,比如说向shell中的slack通道发送消息,命令如下所示
curl -d "text=Hi I am a bot that can post messages to any public channel." -d "channel=C1234567" -H "Authorization: Bearer xoxb-xxxxxxxxxxxxxxxx" -X POST https://slack.com/api/chat.postMessage
Run Code Online (Sandbox Code Playgroud)
在我的 pod 定义中,我尝试了这样的操作
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: curlimages/curl
env:
- name: TOKEN
valueFrom:
configMapKeyRef:
name: my-config
key: token
command: ["sleep"]
args: ["3000"]
lifecycle:
postStart:
exec:
command:
- "sh"
- "-c"
- |
curl -d "text=Hi going to start." -d "channel=C1234567" -H "Authorization: Bearer $(TOKEN)" -X POST https://slack.com/api/chat.postMessage
Run Code Online (Sandbox Code Playgroud)
与容器->命令不同,它具有args参数,我可以用引号传递多行命令,但在生命周期->poststart->exec->命令中它不支持args参数
我也尝试过,但没有运气
command: ["curl","-d","text=Hi going to start.",....]
Run Code Online (Sandbox Code Playgroud)
但我从来没有收到过我的松懈信息
我的问题是,如何在生命周期->poststart->exec->command 中传递带引号的长curl 命令?
| 归档时间: |
|
| 查看次数: |
2488 次 |
| 最近记录: |