Creating a StatefulSet
Function
This API is used to create a StatefulSet.
URI
POST /apis/apps/v1/namespaces/{namespace}/statefulsets
|
Parameter |
Description |
|---|---|
|
namespace |
Object name and auth scope, such as for teams and projects. |
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
pretty |
No |
If 'true', then the output is pretty printed. |
Request
Request parameters
For the description about request parameters, see Table 86.
Example request
{
"apiVersion": "apps/v1",
"kind": "StatefulSet",
"metadata": {
"name": "statefulset-test"
},
"spec": {
"replicas": 3,
"selector": {
"matchLabels": {
"app": "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
}
}
}
}
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": "5207623",
"generation": 1,
"creationTimestamp": "2018-09-04T07:13:00Z",
"labels": {
"app": "statefulset-test"
},
"enable": true
},
"spec": {
"replicas": 3,
"priority": 0,
"selector": {
"matchLabels": {
"app": "statefulset-test"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "statefulset-test"
},
"annotations": {
"cri.cci.io/container-type": "secure-container"
},
"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": {
"replicas": 0
}
}
Status Code
Table 3 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
201 |
The request has been fulfilled, resulting in the creation of a new resource. |
For more status codes, see Status Codes.
Last Article: StatefulSet
Next Article: Reading a StatefulSet
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.