A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/kubernetes-engine/docs/how-to/run-pods-default-compute-classes below:

Apply compute classes to Pods by default | Google Kubernetes Engine (GKE)

Apply compute classes to Pods by default

Stay organized with collections Save and categorize content based on your preferences.

This page shows you how to apply compute classes by default to Google Kubernetes Engine (GKE) Pods that don't explicitly select a compute class. This page has instructions for setting a compute class as the default in a namespace and for an entire cluster. These instructions are intended for cluster administrators who want to reduce manual overhead caused by individual workload and node configuration.

Before reading this page, become familiar with custom compute classes.

About default compute classes

You can configure GKE clusters or specific namespaces to have a default compute class. The default class that you configure applies to any Pod in that cluster or namespace that doesn't select a different compute class. When you deploy a Pod that doesn't select a compute class, GKE applies default compute classes in the following order:

  1. If the namespace has a default compute class, GKE modifies the Pod specification to select that compute class.
  2. If the namespace doesn't have a default compute class, the cluster-level default class applies. GKE doesn't modify the Pod specification.
Before you begin

Before you start, make sure that you have performed the following tasks:

Requirements Required roles and permissions

To get the permissions that you need to configure cluster- or namespace-level default compute classes, ask your administrator to grant you the following IAM roles on the Google Cloud project:

For more information about granting roles, see Manage access to projects, folders, and organizations.

These predefined roles contain the permissions required to configure cluster- or namespace-level default compute classes. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to configure cluster- or namespace-level default compute classes:

You might also be able to get these permissions with custom roles or other predefined roles.

Configure a default compute class for a namespace

You can annotate any Kubernetes namespace in your cluster with the name of a compute class to use as the default. If a Pod that's deployed to that namespace doesn't already select a compute class, GKE modifies the Pod specification to select the default class in the namespace. You can set any custom or built-in compute class as the default.

Update the existing default compute class in a namespace

To overwrite the existing default compute class for a namespace, run one of the following commands:

Configure a default compute class for a cluster

This section shows you how to set a compute class as the default for your cluster. For cluster-level default compute classes, don't manually specify node taints and node labels for existing node pools in the cluster. GKE ignores node pools that have node taints for compute classes during node creation.

Note: In Autopilot clusters, setting a default compute class for the cluster overrides the Autopilot default behavior that places Pods on the container-optimized compute platform.
  1. To enable setting a cluster-level default compute class for a cluster, run the gcloud container clusters update command with the --enable-default-compute-class flag:

    gcloud container clusters update CLUSTER_NAME \
        --location=CONTROL_PLANE_LOCATION \
        --enable-default-compute-class
    

    Replace the following:

    You can also specify this flag when you create an Autopilot or Standard cluster.

  2. Save the following manifest, which defines a ComputeClass named default:

    apiVersion: cloud.google.com/v1
    kind: ComputeClass
    metadata:
      name: default
    spec:
      priorities:
      - machineFamily: n4
      - machineFamily: n2
      whenUnsatisfiable: ScaleUpAnyway
      nodePoolAutoCreation:
        enabled: true
    

    This example manifest requests nodes that use N4 instances. If N4 instances aren't available, the compute class requests N2 instances instead. You can configure the default compute class with any of the available fields in the ComputeClass CustomResourceDefinition.

  3. Apply the manifest to your cluster:

    kubectl apply -f PATH_TO_MANIFEST
    

    Replace PATH_TO_MANIFEST with the path to the manifest for the compute class.

After you set a cluster-level default compute class, Autopilot clusters no longer use the general-purpose Autopilot compute platform for Pods that don't request a compute class.

Verify the default compute class behavior

To check whether the default compute class that you set for a namespace or for a cluster works as expected, do the following:

  1. Review the following example Deployment:

    This Deployment doesn't explicitly request a compute class.

  2. Create the Deployment:

    kubectl apply --namespace=NAMESPACE_NAME \
        -f https://raw.githubusercontent.com/GoogleCloudPlatform/kubernetes-engine-samples/refs/heads/main/quickstarts/hello-app/manifests/helloweb-deployment.yaml
    

    Replace NAMESPACE_NAME with one of the following, depending on what you want to verify:

    GKE might take some time to create new nodes to run the Pods.

  3. Identify the nodes that run the Pods from the example Deployment:

    kubectl get pods --namespace=NAMESPACE_NAME \
        --selector=app=hello -o=wide
    

    The output is similar to the following:

    NAME                        READY   STATUS    RESTARTS   AGE     IP          NODE                                                  NOMINATED NODE   READINESS GATES
    helloweb-7795fbf856-58n5l   1/1     Running   0          9m21s   10.52.2.3   gke-cluster-1-nap-n2-highcpu-2-3muqi8-f213e529-rx7d   <none>           <none>
    
  4. Get the node labels:

    kubectl get node NODE_NAME --show-labels \
        | grep "cloud.google.com/compute-class"
    

    Replace NODE_NAME with the name of the node from the output of the previous step.

    The output is similar to the following:

    NODE_NAME   Ready    <none>   22m   v1.32.4-gke.1236007
    # lines are omitted from this output
    cloud.google.com/compute-class=COMPUTECLASS_NAME,cloud.google.com/gke-boot-disk=pd-balanced,cloud.google.com/gke-container-runtime=containerd
    

    The value in COMPUTECLASS_NAME is one of the following:

Disable the default compute class

To disable the default compute class in a namespace or a cluster, do one of the following:

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-12 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-12 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4