Replacing a Specified Pod
Function
This API is used to replace a pod in a specified namespace.
The following field 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 request parameters, see Table 3.
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-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"
}
]
}
}
Response
Response parameters:
For the description about response parameters, see 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-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"
}
]
}
}
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: Reading a Specified Pod
Next Article: Replacing the Status of a Specified Pod
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.