CKAD Prep Part 16 – Network Policies

Network Policies By default, a Pod can communicate with any other Pod in the same cluster. NetworkPolicies allow you to limit the network traffic allowed to and from Pods in the cluster. A sample NetworkPolicy is shown below. apiVersion: kind: NetworkPolicy metadata: name: sample-network-policy spec: podSelector: matchLabels: app: secure-app policyTypes: - Ingress - Egress ingress: # traffic coming into the Pod - from: - podSelector: matchLabels: allow-access: "true" # allow inbound traffic from Pods that have this label ports: - protocol: TCP port: 6379 egress: # traffic coming into the Pod - to: - podSelector: matchLabels: allow-access: "true" # allow outbound traffic to Pods [...]