Review legacy Basic authentication settings in GKE

Remove obsolete Basic authentication settings and login procedures from GKE configurations.

Description

GKE removed basic authentication with a username and static password in 1.19. Move any tools or automation that depend on it to Google Cloud OAuth.

Potential impact

A shared password makes individual access hard to trace or rotate. Where an old cluster still accepts it, disclosure can expose the account’s permissions.

Remediation

Test that users and automation can perform the required operations with OAuth and limit their IAM and Kubernetes RBAC grants. If an existing cluster still accepts basic authentication, disable it there with --no-enable-basic-auth. Remove old master_auth.username and master_auth.password values from configuration, automation and operating procedures.

Examples

Supply your project and the path to a protected service account JSON file. Ansible uses this file to authenticate to Google Cloud.

Before

yaml
- name: create a cluster4
  google.cloud.gcp_container_cluster:
    name: my-cluster4
    initial_node_count: 2
    master_auth:
      username: cluster_admin
      password: ""
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ gcp_project }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_service_account_file }}"
    state: present

- name: create a cluster5
  google.cloud.gcp_container_cluster:
    name: my-cluster5
    initial_node_count: 2
    master_auth:
      username: ""
      password: my-secret-password
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ gcp_project }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_service_account_file }}"
    state: present

my-cluster4 supplies only a username. my-cluster5 supplies a password without a username, which is invalid.

After

yaml
- name: create a cluster
  google.cloud.gcp_container_cluster:
    name: my-cluster
    initial_node_count: 2
    master_auth:
      username: ""
      password: ""
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ gcp_project }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_service_account_file }}"
    state: present

The new my-cluster leaves both basic credential fields empty. Configure OAuth access and IAM permissions separately.

References