Reading a Specified NetworkPolicy
Function
This API is used to read a specified NetworkPolicy.
URL
GET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}
Table 1 describes the parameters of this API.
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
name |
Yes |
Name of the network policy. |
|
namespace |
Yes |
Object name and auth scope, such as for teams and projects. |
|
exact |
No |
Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'. |
|
export |
No |
Should this value be exported. Export strips fields that a user cannot specify. |
|
pretty |
No |
If 'true', then the output is pretty printed. |
Request
N/A
Example response:
{
"kind": "NetworkPolicy",
"apiVersion": "networking.k8s.io/v1",
"metadata": {
"name": "test-network-policy",
"namespace": "default",
"selfLink": "/apis/networking.k8s.io/v1/namespaces/default/networkpolicies/test-network-policy",
"uid": "be347ddd-e8af-11e8-b187-fa163e3cca63",
"resourceVersion": "213982",
"generation": 1,
"creationTimestamp": "2018-11-15T08:23:34Z",
"labels": {
"app": "nginx"
}
},
"spec": {
"podSelector": {
"matchLabels": {
"app": "nginx"
}
},
"ingress": [{
"from": [{
"podSelector": {
"matchLabels": {
"app": "nginx2"
}
}
}],
"ports": [{
"protocol": "TCP",
"port": 6379
}]
}],
"policyTypes":[
"Ingress"
]
}
}
Status Code
Table 2 describes the status code of this API.
For the description about error status codes, see Status Code.
Last Article: Deleting NetworkPolicies in Batches
Next Article: Obtaining the NetworkPolicy List Under a Specified Namespace
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.