sed -i "s/spider:[^[:space:]]*/spider:$GIT_COMMIT/" xx.yml
token="2xkkdklag"
response=$(curl -H "Authorization: Bearer $token" \
-H "Content-Type: application/yaml" \
-X PUT \
--data-binary "@xx.yml" \
https://www.xx.top/k8sapi/apis/apps/v1/namespaces/default/deployments/xx)
if echo "$response" | grep -q "NotFound"; then
response=$(curl -H "Authorization: Bearer $token" \
-H "Content-Type: application/yaml" \
-X POST \
--data-binary "@xx.yml" \
https://www.xx.top/k8sapi/apis/apps/v1/namespaces/default/deployments)
fi
-
命令中需要注意: 如果用-X PUT方法,那么URL需要携带部署的资源名称:xx
https://www.xx.top/k8sapi/apis/apps/v1/namespaces/default/deployments/xx
- 如果用 -X POST 方法,URL不能携带资源名称
https://www.xx.top/k8sapi/apis/apps/v1/namespaces/default/deployments
网友评论