華為云計(jì)算 云知識(shí) 更新StatefulSetpatchAppsV1NamespacedStatefulSet
更新StatefulSetpatchAppsV1NamespacedStatefulSet

 

接口說(shuō)明

更新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} 
請(qǐng)求參數(shù)
名稱 類型 IN 必選 描述
X-Auth-Token
 
string header

用戶Token。

通過(guò)調(diào)用 IAM 服務(wù)獲取用戶Token接口獲取(響應(yīng)消息頭中X-Subject-Token的值)。

Content-Type
 
string header

目前支持三種類型的PATCH請(qǐng)求方法的操作,參考《使用JSON合并patch更新Deployment》。

  1. Json Patch, Content-Type: application/json-patch+json 在RFC6902協(xié)議的定義中,Json Patch包含一系列對(duì)目標(biāo)JSON對(duì)象的操作,其本身也為JSON對(duì)象。服務(wù)器接收到該對(duì)象后,會(huì)將其表示的操作應(yīng)用于目標(biāo)JSON對(duì)象。

  2. Merge Patch, Content-Type: application/merge-patch+json 在RFC7386協(xié)議的定義中,Merge Patch必須包含對(duì)一個(gè)資源對(duì)象的部分描述,即為JSON對(duì)象。該JSON對(duì)象被提交到服務(wù)端后與服務(wù)端的當(dāng)前對(duì)象合并,即替換當(dāng)前資源對(duì)象中的列表域,從而創(chuàng)建一個(gè)新的對(duì)象。

  3. Strategic Merge Patch, Content-Type: application/strategic-merge-patch+json Strategic Merge Patch是添加合法的元數(shù)據(jù)到API對(duì)象中,并通過(guò)這些新的元數(shù)據(jù)來(lái)決定哪個(gè)列表被合并,哪個(gè)列表不該被合并。當(dāng)前這些元數(shù)據(jù)則作為結(jié)構(gòu)標(biāo)簽。

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參數(shù)和返回參數(shù)請(qǐng)參考《接口說(shuō)明》。)
請(qǐng)求示例
示例 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
}
}
錯(cuò)誤碼
請(qǐng)參考 錯(cuò)誤碼說(shuō)明。