文档首页 > > API参考> Kubernetes API> StatefulSet>

更新StatefulSet

更新StatefulSet

分享
更新时间:2021/06/24 GMT+08:00

功能介绍

更新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}

表1 Path参数

参数

描述

namespace

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

name

Name of the StatefulSet.

表2 Query参数

参数

是否必选

描述

pretty

No

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

请求消息

请求参数:

“Content-Type”消息头说明请参见PATCH请求方法操作说明

请求示例:

创建StatefulSet创建的StatefulSet的metadata.labels更新为"app": "statefulset-test2"。

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

响应消息

响应参数:

响应参数的详细描述请参见表86

响应示例:

{
    "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",                                
                "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
    }
}

状态码

表3描述API的状态码。

表3 状态码

状态码

描述

200

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

更多状态码请参见状态码

分享:

    相关文档

    相关产品