华为云计算 云知识 更新StatefulSetpatchAppsV1NamespacedStatefulSet
更新StatefulSetpatchAppsV1NamespacedStatefulSet

 

接口说明

更新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.
URL
PATCH  https://cci.cn-north-4.myhuaweicloud.com/apis/apps/v1/namespaces/{namespace}/statefulsets/{name} 
请求参数
名称 类型 IN 必选 描述
X-Auth-Token
 
string header

用户Token。

通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

Content-Type
 
string header

目前支持三种类型的PATCH请求方法的操作,参考《使用JSON合并patch更新Deployment》

  1. Json Patch, Content-Type: application/json-patch+json 在RFC6902协议的定义中,Json Patch包含一系列对目标JSON对象的操作,其本身也为JSON对象。服务器接收到该对象后,会将其表示的操作应用于目标JSON对象。

  2. Merge Patch, Content-Type: application/merge-patch+json 在RFC7386协议的定义中,Merge Patch必须包含对一个资源对象的部分描述,即为JSON对象。该JSON对象被提交到服务端后与服务端的当前对象合并,即替换当前资源对象中的列表域,从而创建一个新的对象。

  3. Strategic Merge Patch, Content-Type: application/strategic-merge-patch+json Strategic Merge Patch是添加合法的元数据到API对象中,并通过这些新的元数据来决定哪个列表被合并,哪个列表不该被合并。当前这些元数据则作为结构标签。

name
 
string path

name of the StatefulSet

namespace
 
string path

object name and auth scope, such as for teams and projects

dryRun
 
string query

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldManager
 
string query

fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch).

force
 
boolean query

Force is going to "force" Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests.

pretty
 
string query

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

(接口较庞大,Body参数和返回参数请参考《接口说明》。)
请求示例
示例 1

更新StatefulSet中的labels值为"app": "statefulset-test2"。

 
{ "metadata": { "labels": { "app": "statefulset-test2" } } }
返回示例
返回码:200

OK

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

 

上一篇:查询保护实例项目标签ListProtectedInstancesProjectTags 下一篇:更新保护实例名称UpdateProtectedInstanceName