Review the legacy kube-apiserver insecure port setting

Close the legacy kube-apiserver insecure HTTP port and move clients to protected API access.

Description

Older kube-apiserver versions could open an HTTP port without TLS, authentication or authorization through --insecure-port. The flag had no effect from Kubernetes 1.20 and was removed in 1.24.

Potential impact

Depending on the bind address and network route, clients reaching the listener could read cluster data or change workloads without permission checks.

Remediation

Move clients to an API endpoint protected by TLS, authentication and authorization. On versions where the option still works, set --insecure-port=0 and verify that the HTTP port is closed. Test required administrative operations and denial of unauthorized requests, then upgrade to a supported release.

Examples

The Kubernetes 1.6 example changes the insecure port from 1143 to 0 to disable the listener. Supply the protected endpoint and client authentication separately.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: api-server
spec:
  containers:
    - name: kube-apiserver
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command:
        - "kube-apiserver"
        - "--insecure-port=1143"

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: api-server
spec:
  containers:
    - name: kube-apiserver
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command:
        - "kube-apiserver"
        - "--insecure-port=0"

References