Updating a StatefulSet

Function

This API is used to update a specified StatefulSet.

The following fields can be updated:

  • metadata.labels
  • metadata.annotations
  • spec.replicas
  • spec.template
  • spec.restartPolicy
  • spec.revisionHistoryLimit
  • spec.progressDeadlineSeconds

The other fields cannot be updated.

URI

PATCH /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

Table 1 Path parameters

Parameter

Description

namespace

Object name and auth scope, such as for teams and projects.

name

Name of the StatefulSet.

Table 2 Query parameter

Parameter

Mandatory

Description

pretty

No

If 'true', then the output is pretty printed.

Request

Request parameters

For the description about the Content-Type field, see Patch Request Method Operation Description.

Example request

Change the metadata.labels of the StatefulSet created in Creating a StatefulSet to "app": "statefulset-test2".

Content-Type: application/merge-patch+json
{
    "metadata": {
        "labels": {
            "app": "statefulset-test2"
        }
    }
}

Response

Response parameters

For the description about response parameters, see Table 86.

Example response

{
    "kind": "StatefulSet",
    "apiVersion": "apps/v1",
    "metadata": {
        "name": "statefulset-test",
        "namespace": "namespace-test",
        "selfLink": "/apis/apps/v1/namespaces/namespace-test/statefulsets/statefulset-test",
        "uid": "f4a35f35-b011-11e8-b6ef-f898ef6c78b4",
        "resourceVersion": "5231369",
        "generation": 2,
        "creationTimestamp": "2018-09-04T07:13:00Z",
        "labels": {
            "app": "statefulset-test2"
        },
        "enable": true
    },
    "spec": {
        "replicas": 2,
        "selector": {
            "matchLabels": {
                "app": "statefulset-test"
            }
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "app": "statefulset-test"
                },
                "enable": true
            },
            "spec": {
                "containers": [
                    {
                        "name": "container-0",
                        "image": "redis",
                        "resources": {
                            "limits": {
                                "cpu": "500m",
                                "memory": "1Gi"
                            },
                            "requests": {
                                "cpu": "500m",
                                "memory": "1Gi"
                            }
                        },
                        "terminationMessagePath": "/dev/termination-log",
                        "terminationMessagePolicy": "File",
                        "imagePullPolicy": "IfNotPresent"
                    }
                ],
                "restartPolicy": "Always",
                "terminationGracePeriodSeconds": 30,
                "dnsPolicy": "ClusterFirst",
                "securityContext": {},
                "imagePullSecrets": [
                    {
                        "name": "imagepull-secret"
                    }
                ],
                "schedulerName": "default-scheduler"
            }
        },
        "serviceName": "",
        "podManagementPolicy": "OrderedReady",
        "updateStrategy": {
            "type": "OnDelete"
        },
        "revisionHistoryLimit": 10
    },
    "status": {
        "observedGeneration": 2,
        "replicas": 2,
        "updatedReplicas": 2,
        "currentRevision": "statefulset-test-f986b645b",
        "updateRevision": "statefulset-test-7748d5459",
        "collisionCount": 0
    }
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

200

This operation succeeds, and a StatefulSet resource object is returned.

For more status codes, see Status Codes.