• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. Pod
  6. Updating a Specified Pod

Updating a Specified Pod

Function

This API is used to update some information about 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

PATCH /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 the Content-Type message header, see section Patch Request Method Operation Description.

Example request:

Content-Type: application/json-patch+json
[ 
 { 
     "op": "add", 
     "path": "/spec/containers/0/image", 
     "value": "busybox:latest" 
 } 
 ]

Response

Response parameters:

For the description about response parameters, see Table 3.

Example response:

{ 
   "kind": "Pod", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "hello-world", 
     "namespace": "default", 
     "selfLink": "/api/v1/namespaces/default/pods/hello-world", 
     "uid": "b4b50f8d-5d0e-11e6-aeb9-286ed488fafe", 
     "resourceVersion": "1638", 
     "creationTimestamp": "2016-08-08T02:20:42Z", 
     "labels": { 
       "name": "brace" 
     } 
   }, 
   "spec": { 
     "volumes": [ 
       { 
         "name": "test", 
         "emptyDir": {} 
       }, 
       { 
         "name": "default-token-pjcz2", 
         "secret": { 
           "secretName": "default-token-pjcz2" 
         } 
       } 
     ], 
     "containers": [ 
       { 
         "name": "hello-world", 
         "image": "busybox:latest", 
         "env": [ 
           { 
             "name": "test1", 
             "value": "test1" 
           } 
         ], 
         "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": "False", 
         "lastProbeTime": null, 
         "lastTransitionTime": "2016-08-08T02:20:44Z", 
         "reason": "ContainersNotReady", 
         "message": "containers with unready status: [hello-world]" 
       } 
     ], 
     "hostIP": "127.0.0.1", 
     "podIP": "172.16.0.4", 
     "startTime": "2016-08-08T02:20:42Z", 
     "containerStatuses": [ 
       { 
         "name": "hello-world", 
         "state": { 
           "waiting": { 
             "reason": "CrashLoopBackOff", 
             "message": "Back-off 5m0s restarting failed container=hello-world pod=hello-world_default(b4b50f8d-5d0e-11e6-aeb9-286ed488fafe)" 
           } 
         }, 
         "lastState": { 
           "terminated": { 
             "exitCode": 0, 
             "reason": "Completed", 
             "startedAt": "2016-08-08T03:38:17Z", 
             "finishedAt": "2016-08-08T03:38:17Z", 
             "containerID": "docker://601ce41bd6cafd403ed30d0beb3d27573c74d0207818b973f42268b37051627c" 
           } 
         }, 
         "ready": false, 
         "restartCount": 24, 
         "image": "busybox:latest", 
         "imageID": "docker://sha256:2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749", 
         "containerID": "docker://601ce41bd6cafd403ed30d0beb3d27573c74d0207818b973f42268b37051627c" 
       } 
     ] 
   } 
 }

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.