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

Deployment 如何使用RestApi更新k8s中的部署?,deployment,kubernetes,postman,Deployment,Kubernetes,Postman,我想使用RestApi更新部署。 我用邮递员测试了一下,但总是得到415 资料如下: 类型: 补丁 网址: 标题: Authorization: bearer token Content-Type:application/json 正文: { "kind": "Deployment", "spec": { "template": { "spec": {

我想使用RestApi更新部署。 我用邮递员测试了一下,但总是得到415


资料如下:

类型: 补丁

网址:

标题:

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
}
响应:

{
    "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,方法补丁:

[{
"op" : "replace",
"path" : "/spec/template/spec/container/0/$setElementOrder/volumeMounts",
"value" : "<value you want to replace>"
}]
[{
“op”:“替换”,
“路径”:“/spec/template/spec/container/0/$setElementOrder/volumeMounts”,
“值”:”
}]

但将内容类型更改为application/json patch+json:{“kind”:“Status”,“apiVersion”:“v1”,“metadata”:{},“Status”:“Failure”,“message”:“json:无法将对象解组为类型为jsonpatch.patch的Go值”,“code”:500}