A security audit reveals that the kube-apiserver is using the default insecure port 8080 on a production cluster. Which is the most secure and recommended remediation?
Trap 1: Change the --insecure-port flag to 0
Setting --insecure-port=0 disables the HTTP listener on the kube-apiserver, but this alone does not guarantee that the API server is securely reachable. The control plane may still have the insecure port enabled via a separate bind address or default configuration, and without explicitly confirming --secure-port=6443 and its TLS settings, the remediation is incomplete. Therefore, while disabling the insecure port is a necessary step, it is insufficient as the 'most secure' fix.
Trap 2: Set --insecure-port=6443
Setting --insecure-port=6443 would expose the insecure, plaintext HTTP API on the default secure port, effectively replacing the TLS-protected endpoint with an unauthenticated one. This is critically dangerous because port 6443 is typically used for the secure API server, and doing so would allow unencrypted, unauthenticated access to the cluster, violating security best practices. The correct approach is to disable the insecure port entirely.
Trap 3: Set --secure-port=8080
Setting --secure-port=8080 reconfigures the TLS-serving port to 8080, but it does not disable the insecure port, which defaults to 8080 in some configurations. This can create a port conflict if the insecure listener is still active, or it may move the secure endpoint to a non-standard port without addressing the underlying plaintext listener. The most secure remediation must explicitly disable the insecure port (--insecure-port=0) and keep the secure port on its default 6443 with TLS, not just shift ports around.
- A
Change the --insecure-port flag to 0
Why wrong: Setting --insecure-port=0 disables the HTTP listener on the kube-apiserver, but this alone does not guarantee that the API server is securely reachable. The control plane may still have the insecure port enabled via a separate bind address or default configuration, and without explicitly confirming --secure-port=6443 and its TLS settings, the remediation is incomplete. Therefore, while disabling the insecure port is a necessary step, it is insufficient as the 'most secure' fix.
- B
Set --insecure-port=0 and ensure --secure-port=6443 is configured
Setting --insecure-port=0 disables the plaintext HTTP endpoint on the kube-apiserver, eliminating unauthenticated access. Simultaneously ensuring --secure-port=6443 is configured guarantees that all API communication is served over TLS on the standard secure port, using client certificate and token authentication. This combination is the recommended hardening measure per Kubernetes documentation.
- C
Set --insecure-port=6443
Why wrong: Setting --insecure-port=6443 would expose the insecure, plaintext HTTP API on the default secure port, effectively replacing the TLS-protected endpoint with an unauthenticated one. This is critically dangerous because port 6443 is typically used for the secure API server, and doing so would allow unencrypted, unauthenticated access to the cluster, violating security best practices. The correct approach is to disable the insecure port entirely.
- D
Set --secure-port=8080
Why wrong: Setting --secure-port=8080 reconfigures the TLS-serving port to 8080, but it does not disable the insecure port, which defaults to 8080 in some configurations. This can create a port conflict if the insecure listener is still active, or it may move the secure endpoint to a non-standard port without addressing the underlying plaintext listener. The most secure remediation must explicitly disable the insecure port (--insecure-port=0) and keep the secure port on its default 6443 with TLS, not just shift ports around.