Fields and annotations of the NetworkPolicy resource
NetworkPolicy
is a resource used for connecting to services published via Network Load Balancer from specified IP addresses.
NetworkPolicy
is a standard Kubernetes resource. This reference describes the resource's fields and annotations supporting Network Load Balancer for Managed Service for Kubernetes. For a complete reference for the resource, please see the Kubernetes documentation
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 or type |
Description |
|
|
Required |
|
|
Resource type |
|
|
Required |
|
|
Required |
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 or type |
Description |
|
|
Required |
|
|
Namespace for saving the policy |
NetworkPolicySpec
podSelector: <selectorRules>
policyTypes:
- Ingress
ingress:
- <IngressRule>
- ...
Field |
Value or type |
Description |
|
|
Required |
|
|
Required |
|
|
Required |
IngressRule
from:
- ipBlock: <IPBlock>
- ...
Field |
Value or type |
Description |
|
|
Required |
IPBlock
ipBlock:
cidr: <string>
Field |
Value or type |
Description |
|
|
Required The |