Listing All StatefulSets
Function
This API is used to list all StatefulSets under a specified namespace.
URI
GET /apis/apps/v1beta1/namespaces/{namespace}/statefulsets
Table 1 describes the parameters of this API.
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
namespace |
Yes |
Namespace to which the StatefulSets you want to query belong. |
|
pretty |
No |
If 'true', then the output is pretty printed. |
|
includeUninitialized |
No |
If true, partially initialized resources are included in the response. |
|
fieldSelector |
No |
A selector to restrict the list of returned objects by their fields. Defaults to everything. |
|
labelSelector |
No |
A selector to restrict the list of returned objects by their labels. Defaults to everything. |
|
resourceVersion |
No |
When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history. |
|
timeoutSeconds |
No |
Timeout for the list/watch call. |
|
watch |
No |
Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. |
Request
N/A
Response
Response parameters
Table 2 describes the response parameters.
|
Parameter |
Type |
Description |
|---|---|---|
|
apiVersion |
String |
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. |
|
items |
Array. For details, see Table 2. |
List of services |
|
kind |
String |
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. |
|
metadata |
Standard list metadata. |
Example response
{
"kind": "StatefulSetList",
"apiVersion": "apps/v1beta1",
"metadata": {
"selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/statefulsets",
"resourceVersion": "4510960"
},
"items": [
{
"metadata": {
"name": "statefulset-test",
"namespace": "8f6c39e7c269440c881bba2fc49586d6",
"selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/statefulsets/statefulset-test",
"uid": "ee0ef0d0-2728-11e8-8930-84a9c46e8ca3",
"resourceVersion": "4510960",
"generation": 2,
"creationTimestamp": "2018-03-14T01:42:18Z",
"labels": {
"appgroup": ""
},
"annotations": {
"description": ""
},
"enable": true
},
"spec": {
"replicas": 2,
"selector": {
"matchLabels": {
"app": "statefulset-test"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "statefulset-test"
},
"annotations": {
"com.huawei.scheduler/container-type": "secure-container",
"metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]",
"pod.alpha.kubernetes.io/initialized": "true"
},
"enable": true
},
"spec": {
"containers": [
{
"name": "container-0",
"image": "mysql:latest",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
},
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
},
{
"name": "container-1",
"image": "nginx:latest",
"resources": {
"limits": {
"cpu": "1",
"memory": "2Gi"
},
"requests": {
"cpu": "1",
"memory": "2Gi"
}
},
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"affinity": {},
"schedulerName": "default-scheduler"
}
},
"serviceName": "test",
"podManagementPolicy": "OrderedReady",
"updateStrategy": {
"type": "RollingUpdate"
},
"revisionHistoryLimit": 10
},
"status": {
"observedGeneration": 2,
"replicas": 1,
"currentReplicas": 1,
"currentRevision": "statefulset-test-2238135242",
"updateRevision": "statefulset-test-4168075007"
}
},
{
"metadata": {
"name": "test",
"namespace": "8f6c39e7c269440c881bba2fc49586d6",
"selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/statefulsets/test",
"uid": "3a03904a-25fb-11e8-a5eb-84a9c46e8c8b",
"resourceVersion": "4183808",
"generation": 4,
"creationTimestamp": "2018-03-12T13:42:37Z",
"labels": {
"appgroup": ""
},
"annotations": {
"description": ""
},
"enable": true
},
"spec": {
"replicas": 5,
"selector": {
"matchLabels": {
"app": "test"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "test"
},
"annotations": {
"com.huawei.scheduler/container-type": "secure-container",
"metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]",
"pod.alpha.kubernetes.io/initialized": "true"
},
"enable": true
},
"spec": {
"volumes": [
{
"name": "ccilocal-mb3osj6m",
"persistentVolumeClaim": {
"claimName": "ccilocal-mb3osj6m"
}
},
{
"name": "ccilocal-59tbq76l",
"persistentVolumeClaim": {
"claimName": "ccilocal-59tbq76l"
}
}
],
"containers": [
{
"name": "container-0",
"image": "nginx:latest",
"resources": {
"limits": {
"cpu": "250m",
"memory": "214748364800m"
},
"requests": {
"cpu": "250m",
"memory": "214748364800m"
}
},
"volumeMounts": [
{
"name": "ccilocal-mb3osj6m",
"mountPath": "/tmp/local0"
},
{
"name": "ccilocal-59tbq76l",
"mountPath": "/tmp/local1"
}
],
"lifecycle": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"affinity": {},
"schedulerName": "default-scheduler"
}
},
"volumeClaimTemplates": [
{
"metadata": {
"name": "ccilocal-mb3osj6m",
"creationTimestamp": null,
"enable": true
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
},
"storageClassName": "localvolumeccihuawei"
},
"status": {
"phase": "Pending"
}
},
{
"metadata": {
"name": "ccilocal-59tbq76l",
"creationTimestamp": null,
"enable": true
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
},
"storageClassName": "localvolumeccihuawei"
},
"status": {
"phase": "Pending"
}
}
],
"serviceName": "test",
"podManagementPolicy": "OrderedReady",
"updateStrategy": {
"type": "RollingUpdate"
},
"revisionHistoryLimit": 10
},
"status": {
"observedGeneration": 4,
"replicas": 5,
"readyReplicas": 5,
"currentReplicas": 5,
"currentRevision": "test-3275405408",
"updateRevision": "test-3275405408"
}
}
]
}
Status Code
Table 3 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
200 |
This operation succeeds, and a StatefulSet resource object is returned. |
For more status codes, see Status Codes.
Last Article: Reading a StatefulSet
Next Article: Reading the Status of a StatefulSet
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.