華為云計算 云知識 創(chuàng)建StatefulSetcreateAppsV1NamespacedStatefulSet
創(chuàng)建StatefulSetcreateAppsV1NamespacedStatefulSet

 

接口說明

創(chuàng)建StatefulSet。

URL
POST  https://cci.cn-north-4.myhuaweicloud.com/apis/apps/v1/namespaces/{namespace}/statefulsets 
請求參數(shù)
名稱 類型 IN 必選 描述
X-Auth-Token
 
string header

用戶Token。

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

Content-Type
 
string header

消息體的類型(格式),默認取值為“application/json”

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.

pretty
 
string query

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

(接口較龐大,Body參數(shù)和返回參數(shù)請參考《接口說明》。)
請求示例
示例 1

創(chuàng)建一個名為“statefulset-test”的StatefuiSet負載,使用 redis 鏡像創(chuàng)建3個Pod。

 
{ "apiVersion": "apps/v1", "kind": "StatefulSet", "metadata": { "name": "statefulset-test" }, "spec": { "replicas": 3, "selector": { "matchLabels": { "app": "statefulset-test" } }, "serviceName": "statefulset-test", "template": { "metadata": { "labels": { "app": "statefulset-test" } }, "spec": { "containers": [ { "image": "redis", "name": "container-0", "resources": { "limits": { "cpu": "500m", "memory": "1024Mi" }, "requests": { "cpu": "500m", "memory": "1024Mi" } } } ], "imagePullSecrets": [ { "name": "imagepull-secret" } ], "priority": 0 } } } }
返回示例
返回碼:200

OK

示例 1
 
{
"apiVersion": "apps/v1",
"kind": "StatefulSet",
"metadata": {
"creationTimestamp": "2018-09-04T07:13:00Z",
"generation": 1,
"labels": {
"app": "statefulset-test"
},
"name": "statefulset-test",
"namespace": "namespace-test",
"resourceVersion": "5207623",
"selfLink": "/apis/apps/v1/namespaces/namespace-test/statefulsets/statefulset-test",
"uid": "f4a35f35-b011-11e8-b6ef-f898ef6c78b4"
},
"spec": {
"podManagementPolicy": "OrderedReady",
"replicas": 3,
"revisionHistoryLimit": 10,
"selector": {
"matchLabels": {
"app": "statefulset-test"
}
},
"serviceName": "",
"template": {
"metadata": {
"annotations": {
"cri.cci.io/container-type": "secure-container"
},
"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": {
"replicas": 0
}
}
錯誤碼
請參考 錯誤碼說明。