Updating a Specified Pod
Function
This API is used to update a pod in a specified namespace.
The following fields can be updated:
- metadata.selfLink
- metadata.resourceVersion
- metadata.clusterName
- metadata.generateName
- metadata.labels
- metadata.annotations
- spec.initContainers[*].image
- spec.containers[*].image
- spec.activeDeadlineSeconds
- spec.tolerations
Other parts cannot be updated.
Request
Request parameters:
For the description about the Content-Type field, see 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-test2",
"secret": {
"secretName": "default-token-test2"
}
}
],
"containers": [
{
"name": "hello-world",
"image": "busybox:latest",
"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": "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.
|
Status Code |
Description |
|---|---|
|
200 |
This operation succeeds, and the JSON of a Pod object is returned. |
For the description about error status codes, see Status Code.
Last Article: Listing Pods
Next Article: Deployment
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.