Listing Services
Function
This API is used to query the details about all services under a specified namespace.
URI
GET /api/v1/namespaces/{namespace}/services
| 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. |
| labelSelector | No | A selector to restrict the list of returned objects by their labels. Defaults to everything. |
| fieldSelector | No | A selector to restrict the list of returned objects by their fields. Defaults to everything. |
| watch | No | Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. |
| 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. |
| namespace | Yes | Object name and auth scope, such as for teams and projects. |
| includeUninitialized | No | If true, partially initialized resources are included in the response. |
Request
N/A
Response
Response parameters
For the description about response parameters, see Table 109.
Example response
{
"kind": "ServiceList",
"apiVersion": "v1",
"metadata": {
"selfLink": "/api/v1/namespaces/namespace-test/services",
"resourceVersion": "5147871"
},
"items": [
{
"metadata": {
"name": "kube-dns",
"namespace": "namespace-test",
"selfLink": "/api/v1/namespaces/namespace-test/services/kube-dns",
"uid": "6d356f18-af6b-11e8-b6ef-f898ef6c78b4",
"resourceVersion": "5016792",
"creationTimestamp": "2018-09-03T11:20:56Z",
"labels": {
"addonmanager.kubernetes.io/mode": "Reconcile",
"app": "kube-dns",
"kubernetes.io/cluster-service": "true",
"kubernetes.io/name": "KubeDNS"
},
"enable": true
},
"spec": {
"ports": [
{
"name": "dns",
"protocol": "UDP",
"port": 53,
"targetPort": 5353
},
{
"name": "dns-tcp",
"protocol": "TCP",
"port": 53,
"targetPort": 5353
}
],
"selector": {
"app": "kube-dns"
},
"clusterIP": "10.247.189.43",
"type": "ClusterIP",
"sessionAffinity": "None"
},
"status": {
"loadBalancer": {}
}
},
{
"metadata": {
"name": "redis",
"namespace": "namespace-test",
"selfLink": "/api/v1/namespaces/namespace-test/services/redis",
"uid": "d6a1ce79-afdb-11e8-b6ef-f898ef6c78b4",
"resourceVersion": "5146412",
"creationTimestamp": "2018-09-04T00:45:36Z",
"labels": {
"app": "redis"
},
"enable": true
},
"spec": {
"ports": [
{
"name": "service0",
"protocol": "TCP",
"port": 8080,
"targetPort": 80
}
],
"selector": {
"app": "redis"
},
"clusterIP": "10.247.212.210",
"type": "ClusterIP",
"sessionAffinity": "None"
},
"status": {
"loadBalancer": {}
}
}
]
} Status Code
Table 3 describes the status code of this API.
| Status Code | Description |
|---|---|
| 200 | This operation succeeds, and a group of Service resource objects is returned. |
For more status codes, see Status Codes.
Last Article: Reading a Service
Next Article: Reading the Status of a Service
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.