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

时间:2018-06-28 05:06:54

标签: deployment kubernetes postman

我想使用RestApi更新部署。 然后我与邮递员进行了测试,但总是得到了415。


信息如下:

类型: 补丁

URL: 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
}

我在此容器中有多个容器,只想申请特定的容器:peer0
$setElementOrder var是否有所不同?

2 个答案:

答案 0 :(得分:2)

415是无效的媒体类型。

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

答案 1 :(得分:0)

您可以尝试使用body并将Content-Type应用于application / json-patch + json方法PATCH:

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