文档首页 > > API参考> Kubernetes API> Pod> 替换指定的Pod

替换指定的Pod

分享
更新时间:2020/05/26 GMT+08:00

功能介绍

该API用于替换指定Namespace下的一个Pod对象。

其中以下字段支持更新:

  • metadata.selfLink
  • metadata.resourceVersion
  • metadata.generation
  • metadata.creationTimestamp
  • metadata.deletionTimestamp
  • metadata.clusterName
  • metadata.generateName
  • metadata.labels
  • metadata.annotations
  • spec.initContainers[*].image
  • spec.containers[*].image
  • spec.activeDeadlineSeconds
  • spec.tolerations

其余部分不支持更新。

URI

PUT /api/v1/namespaces/{namespace}/pods/{name}

表1 描述该API的参数。

表1 参数描述

参数

是否必选

描述

pretty

No

If 'true', then the output is pretty printed.

namespace

Yes

Object name and auth scope, such as for teams and projects.

name

Yes

Name of the Pod.

请求消息

请求参数:

请求参数的详细描述请参见表3

请求示例:

{ 
     "kind": "Pod", 
     "apiVersion": "v1", 
     "metadata": { 
         "name": "hello-world", 
         "namespace": "default", 
         "selfLink": "/api/v1/namespaces/default/pods/hello-world", 
         "uid": "84973056-5d3b-11e6-aeb9-286ed488fafe", 
         "resourceVersion": "3416", 
         "creationTimestamp": "2016-08-08T07:41:29Z", 
         "labels": { 
             "name": "brace" 
         } 
     }, 
     "spec": { 
         "volumes": [ 
             { 
                 "name": "test", 
                 "emptyDir": {} 
             }, 
             { 
                 "name": "default-token-test2", 
                 "secret": { 
                     "secretName": "default-token-test2" 
                 } 
             } 
         ], 
         "containers": [ 
             { 
                 "name": "hello-world", 
                 "image": "beego:v1", 
                 "env": [ 
                     { 
                         "name": "cy", 
                         "value": "cy" 
                     } 
                 ], 
                 "resources": {}, 
                 "volumeMounts": [ 
                     { 
                         "name": "test", 
                         "mountPath": "/tmp/foo" 
                     }, 
                     { 
                         "name": "default-token-test2", 
                         "readOnly": true, 
                         "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" 
                     } 
                 ], 
                 "terminationMessagePath": "/dev/termination-log", 
                 "imagePullPolicy": "IfNotPresent" 
             } 
         ], 
         "restartPolicy": "Always", 
         "terminationGracePeriodSeconds": 30, 
         "dnsPolicy": "ClusterFirst", 
         "serviceAccountName": "default", 
         "serviceAccount": "default", 
         "nodeName": "127.0.0.1", 
         "securityContext": {} 
     }, 
     "status": { 
         "phase": "Running", 
         "conditions": [ 
             { 
                 "type": "Ready", 
                 "status": "True", 
                 "lastProbeTime": null, 
                 "lastTransitionTime": "2016-08-08T07:41:29Z" 
             } 
         ], 
         "hostIP": "127.0.0.1", 
         "podIP": "172.16.0.4", 
         "startTime": "2016-08-08T07:41:29Z", 
         "containerStatuses": [ 
             { 
                 "name": "hello-world", 
                 "state": { 
                     "running": { 
                         "startedAt": "2016-08-08T07:41:29Z" 
                     } 
                 }, 
                 "lastState": {}, 
                 "ready": true, 
                 "restartCount": 0, 
                 "image": "test:v1", 
                 "imageID": "docker://sha256:b38119b54befb956986a4f5fb6f6eb79c9a1a4d94bbb8ad5fee82f5c1175e5b9", 
                 "containerID": "docker://ca6e4e70a4617701e3ef95f44426503d171ed23305a9de61e0198baa58822902" 
             } 
         ] 
     } 
 }

响应消息

响应参数:

响应参数的详细描述请参见请求消息

响应示例:

    { 
   "kind": "Pod", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "hello-world", 
     "namespace": "default", 
     "selfLink": "/api/v1/namespaces/default/pods/hello-world", 
     "uid": "84973056-5d3b-11e6-aeb9-286ed488fafe", 
     "resourceVersion": "3472", 
     "creationTimestamp": "2016-08-08T07:41:29Z", 
     "labels": { 
       "name": "brace" 
     } 
   }, 
   "spec": { 
     "volumes": [ 
       { 
         "name": "test", 
         "emptyDir": {} 
       }, 
       { 
         "name": "default-token-test2", 
         "secret": { 
           "secretName": "default-token-test2" 
         } 
       } 
     ], 
     "containers": [ 
       { 
         "name": "hello-world", 
         "image": "beego:v1", 
         "env": [ 
           { 
           "name": "cy", 
             "value": "cy" 
           } 
         ], 
         "resources": {}, 
         "volumeMounts": [ 
           { 
             "name": "test", 
             "mountPath": "/tmp/foo" 
           }, 
           { 
             "name": "default-token-test2", 
             "readOnly": true, 
             "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" 
           } 
         ], 
         "terminationMessagePath": "/dev/termination-log", 
         "imagePullPolicy": "IfNotPresent" 
       } 
     ], 
     "restartPolicy": "Always", 
     "terminationGracePeriodSeconds": 30, 
     "dnsPolicy": "ClusterFirst", 
     "serviceAccountName": "default", 
     "serviceAccount": "default", 
     "nodeName": "127.0.0.1", 
     "securityContext": {} 
   }, 
   "status": { 
     "phase": "Running", 
     "conditions": [ 
       { 
         "type": "Ready", 
         "status": "True", 
         "lastProbeTime": null, 
         "lastTransitionTime": "2016-08-08T07:41:29Z" 
       } 
     ], 
     "hostIP": "127.0.0.1", 
     "podIP": "172.16.0.4", 
     "startTime": "2016-08-08T07:41:29Z", 
     "containerStatuses": [ 
       { 
         "name": "hello-world", 
         "state": { 
           "running": { 
             "startedAt": "2016-08-08T07:41:29Z" 
           } 
         }, 
         "lastState": {}, 
         "ready": true, 
         "restartCount": 0, 
         "image": "test:v1", 
         "imageID": "docker://sha256:b38119b54befb956986a4f5fb6f6eb79c9a1a4d94bbb8ad5fee82f5c1175e5b9", 
         "containerID": "docker://ca6e4e70a4617701e3ef95f44426503d171ed23305a9de61e0198baa58822902" 
       } 
     ] 
   } 
 }

状态码

表2描述API的状态码。

表2 状态码

状态码

描述

200

This operation succeeds, and the JSON of a Pod object is returned.

异常状态码请参见状态码

分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!非常感谢您的反馈,我们会继续努力做到更好!
反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问