Listing All ReplicaSets

Function

This API is used to read all ReplicaSets under a specified namespace.

URI

GET /apis/apps/v1/namespaces/{namespace}/replicasets

Table 1 Path parameters

Parameter

Mandatory

Description

namespace

Yes

Object name and auth scope, such as for teams and projects.

Table 2 Query parameters

Parameter

Mandatory

Description

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

For the description about response parameters, see Table 144.

Example response

{
    "kind": "ReplicaSetList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/default/replicasets",
        "resourceVersion": "793174"
    },
    "items": [
        {
            "metadata": {
                "name": "deployment-test-800400086",
                "namespace": "default",
                "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets/deployment-test-800400086",
                "uid": "67775454-df2f-11e7-961f-fa163ed139d5",
                "resourceVersion": "784294",
                "generation": 1,
                "creationTimestamp": "2017-12-12T11:27:15Z",
                "labels": {
                    "name": "deployment-test",
                    "pod-template-hash": "800400086"
                },
                "annotations": {
                    "deployment.kubernetes.io/desired-replicas": "1",
                    "deployment.kubernetes.io/max-replicas": "2",
                    "deployment.kubernetes.io/revision": "1"
                },
                "ownerReferences": [
                    {
                        "apiVersion": "extensions/v1beta1",
                        "kind": "Deployment",
                        "name": "deployment-test",
                        "uid": "6776d16b-df2f-11e7-961f-fa163ed139d5",
                        "controller": true,
                        "blockOwnerDeletion": true
                    }
                ],
                "enable": true
            },
            "spec": {
                "replicas": 1,
                "selector": {
                    "matchLabels": {
                        "name": "deployment-test",
                        "pod-template-hash": "800400086"
                    }
                },
                "template": {
                    "metadata": {
                        "creationTimestamp": null,
                        "labels": {
                            "name": "deployment-test",
                            "pod-template-hash": "800400086"
                        },
                        "enable": true
                    },
                    "spec": {
                        "containers": [
                            {
                                "name": "deployment-test",
                                "image": "172.16.5.235:20202/test/testnginx:v3",
                                "resources": {},
                                "terminationMessagePath": "/dev/termination-log",
                                "terminationMessagePolicy": "File",
                                "imagePullPolicy": "IfNotPresent"
                            }
                        ],
                        "restartPolicy": "Always",
                        "terminationGracePeriodSeconds": 30,
                        "dnsPolicy": "ClusterFirst",
                        "securityContext": {},
                        "schedulerName": "default-scheduler"
                    }
                }
            },
            "status": {
                "replicas": 1,
                "fullyLabeledReplicas": 1,
                "observedGeneration": 1
            }
        },
        {
            "metadata": {
                "name": "test-pv-446136006",
                "namespace": "default",
                "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets/test-pv-446136006",
                "uid": "3b3dee35-dfd7-11e7-961f-fa163ed139d5",
                "resourceVersion": "784441",
                "generation": 1,
                "creationTimestamp": "2017-12-13T07:28:36Z",
                "labels": {
                    "app": "test-pv",
                    "pod-template-hash": "446136006"
                },
                "annotations": {
                    "deployment.kubernetes.io/desired-replicas": "2",
                    "deployment.kubernetes.io/max-replicas": "2",
                    "deployment.kubernetes.io/revision": "1"
                },
                "ownerReferences": [
                    {
                        "apiVersion": "extensions/v1beta1",
                        "kind": "Deployment",
                        "name": "test-pv",
                        "uid": "3b3d3a22-dfd7-11e7-961f-fa163ed139d5",
                        "controller": true,
                        "blockOwnerDeletion": true
                    }
                ],
                "enable": true
            },
            "spec": {
                "replicas": 2,
                "selector": {
                    "matchLabels": {
                        "app": "test-pv",
                        "pod-template-hash": "446136006"
                    }
                },
                "template": {
                    "metadata": {
                        "creationTimestamp": null,
                        "labels": {
                            "app": "test-pv",
                            "pod-template-hash": "446136006"
                        },
                        "annotations": {
                            "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]"
                        },
                        "enable": true
                    },
                    "spec": {
                        "volumes": [
                            {
                                "name": "wwww",
                                "persistentVolumeClaim": {
                                    "claimName": "pvc1513149915389"
                                }
                            }
                        ],
                        "containers": [
                            {
                                "name": "container-0",
                                "image": "172.16.5.235:20202/test/nginx:latest",
                                "resources": {},
                                "volumeMounts": [
                                    {
                                        "name": "wwww",
                                        "readOnly": true,
                                        "mountPath": "/tmp0"
                                    }
                                ],
                                "lifecycle": {},
                                "terminationMessagePath": "/dev/termination-log",
                                "terminationMessagePolicy": "File",
                                "imagePullPolicy": "Always"
                            }
                        ],
                        "restartPolicy": "Always",
                        "terminationGracePeriodSeconds": 30,
                        "dnsPolicy": "ClusterFirst",
                        "securityContext": {},
                        "imagePullSecrets": [
                            {
                                "name": "default-secret"
                            }
                        ],
                        "affinity": {},
                        "schedulerName": "default-scheduler"
                    }
                }
            },
            "status": {
                "replicas": 2,
                "fullyLabeledReplicas": 2,
                "readyReplicas": 2,
                "availableReplicas": 2,
                "observedGeneration": 1
            }
        }
    ]
}

Status Code

Table 3 Status code

Status Code

Description

200

This operation succeeds, and a ReplicaSet resource object is returned.

For more status codes, see Status Codes.