WebMagicInformatica
CKA practice questions

CKA practice questions: Services and Networking

5 free questions on Services and Networking, 20% of the Kubernetes: CKA exam. Try each one, then open the answer and explanation. None of them are in the free readiness check, so you can still take it fresh.

Question 1

You want to block all inbound traffic to every Pod in the namespace shop unless another policy allows it. Which manifest does that?

  1. A.
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: default-deny-ingress
      namespace: shop
    spec:
      podSelector: {}
      ingress:
      - {}
  2. B.
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: default-deny-ingress
      namespace: shop
    spec:
      podSelector: {}
      policyTypes:
      - Ingress
  3. C.
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: default-deny-ingress
      namespace: shop
    spec:
      podSelector: {}
      policyTypes:
      - Egress
  4. D.
    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: default-deny-ingress
      namespace: shop
    spec:
      podSelector:
        matchLabels:
          app: shop
      policyTypes:
      - Ingress
Show answer and explanation

Answer: B

An empty podSelector selects every Pod in the namespace, and listing Ingress under policyTypes with no ingress rules means nothing is allowed in.

  • ingress: [{}] is an allow-all rule.
  • policyTypes: [Egress] restricts outbound traffic, not inbound.
  • matchLabels: {app: shop} only selects Pods carrying that label, so other Pods in the namespace stay open.
Question 2Choose 2

An Ingress resource has been created for an application but kubectl get ingress shows an empty ADDRESS column and traffic does not reach the app. Which TWO actions are needed to make Ingress work? (Choose two.)

  1. A.

    Delete the default kube-proxy DaemonSet so the Ingress can bind port 80.

  2. B.

    Install an Ingress controller (for example ingress-nginx) in the cluster.

  3. C.

    Set ingressClassName on the Ingress to match an existing IngressClass served by that controller.

  4. D.

    Change the backing Service to type NodePort with a random port.

  5. E.

    Replace the Ingress with a NetworkPolicy that allows port 80.

Show answer and explanation

Answer: B and C

An Ingress object is only a set of rules. An Ingress controller must run to implement it, and the Ingress must target that controller's IngressClass (unless a default class is set).

  • Ingress backends normally use ClusterIP Services.
  • NetworkPolicies only filter traffic and cannot route it.
  • kube-proxy is unrelated to Ingress.
Question 3Choose 2

Which TWO statements about NetworkPolicy are correct? (Choose two.)

  1. A.

    A Pod that no policy selects is isolated from all traffic by default.

  2. B.

    NetworkPolicy works the same with every CNI plugin, including those without policy support.

  3. C.

    Policies are evaluated in order and the first match wins.

  4. D.

    Policies are enforced by the network plugin, so the CNI in use must support NetworkPolicy.

  5. E.

    Policies are additive: if several policies select a Pod, the union of their allow rules applies.

Show answer and explanation

Answer: D and E

NetworkPolicy has only allow rules, which are combined. The API object does nothing unless the CNI implements it.

  • There is no ordering or deny rule.
  • Pods not selected by any policy are non-isolated and accept all traffic.
  • With a CNI that lacks support, policies are accepted but silently ignored.
Question 4

An Ingress rule uses path: /api with pathType: Exact. Requests to /api/users return 404, while /api works. What change makes /api/users reach the backend?

  1. A.

    Set pathType: ImplementationSpecific and remove the path.

  2. B.

    Set pathType: Prefix for the /api path.

  3. C.

    Add a trailing wildcard * to the Exact path.

  4. D.

    Change the Service port to 80.

Show answer and explanation

Answer: B

Exact matches the URL path exactly, while Prefix matches on path elements, so /api/users matches the prefix /api.

  • Removing the path makes the rule ambiguous.
  • Ingress paths are not glob patterns; with Exact a * is just a literal character, so /api/users would still not match.
  • The Service port is unrelated to path matching.
Question 5

You use Gateway API and want to send 90% of traffic to app-v1 and 10% to app-v2 for path /. How is this configured?

  1. A.

    Create two Gateways, one per version, with listeners on ports 90 and 10.

  2. B.

    Add the annotation canary: 10 to the HTTPRoute.

  3. C.

    Create two identical rules matching /; Kubernetes splits them 90/10.

  4. D.

    In one HTTPRoute rule, list two backendRefs with weight: 90 for app-v1 and weight: 10 for app-v2.

Show answer and explanation

Answer: D

HTTPRoute backendRefs support weights, which split traffic proportionally.

  • Listener ports are unrelated to traffic percentages.
  • Annotations like this are not part of the API.
  • Duplicate rules do not split traffic.

How ready are you for CKA?

Take the free readiness check: 15 questions from every exam domain in 20 minutes, with your score per domain.

  • 20 minutes
  • 15 questions
  • Free with an account

More CKA practice by topic

Back to the CKA practice test →

Independent practice material written from the official exam guide. Not affiliated with or endorsed by the exam provider.