NetworkPolicy resource fields and annotations
NetworkPolicy is a resource for managing access to services published via Network Load Balancer based on IP addresses.
NetworkPolicy is a standard Kubernetes resource. This reference describes the resource fields and annotations supported by Network Load Balancer for Managed Service for Kubernetes. For a complete reference for the resource, see this Kubernetes guide
For more information about network policies, see Kubernetes cluster network policies.
NetworkPolicy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: <ObjectMeta>
spec: <NetworkPolicySpec>
|
Field |
Value / Type |
Description |
|
|
|
This is a required field. |
|
|
|
Resource type. |
|
|
|
This is a required field. |
|
|
|
This is a required field. |
Example
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: whitelist-netpol
namespace: ns-example
spec:
podSelector:
matchLabels:
role: db
policyTypes:
- Ingress
ingress:
- from:
- ipBlock:
cidr: 198.18.235.0/24
- ipBlock:
cidr: 198.18.248.0/24
- ipBlock:
cidr: 172.16.1.0/12
ObjectMeta
name: <string>
namespace: <string>
|
Field |
Value / Type |
Description |
|
|
|
This is a required field. |
|
|
|
Namespace for the policy. |
NetworkPolicySpec
podSelector: <selectorRules>
policyTypes:
- Ingress
ingress:
- <IngressRule>
- ...
|
Field |
Value / Type |
Description |
|
|
|
This is a required field. |
|
|
|
This is a required field. |
|
|
|
This is a required field. |
IngressRule
from:
- ipBlock: <IPBlock>
- ...
|
Field |
Value / Type |
Description |
|
|
|
This is a required field. |
IPBlock
ipBlock:
cidr: <string>
|
Field |
Value / Type |
Description |
|
|
|
This is a required field. The |