Replacing a Specified StatefulSet
Function
This API is used to replace a StatefulSet under a specified namespace.
The following fields can be updated:
- metadata.selfLink
- metadata.resourceVersion
- metadata.labels
- metadata.clusterName
- metadata.generateName
- metadata.annotations
- spec.replicas
- template.containers
- spec.restartPolicy
- spec.activeDeadlineSeconds
The other fields cannot be updated.
URI
PUT /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} (for clusters of v1.9 and later)
PUT /apis/apps/v1beta1/namespaces/{namespace}/statefulsets/{name} (for clusters of v1.15 and earlier)
Table 1 describes the parameters of this API.
Request
Request parameters:
For the description about request parameters, see Table 2.
Example request:
{
"apiVersion": "apps/v1beta1",
"kind": "StatefulSet",
"metadata": {
"generateName": "sz",
"labels": {
"app": "mysql-0"
},
"name": "mysql",
"namespace": "default",
"resourceVersion": "1923999"
},
"spec": {
"replicas": 1,
"serviceName": "mysql-service",
"template": {
"metadata": {
"labels": {
"app": "mysql"
}
},
"spec": {
"containers": [
{
"image": "10.154.52.159:443/test/nginx:latest",
"imagePullPolicy": "IfNotPresent",
"name": "container01",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {},
"terminationGracePeriodSeconds": 100,
"terminationMessagePath": "/dev/termination-log"
}
]
}
},
"volumeClaimTemplates": [
{
"metadata": {
"name": "db"
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
}
}
}
]
}
}
Response
Response parameters:
For the description about response parameters, see Table 2.
Example response:
{
"kind": "StatefulSet",
"apiVersion": "apps/v1beta1",
"metadata": {
"name": "mysql",
"generateName": "sz",
"namespace": "default",
"selfLink": "/apis/apps/v1beta1/namespaces/default/statefulsets/mysql",
"uid": "1688bdcb-24da-11e7-9c83-fa163ec08232",
"resourceVersion": "1923999",
"generation": 1,
"creationTimestamp": "2017-04-19T08:27:55Z",
"labels": {
"app": "mysql-0"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "mysql"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "mysql"
}
},
"spec": {
"containers": [
{
"name": "container01",
"image": "10.154.52.159:443/test/nginx:latest",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {}
}
},
"volumeClaimTemplates": [
{
"metadata": {
"name": "db",
"creationTimestamp": null
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
}
},
"status": {
"phase": "Pending"
}
}
],
"serviceName": "mysql-service"
},
"status": {
"replicas": 1
}
}
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 the description about error status codes, see Status Code.
Last Article: Reading the Status of a Specified StatefulSet
Next Article: Replacing the Status of a Specified StatefulSet
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.