Updating a Specified StatefulSet
Function
This API is used to update a StatefulSet under a specific namespace.
The following fields can be updated:
- metadata.labels
- metadata.clusterName
- metadata.generateName
- metadata.annotations
- spec.replicas
- template.containers
The other fields cannot be updated.
URI
PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} (for clusters of v1.9 and later)
PATCH /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 the Content-Type field, see Patch Request Method Operation Description.
Example request:
Content-Type: application/merge-patch+json
{
"metadata": {
"labels": {
"app": "mysql-0"
}
}
}
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": "1924739",
"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: Listing All StatefulSets
Next Article: Updating 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.