Replacing a StatefulSet
Function
This API is used to replace a StatefulSet under a specified namespace.
The following fields can be updated:
- metadata.labels
- metadata.generateName
- metadata.annotations
- spec.template
- spec.replicas
- spec.revisionHistoryLimit
- spec.progressDeadlineSeconds
URI
PUT /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name}
Table 1 describes the parameters of this API.
Request
Request parameters
For the description about request parameters, see Table 2.
Example request
{
"kind": "StatefulSet",
"apiVersion": "apps/v1beta1",
"metadata": {
"name": "statefulset-test",
"namespace": "8f6c39e7c269440c881bba2fc49586d6",
"selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/statefulsets/statefulset-test",
"uid": "ee0ef0d0-2728-11e8-8930-84a9c46e8ca3",
"resourceVersion": "4510955",
"generation": 1,
"creationTimestamp": "2018-03-14T01:42:18Z",
"labels": {
"appgroup": ""
},
"annotations": {
"description": ""
},
"enable": true
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "statefulset-test"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "statefulset-test"
},
"annotations": {
"com.huawei.scheduler/container-type": "secure-container",
"metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]",
"pod.alpha.kubernetes.io/initialized": "true"
},
"enable": true
},
"spec": {
"containers": [
{
"name": "container-0",
"image": "mysql:latest",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
},
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent",
"env": []
},
{
"name": "container-1",
"image": "nginx:latest",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
},
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always",
"env": []
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"affinity": {},
"schedulerName": "default-scheduler"
}
},
"serviceName": "test",
"podManagementPolicy": "OrderedReady",
"updateStrategy": {
"type": "RollingUpdate"
},
"revisionHistoryLimit": 10
},
"status": {
"observedGeneration": 1,
"replicas": 1,
"currentReplicas": 1,
"currentRevision": "statefulset-test-2238135242",
"updateRevision": "statefulset-test-2238135242"
}
}
Response
Response parameters
For the description about response parameters, see Table 2.
Example response
{
"kind": "StatefulSet",
"apiVersion": "apps/v1beta1",
"metadata": {
"name": "statefulset-test",
"namespace": "8f6c39e7c269440c881bba2fc49586d6",
"selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/statefulsets/statefulset-test",
"uid": "ee0ef0d0-2728-11e8-8930-84a9c46e8ca3",
"resourceVersion": "4510958",
"generation": 2,
"creationTimestamp": "2018-03-14T01:42:18Z",
"labels": {
"appgroup": ""
},
"annotations": {
"description": ""
},
"enable": true
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "statefulset-test"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "statefulset-test"
},
"annotations": {
"com.huawei.scheduler/container-type": "secure-container",
"metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]",
"pod.alpha.kubernetes.io/initialized": "true"
},
"enable": true
},
"spec": {
"containers": [
{
"name": "container-0",
"image": "mysql:latest",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
},
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
},
{
"name": "container-1",
"image": "nginx:latest",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
},
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"affinity": {},
"schedulerName": "default-scheduler"
}
},
"serviceName": "test",
"podManagementPolicy": "OrderedReady",
"updateStrategy": {
"type": "RollingUpdate"
},
"revisionHistoryLimit": 10
},
"status": {
"observedGeneration": 1,
"replicas": 1,
"currentReplicas": 1,
"currentRevision": "statefulset-test-2238135242",
"updateRevision": "statefulset-test-2238135242"
}
}
Status Code
Table 2 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
200 |
This operation succeeds, and a StatefulSet resource object is returned. |
For more status codes, see Status Codes.
Last Article: Reading the Status of a StatefulSet
Next Article: Updating a StatefulSet
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.