繁体   English   中英

如何使用 RestApi 更新 k8s 中的部署?

[英]how can i use RestApi to update deployment in k8s?

我想使用 RestApi 来更新部署。 我用邮递员测试它,但总是得到 415 回来。


信息如下:

类型:补丁

网址: https://k8sClusterUrl:6443/apis/extensions/v1beta1/namespaces/ns/deployments/peer0

标题:

Authorization: bearer token  
Content-Type:application/json  

身体:

{
    "kind": "Deployment",
    "spec":
    {
        "template":
        {
            "spec":
            {
                "containers":[
                    {
                        "$setElementOrder/volumeMounts":[{"mountPath":"/host/var/run/"},{"mountPath":"/mnt"}],
                        "name":"peer0",
                        "image":"hyperledger/fabric-peer:x86_64-1.1.0"}
                ]
            }
        }
    }
}

回复:

{
    "kind": "Status",
    "apiVersion": "v1",
    "metadata": {},
    "status": "Failure",
    "message": "the server responded with the status code 415 but did not return more information",
    "details": {},
    "code": 415
}

我在这个 pod 中有多个容器,并且只想申请特定的容器: peer0
$setElementOrder var 有什么不同吗?

415是无效的媒体类型。

在这种情况下,您应该将媒体类型设置为application/json+patch+json (您可以在此处的文档中看到这一点

您可以尝试使用 body 和使用 Content-Type 到 application/json-patch+json,方法 PATCH:

[{
"op" : "replace",
"path" : "/spec/template/spec/container/0/$setElementOrder/volumeMounts",
"value" : "<value you want to replace>"
}]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM