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/node-attributes-compute-classes below:

Control autoscaled node attributes with custom compute classes | Google Kubernetes Engine (GKE)

This page shows you how to control the compute infrastructure and autoscaling behavior of Google Kubernetes Engine (GKE) clusters based on the specific needs of your workloads by using custom compute classes. You should already be familiar with the concept of custom compute classes. For details, see About custom compute classes.

This page is intended for platform administrators who want to declaratively define autoscaling profiles for nodes, and for cluster operators who want to run their workloads on specific compute classes.

About custom compute classes

Custom compute classes are Kubernetes Custom Resources that let you define priorities for GKE to follow when provisioning nodes to run your workloads. You can use a custom compute class to do the following:

To understand all of the configuration options and how they interact with each other and with GKE Autopilot mode and GKE Standard mode, see About custom compute classes.

Pricing

The ComputeClass custom resource is provided at no extra cost in GKE. The following pricing considerations apply:

Before you begin

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

Example scenario for compute classes

This page presents an example scenario for which you define a custom compute class. In practice, you should consider the requirements of your specific workloads and organization, and define compute classes that meet those requirements. For full descriptions of all of the options for compute classes, and for special considerations, see About custom compute classes.

Consider the following example scenario:

Based on the example scenario, you decide that you want a compute class that does the following:

Configure a compute class in Autopilot mode

In GKE Autopilot, you define a compute class, deploy it to the cluster, and request that compute class in your workloads. GKE performs any node configuration steps, like applying labels and taints, for you.

Save the following manifest as compute-class.yaml:

apiVersion: cloud.google.com/v1
kind: ComputeClass
metadata:
  name: cost-optimized
spec:
  priorities:
  - machineFamily: n2
    spot: true
    minCores: 64
  - machineFamily: n2
    spot: true
  - machineFamily: n2
    spot: false
  activeMigration:
    optimizeRulePriority: true
  nodePoolAutoCreation:
    enabled: true
Configure a compute class in Standard mode

In GKE Standard mode clusters, you define a compute class, after which you might have to perform manual configuration to ensure that your compute class Pods schedule as expected. Manual configuration depends on whether your node pools are automatically provisioned, as follows:

Caution: If you use only manually-created node pools in your cluster and you don't associate any node pools with a compute class, Pods that request the compute class remain stuck in the Pending state. Conversely, if you associate every node pool with a specific compute class, Pods that request a different compute class and Pods that don't request a compute class remain stuck in the Pending state. Use compute classes with manually-created node pools

This section shows you how to define a compute class in a cluster that only uses manually-created node pools.

  1. Save the following manifest as compute-class.yaml:

    apiVersion: cloud.google.com/v1
    kind: ComputeClass
    metadata:
      name: cost-optimized
    spec:
      priorities:
      - machineFamily: n2
        spot: true
        minCores: 64
      - machineFamily: n2
        spot: false
      activeMigration:
        optimizeRulePriority: true
    
  2. Create a new autoscaled node pool that uses Spot VMs and associate it with the compute class:

    gcloud container node-pools create cost-optimized-pool \
        --location=LOCATION \
        --cluster=CLUSTER_NAME \
        --machine-type=n2-standard-64 \
        --spot \
        --enable-autoscaling \
        --max-nodes=9 \
        --node-labels="cloud.google.com/compute-class=cost-optimized" \
        --node-taints="cloud.google.com/compute-class=cost-optimized:NoSchedule"
    

    Replace the following:

  3. Create a new autoscaled node pool with on-demand VMs and associate it with the compute class:

    gcloud container node-pools create on-demand-pool \
        --location=LOCATION \
        --cluster=CLUSTER_NAME \
        --machine-type=n2-standard-64 \
        --enable-autoscaling \
        --max-nodes=9 \
        --num-nodes=0 \
        --node-labels="cloud.google.com/compute-class=cost-optimized" \
        --node-taints="cloud.google.com/compute-class=cost-optimized:NoSchedule"
    

When you deploy Pods that request this compute class and new nodes need to be created, GKE prioritizes creating nodes in the cost-optimized-pool node pool. If new nodes can't be created, GKE creates nodes in the on-demand-pool node pool.

For more details about how manually-created node pools interact with custom compute classes, see Configure manually-created node pools for compute class use.

Use compute classes with auto-provisioned node pools

This section shows you how to define a compute class in a cluster that uses node auto-provisioning.

Save the following manifest as compute-class.yaml:

apiVersion: cloud.google.com/v1
kind: ComputeClass
metadata:
  name: cost-optimized
spec:
  priorities:
  - machineFamily: n2
    spot: true
    minCores: 64
  - machineFamily: n2
    spot: true
  - machineFamily: n2
    spot: false
  activeMigration:
    optimizeRulePriority: true
  nodePoolAutoCreation:
    enabled: true

When you deploy Pods that request this compute class and new nodes need to be created, GKE prioritizes creating nodes in the order items in the priorities field. If required, GKE creates new node pools that meet the hardware requirements of the compute class.

For more details about how node auto-provisioning works with custom compute classes, see Node auto-provisioning and compute classes.

Customize autoscaling thresholds for node consolidation

By default, GKE removes underutilized nodes and reschedules your workloads onto other available nodes. You can further customize the thresholds and timing after which a node becomes a candidate for removal by using the autoscalingPolicy field in the compute class definition, like in the following example:

apiVersion: cloud.google.com/v1
kind: ComputeClass
metadata:
  name: cost-optimized
spec:
  priorities:
  - machineFamily: n2
    spot: true
    minCores: 64
  - machineFamily: n2
    spot: true
  - machineFamily: n2
    spot: false
  activeMigration:
    optimizeRulePriority: true
  autoscalingPolicy:
    consolidationDelayMinutes : 5
    consolidationThreshold    : 70

This example makes a node become a candidate for removal if it's underutilized by 70% of its available CPU and memory capacity for more than five minutes. For a list of available parameters, see Set autoscaling parameters for node consolidation.

Deploy a compute class in a cluster

After you define a compute class, deploy it to the cluster:

kubectl apply -f compute-class.yaml

This compute class is ready to use in the cluster. You can request the compute class in Pod specifications or, optionally, set it as the default compute class in a specific namespace.

Request a compute class in a workload

To request a compute class in a workload, add a node selector for that compute class in your manifest.

  1. Save the following manifest as cc-workload.yaml:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: custom-workload
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: custom-workload
      template:
        metadata:
          labels:
            app: custom-workload
        spec:
          nodeSelector:
            cloud.google.com/compute-class: cost-optimized
          containers:
          - name: test
            image: gcr.io/google_containers/pause
            resources:
              requests:
                cpu: 1.5
                memory: "4Gi"
    
  2. Deploy the workload:

    kubectl apply -f cc-workload.yaml
    

When you deploy this workload, GKE automatically adds a toleration to the Pods that corresponds to the node taint for the requested compute class. This toleration ensures that only Pods that request the compute class run on compute class nodes.

Update a deployed compute class

To update a deployed compute class, modify the YAML manifest for the ComputeClass. Then, deploy the modified manifest by running the following command:

kubectl apply -f PATH_TO_FILE

Replace PATH_TO_FILE with the path to your modified manifest. Ensure that the value in the name field remains unchanged.

When you deploy your updated compute class, GKE uses your updated configuration to create new nodes. GKE doesn't modify any existing nodes with your updated configuration.

Over time, GKE might move existing Pods to nodes that use your updated configuration if the compute class uses active migration and if the existing Pods are eligible to migrate.

What's next

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