Review public access to GKE nodes and the control plane

Review external IPs on GKE nodes and access paths to the control plane separately, and permit only required administration paths.

Description

Private nodes have no external IP addresses. The control plane has separate access settings for its external IP and DNS endpoints.

Potential impact

Firewall rules can expose node services to external connection attempts. The public API endpoint still requires authentication, but an account with excessive permissions can change workloads or cluster settings.

Remediation

  1. Use private nodes for internal workloads and provide the outbound connections they need.
  2. Before disabling the external IP endpoint, test the internal path from operator and automation networks. If you need the external IP, allow only approved management networks.
  3. Apply IAM and network controls to DNS access. After the change, verify node and management connectivity and Kubernetes RBAC permissions.

Examples

These tasks create new clusters. Supply the project, VPC, subnet, IP allocation and any control-plane CIDR your version requires. Replace /tmp/auth.pem with the path to a service account JSON file. GKE 1.19 and later do not support basic username/password authentication.

Before

yaml
- name: create a cluster1
  google.cloud.gcp_container_cluster:
    name: my-cluster1
    initial_node_count: 2
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ project_id }}"
    auth_kind: serviceaccount
    service_account_file: "/tmp/auth.pem"
    state: present

- name: create a cluster4
  google.cloud.gcp_container_cluster:
    name: my-cluster4
    initial_node_count: 2
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ project_id }}"
    auth_kind: serviceaccount
    service_account_file: "/tmp/auth.pem"
    state: present
    private_cluster_config:
      enable_private_endpoint: no
      enable_private_nodes: yes

my-cluster1 omits private networking settings. my-cluster4 uses private nodes and keeps the external control-plane IP endpoint.

After

yaml
- name: create a cluster
  google.cloud.gcp_container_cluster:
    name: my-cluster
    initial_node_count: 2
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ project_id }}"
    auth_kind: serviceaccount
    service_account_file: /tmp/auth.pem
    state: present
    private_cluster_config:
      enable_private_endpoint: yes
      enable_private_nodes: yes

my-cluster enables both enable_private_nodes and enable_private_endpoint. It has a different name. To update an existing cluster or move workloads, follow the GKE procedure for that operation.

References