In Kubernetes, what is the default behavior of pod-to-pod communication when no network policies are applied?
Think about the default openness of pod networking before any restrictions are set.
By default, Kubernetes allows all pods to communicate with each other without restrictions unless network policies are applied to restrict traffic.
Given the following NetworkPolicy YAML applied to a namespace, what will be the effect on pod ingress traffic?
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-ingress
spec:
podSelector: {}
policyTypes:
- IngressConsider what an empty podSelector and only Ingress policyTypes imply.
This policy selects all pods (empty podSelector) and denies all ingress traffic because no ingress rules are specified, effectively blocking all incoming connections.
Which NetworkPolicy configuration correctly allows ingress traffic only from pods in the namespace labeled team=frontend?
Focus on the difference between namespaceSelector and podSelector and the label keys.
Option A correctly uses namespaceSelector with the label team: frontend to allow ingress only from pods in namespaces labeled accordingly. Option A incorrectly uses podSelector which selects pods in the same namespace, not namespaces. Options A and C use wrong label keys or values.
A developer reports that pods in namespace dev cannot receive traffic from pods in namespace test even though a NetworkPolicy allows ingress from test. What is a likely cause?
Check if the source namespace matches the label selector in the policy.
If the test namespace does not have the label that the NetworkPolicy's namespaceSelector matches, traffic from test pods will be blocked despite the policy.
Arrange the steps in the correct order to secure a Kubernetes namespace by restricting all ingress traffic except from a trusted namespace.
Think about labeling first, then defining policies, then applying them.
First, label the trusted namespace so it can be referenced. Then create a deny-all ingress policy to block all traffic by default. Next, create a policy allowing ingress from the trusted namespace using the label. Finally, apply these policies to enforce the rules.