GKE logging is disabled

Verify collection of the system and workload logs needed for GKE.

Description

For a new GKE Standard cluster, set logging_service: logging.googleapis.com/kubernetes to select Cloud Logging. If the task omits this setting, GKE can apply its default.

Potential impact

With collection disabled, Cloud Logging may have no record of which Pod reported an error.

Remediation

For an existing cluster, use gcloud container clusters update with --logging to choose the required components. If you collect workload output, emit a test log from a container and find it under the intended cluster in Logs Explorer. Set a retention period.

Examples

The examples leave my-cluster1 at its default and disable collection on my-cluster2 with none. The final task creates a different cluster, my-cluster. Supply the actual project and the path to a protected service-account JSON file.

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: "{{ gcp_project_id }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_credentials_file }}"
    state: present

- name: create a cluster2
  google.cloud.gcp_container_cluster:
    name: my-cluster2
    initial_node_count: 2
    node_config:
      machine_type: n1-standard-4
      disk_size_gb: 500
    location: us-central1-a
    project: "{{ gcp_project_id }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_credentials_file }}"
    state: present
    logging_service: none

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: "{{ gcp_project_id }}"
    auth_kind: serviceaccount
    service_account_file: "{{ gcp_credentials_file }}"
    state: present
    logging_service: logging.googleapis.com/kubernetes

References