Listing All Deployments

Function

This API is used to list all Deployments under a specified namespace.

URI

GET /apis/apps/v1beta1/namespaces/{namespace}/deployments

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

namespace

Yes

Namespace to which the Deployments you want to query belong.

fieldSelector

No

A selector to restrict the list of returned objects by their fields. Defaults to everything.

includeUninitialized

No

If true, partially initialized resources are included in the response.

labelSelector

No

A selector to restrict the list of returned objects by their labels. Defaults to everything.

pretty

No

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

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. When specified for list: - if unset, then the result is returned from remote storage based on quorum-read flag; - if it is 0, then we simply return what we currently have in cache, no guarantee; - if set to non zero, then the result is at least as fresh as given rv.

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.

Table 2 Parameter description

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

Table 13

Standard list metadata.

Example response

{
    "kind": "DeploymentList", 
    "apiVersion": "apps/v1beta1", 
    "metadata": {
        "selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/deployments", 
        "resourceVersion": "4510944"
    }, 
    "items": [
        {
            "metadata": {
                "name": "deployment-test", 
                "namespace": "8f6c39e7c269440c881bba2fc49586d6", 
                "selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/deployments/deployment-test", 
                "uid": "ed89a51c-2728-11e8-b891-84a9c46e8c8b", 
                "resourceVersion": "4510944", 
                "generation": 3, 
                "creationTimestamp": "2018-03-14T01:42:17Z", 
                "labels": {
                    "appgroup": ""
                }, 
                "annotations": {
                    "deployment.kubernetes.io/revision": "1", 
                    "description": ""
                }, 
                "enable": true
            }, 
            "spec": {
                "replicas": 1, 
                "selector": {
                    "matchLabels": {
                        "app": "deployment-test"
                    }
                }, 
                "template": {
                    "metadata": {
                        "creationTimestamp": null, 
                        "labels": {
                            "app": "deployment-test"
                        }, 
                        "annotations": {
                            "com.huawei.scheduler/container-type": "secure-container", 
                            "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]"
                        }, 
                        "enable": true
                    }, 
                    "spec": {
                        "containers": [
                            {
                                "name": "container-0", 
                                "image": "nginx:latest", 
                                "resources": {
                                    "limits": {
                                        "cpu": "1", 
                                        "memory": "1024Mi"
                                    }, 
                                    "requests": {
                                        "cpu": "1", 
                                        "memory": "1024Mi"
                                    }
                                }, 
                                "lifecycle": {}, 
                                "terminationMessagePath": "/dev/termination-log", 
                                "terminationMessagePolicy": "File", 
                                "imagePullPolicy": "Always"
                            }
                        ], 
                        "restartPolicy": "Always", 
                        "terminationGracePeriodSeconds": 30, 
                        "dnsPolicy": "ClusterFirst", 
                        "securityContext": {}, 
                        "imagePullSecrets": [
                            {
                                "name": "imagepull-secret"
                            }
                        ], 
                        "affinity": {}, 
                        "schedulerName": "default-scheduler"
                    }
                }, 
                "strategy": {
                    "type": "RollingUpdate", 
                    "rollingUpdate": {
                        "maxUnavailable": 1, 
                        "maxSurge": 0
                    }
                }, 
                "revisionHistoryLimit": 2, 
                "progressDeadlineSeconds": 600
            }, 
            "status": {
                "observedGeneration": 3, 
                "replicas": 1, 
                "updatedReplicas": 1, 
                "unavailableReplicas": 1, 
                "conditions": [
                    {
                        "type": "Available", 
                        "status": "True", 
                        "lastUpdateTime": "2018-03-14T01:42:17Z", 
                        "lastTransitionTime": "2018-03-14T01:42:17Z", 
                        "reason": "MinimumReplicasAvailable", 
                        "message": "Deployment has minimum availability."
                    }, 
                    {
                        "type": "Progressing", 
                        "status": "True", 
                        "lastUpdateTime": "2018-03-14T01:42:17Z", 
                        "lastTransitionTime": "2018-03-14T01:42:17Z", 
                        "reason": "ReplicaSetUpdated", 
                        "message": "ReplicaSet \"deployment-test-4094680052\" is progressing."
                    }
                ]
            }
        }, 
        {
            "metadata": {
                "name": "ocean", 
                "namespace": "8f6c39e7c269440c881bba2fc49586d6", 
                "selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/deployments/ocean", 
                "uid": "f0bdbf83-25d8-11e8-a5eb-84a9c46e8c8b", 
                "resourceVersion": "4145374", 
                "generation": 1, 
                "creationTimestamp": "2018-03-12T09:37:11Z", 
                "labels": {
                    "appgroup": ""
                }, 
                "annotations": {
                    "deployment.kubernetes.io/revision": "1", 
                    "description": ""
                }, 
                "enable": true
            }, 
            "spec": {
                "replicas": 2, 
                "selector": {
                    "matchLabels": {
                        "app": "ocean"
                    }
                }, 
                "template": {
                    "metadata": {
                        "creationTimestamp": null, 
                        "labels": {
                            "app": "ocean"
                        }, 
                        "annotations": {
                            "com.huawei.scheduler/container-type": "secure-container", 
                            "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]"
                        }, 
                        "enable": true
                    }, 
                    "spec": {
                        "containers": [
                            {
                                "name": "container-0", 
                                "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"
                    }
                }, 
                "strategy": {
                    "type": "RollingUpdate", 
                    "rollingUpdate": {
                        "maxUnavailable": 1, 
                        "maxSurge": 0
                    }
                }, 
                "revisionHistoryLimit": 2, 
                "progressDeadlineSeconds": 600
            }, 
            "status": {
                "observedGeneration": 1, 
                "replicas": 2, 
                "updatedReplicas": 2, 
                "readyReplicas": 2, 
                "availableReplicas": 2, 
                "conditions": [
                    {
                        "type": "Available", 
                        "status": "True", 
                        "lastUpdateTime": "2018-03-12T09:37:13Z", 
                        "lastTransitionTime": "2018-03-12T09:37:13Z", 
                        "reason": "MinimumReplicasAvailable", 
                        "message": "Deployment has minimum availability."
                    }, 
                    {
                        "type": "Progressing", 
                        "status": "True", 
                        "lastUpdateTime": "2018-03-12T09:37:17Z", 
                        "lastTransitionTime": "2018-03-12T09:37:11Z", 
                        "reason": "NewReplicaSetAvailable", 
                        "message": "ReplicaSet \"ocean-211195136\" has successfully progressed."
                    }
                ]
            }
        }, 
        {
            "metadata": {
                "name": "pzb-test", 
                "namespace": "8f6c39e7c269440c881bba2fc49586d6", 
                "selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/deployments/pzb-test", 
                "uid": "198d874c-265e-11e8-b891-84a9c46e8c8b", 
                "resourceVersion": "4312987", 
                "generation": 4, 
                "creationTimestamp": "2018-03-13T01:30:23Z", 
                "labels": {
                    "appgroup": ""
                }, 
                "annotations": {
                    "deployment.kubernetes.io/revision": "2", 
                    "description": "test"
                }, 
                "enable": true
            }, 
            "spec": {
                "replicas": 1, 
                "selector": {
                    "matchLabels": {
                        "app": "pzb-test"
                    }
                }, 
                "template": {
                    "metadata": {
                        "creationTimestamp": null, 
                        "labels": {
                            "app": "pzb-test"
                        }, 
                        "annotations": {
                            "com.huawei.scheduler/container-type": "secure-container", 
                            "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]"
                        }, 
                        "enable": true
                    }, 
                    "spec": {
                        "containers": [
                            {
                                "name": "container-0", 
                                "image": "nginx:latest", 
                                "env": [
                                    {
                                        "name": "cci", 
                                        "value": "test"
                                    }
                                ], 
                                "resources": {
                                    "limits": {
                                        "cpu": "250m", 
                                        "memory": "107374182400m"
                                    }, 
                                    "requests": {
                                        "cpu": "250m", 
                                        "memory": "107374182400m"
                                    }
                                }, 
                                "lifecycle": {}, 
                                "terminationMessagePath": "/dev/termination-log", 
                                "terminationMessagePolicy": "File", 
                                "imagePullPolicy": "Always"
                            }
                        ], 
                        "restartPolicy": "Always", 
                        "terminationGracePeriodSeconds": 30, 
                        "dnsPolicy": "ClusterFirst", 
                        "securityContext": {}, 
                        "imagePullSecrets": [
                            {
                                "name": "imagepull-secret"
                            }
                        ], 
                        "affinity": {}, 
                        "schedulerName": "default-scheduler"
                    }
                }, 
                "strategy": {
                    "type": "RollingUpdate", 
                    "rollingUpdate": {
                        "maxUnavailable": 1, 
                        "maxSurge": 0
                    }
                }, 
                "revisionHistoryLimit": 2, 
                "progressDeadlineSeconds": 600
            }, 
            "status": {
                "observedGeneration": 4, 
                "replicas": 1, 
                "updatedReplicas": 1, 
                "readyReplicas": 1, 
                "availableReplicas": 1, 
                "conditions": [
                    {
                        "type": "Available", 
                        "status": "True", 
                        "lastUpdateTime": "2018-03-13T02:36:24Z", 
                        "lastTransitionTime": "2018-03-13T02:36:24Z", 
                        "reason": "MinimumReplicasAvailable", 
                        "message": "Deployment has minimum availability."
                    }, 
                    {
                        "type": "Progressing", 
                        "status": "True", 
                        "lastUpdateTime": "2018-03-13T03:57:57Z", 
                        "lastTransitionTime": "2018-03-13T01:30:23Z", 
                        "reason": "NewReplicaSetAvailable", 
                        "message": "ReplicaSet \"pzb-test-1040447754\" has successfully progressed."
                    }
                ]
            }
        }
    ]
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

200

This operation succeeds.

For more status codes, see Status Codes.