更新时间:2022-04-18 GMT+08:00
分享

获取指定的networkpolicy

功能介绍

This API is used to read the specified NetworkPolicy

URL

GET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

表1描述该API的参数。

表1 参数解释

参数

是否必选

描述

name

Yes

name of the NetworkPolicy

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 can not specify.

pretty

No

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

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数

响应示例:

{
    "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"
        ]
    }
}

状态码

状态码描述API的状态码。

表2 状态码

状态码

描述

200

OK

异常状态码请参见状态码

分享:

    相关文档

    相关产品

close