Skip to content

KCSA · Domain 2: Kubernetes Cluster Component Security · 22% of the exam

Task 2.6: KubeProxy

What kube-proxy does on each node, its credentials and metrics endpoints, and how Service traffic rules relate to network policy.

Study it

  • Kubelet, container runtime and kube-proxy

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the CNCF documentation page that proves it.

Question 1 · choose 1

A shared cluster lets tenants create their own Services. An advisory explains that a tenant could set spec.externalIPs on a Service to an address used by another system, and kube-proxy on every node would then route traffic for that address to the tenant's Pods. One legacy Service run by the platform team already uses the field and must keep serving its two addresses until its migration next quarter; the platform pipeline still changes that Service's ports and selector during the migration. Tenants must not be able to add external addresses anywhere. What should the administrators enable?

  1. AThe DenyServiceExternalIPs admission controller
  2. Bkube-proxy's nodePortAddresses limited to the node subnet so that external IPs are not served
  3. CA default-deny egress NetworkPolicy in each tenant namespace
  4. DA ValidatingAdmissionPolicy that rejects any Service create or update with spec.externalIPs set
Show the answer and why
  • AThe DenyServiceExternalIPs admission controller

    Correct

    It rejects new Services that use externalIPs and new values added to existing Services, while existing uses are not affected, so the legacy Service keeps its two addresses and can still be updated.

  • Bkube-proxy's nodePortAddresses limited to the node subnet so that external IPs are not served

    Incorrect

    nodePortAddresses selects the node addresses on which NodePort Services are served; it does not stop kube-proxy from routing a Service's externalIPs, and it would not keep tenants from setting them.

  • CA default-deny egress NetworkPolicy in each tenant namespace

    Incorrect

    The interception affects traffic that other clients send to the external address; restricting what tenant Pods may send does not stop kube-proxy from routing that traffic to them.

  • DA ValidatingAdmissionPolicy that rejects any Service create or update with spec.externalIPs set

    Incorrect

    The policy evaluates the object in each create and update request. An update of the legacy Service still carries its two externalIPs, so the pipeline's port and selector changes would be rejected.

externalIPs let any Service claim an address that kube-proxy then routes to the Service's Pods, which enables traffic interception (CVE-2020-8554, cited in the security checklist); the field is deprecated since v1.36. DenyServiceExternalIPs blocks net-new use of the field, both in new Services and as added values, and leaves existing uses alone, which suits a cluster where one legacy Service still depends on it and is still being changed. A policy that rejects any object carrying the field would block those changes too.

Question 2 · choose 1

By default, on which address and port does kube-proxy serve its metrics?

  1. A127.0.0.1:10249, reachable only from the node itself
  2. B0.0.0.0:10249, on every interface of the node
  3. C0.0.0.0:10250, next to the kubelet
  4. DThrough the API server's /metrics endpoint
Show the answer and why
  • A127.0.0.1:10249, reachable only from the node itself

    Correct

    The kube-proxy reference gives --metrics-bind-address a default of 127.0.0.1:10249.

  • B0.0.0.0:10249, on every interface of the node

    Incorrect

    The default binds metrics to localhost, not to all interfaces.

  • C0.0.0.0:10250, next to the kubelet

    Incorrect

    10250 is the kubelet's HTTPS port, not where kube-proxy serves metrics.

  • DThrough the API server's /metrics endpoint

    Incorrect

    kube-proxy serves its own metrics; the API server's /metrics covers the API server.

kube-proxy binds its metrics endpoint to 127.0.0.1:10249 by default, so only processes on the node can read it. Changing the metrics bind address to all interfaces exposes those metrics to the network.

Question 3 · choose 1

A platform team wants the long-running kube-proxy process on each node to hold as few privileges as possible. What does the kube-proxy reference describe for this?

  1. AStart it with --cleanup, after which it runs without any capabilities
  2. BSet --bind-address to 127.0.0.1 so that it needs no root privileges
  3. CEnable --masquerade-all, which lets it run as an unprivileged user
  4. DRun it once with --init-only for the root-only steps, then run it with only CAP_NET_ADMIN
Show the answer and why
  • AStart it with --cleanup, after which it runs without any capabilities

    Incorrect

    --cleanup removes iptables and IPVS rules and exits; it is not a way to run kube-proxy with fewer privileges.

  • BSet --bind-address to 127.0.0.1 so that it needs no root privileges

    Incorrect

    The reference says kube-proxy does not actually bind sockets to that address; it only overrides kube-proxy's idea of the node's primary IP.

  • CEnable --masquerade-all, which lets it run as an unprivileged user

    Incorrect

    --masquerade-all makes kube-proxy SNAT all traffic sent through Service cluster IPs; it has nothing to do with the process's privileges.

  • DRun it once with --init-only for the root-only steps, then run it with only CAP_NET_ADMIN

    Correct

    The reference says --init-only performs the initialization that needs full root privileges and exits, after which kube-proxy can run again with only the CAP_NET_ADMIN capability.

kube-proxy needs full root privileges only for some initialization steps. With --init-only it performs those steps and exits; the long-running kube-proxy can then run with just CAP_NET_ADMIN, which limits what a compromise of that process can do.

Practice domain 2 →Practice all domains →