• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. Pod (Native Kubernetes APIs)
  5. Replacing a Specified Pod

Replacing a Specified Pod

Function

This API is used to replace a pod object under a specified namespace.

The following fields can be updated:

  • 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

The other fields cannot be updated.

URI

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

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

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.

Request

Request parameters:

For the description about request parameters, see Table 3.

Before sending a request for updating a specified pod, call GET /api/v1/namespaces/ {namespace} /pods/ {name} to query the configurations of the pod.

All configuration parameters of the pod need to be added in the body of the request used to update the pod. Do not modify the values of the parameters that do not need to be updated. Otherwise, the specified pod may fail to be updated.

Example request:

{ 
     "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-pjcz2", 
                 "secret": { 
                     "secretName": "default-token-pjcz2" 
                 } 
             } 
         ], 
         "containers": [ 
             { 
                 "name": "hello-world", 
                 "image": "beego:v1", 
                 "env": [ 
                     { 
                         "name": "cy", 
                         "value": "cy" 
                     } 
                 ], 
                 "resources": {}, 
                 "volumeMounts": [ 
                     { 
                         "name": "test", 
                         "mountPath": "/tmp/foo" 
                     }, 
                     { 
                         "name": "default-token-pjcz2", 
                         "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.17.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" 
             } 
         ] 
     } 
 }

Response

Response parameters:

For the description about response parameters, see the parameter description in Request.

Example response:

    { 
   "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-pjcz2", 
         "secret": { 
           "secretName": "default-token-pjcz2" 
         } 
       } 
     ], 
     "containers": [ 
       { 
         "name": "hello-world", 
         "image": "beego:v1", 
         "env": [ 
           { 
           "name": "cy", 
             "value": "cy" 
           } 
         ], 
         "resources": {}, 
         "volumeMounts": [ 
           { 
             "name": "test", 
             "mountPath": "/tmp/foo" 
           }, 
           { 
             "name": "default-token-pjcz2", 
             "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.17.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" 
       } 
     ] 
   } 
 }

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

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

For the description about status codes, see section Status Codes.