ExamPilot Global home

CKS lab · Isolate ingress in a namespace

A lab namespace needs explicit allow rules for ingress.

ExamPilot graduation owl

Initial conditions

Use a disposable cluster with a network plugin that enforces NetworkPolicy. Create namespace lab and a reachable web test workload.

Objective

Apply a default-deny ingress policy, then check the same probe used before the change.

Hint

An empty podSelector selects every Pod in the policy namespace.

Solution manifest

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-ingress
spec:
  podSelector: {}
  policyTypes: [Ingress]

Solution commands

kubectl -n lab apply -f deny-ingress.yaml

Validate the result

kubectl -n lab describe networkpolicy default-deny-ingress
kubectl -n lab exec probe -- wget -T 3 -O- http://web

With no additional allowing policy, a probe Pod in the namespace should no longer reach the selected backend. Policies add allowed traffic together.

Common mistakes

An implementation that does not enforce policies will still allow traffic. Ingress-only rules do not isolate egress.

Free official documentation · Verified 26 November 2026

Use your own disposable Kubernetes environment.