GKE Node pool does not use a container-optimized OS Affecting Kubernetes (Container) Engine service in Google


Severity

0.0
low
0
10
Severity Framework
Snyk CCSS
Rule category
Containers/ APIs

Is your environment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
Frameworks
CIS-Controls
  • Snyk IDSNYK-CC-00411
  • creditSnyk Research Team

Description

Container-Optimized OS is a secure and speedy operating system image for Compute Engine VMs. Optimize your GKE cluster nodes' security by running them on Container-Optimized OS images.

How to fix?

Set node_config.image_type attribute to a COS based image, or remove attribute.

Example configuration

resource "google_service_account" "default" {
  account_id   = "service-account-id"
  display_name = "Service Account"
}

resource "google_container_cluster" "allowed" {
  name               = "gke-cluster-411-b1"
  location           = "us-east1-b"
  initial_node_count = 1
}

resource "google_container_node_pool" "primary_preemptible_nodes_b" {
  name       = "node-pool-411b1"
  cluster    = google_container_cluster.allowed.id
  node_count = 1

  node_config {
    preemptible  = true
    machine_type = "e2-medium"
    image_type   = "COS_CONTAINERD"

    service_account = google_service_account.default.email
    oauth_scopes    = [
      "https://www.googleapis.com/auth/cloud-platform"
    ]
  }
}