google-cloud-platform - 如何判断 GKE Autopilot 工作负载是否正在 Spot Pod 上运行?

标签 google-cloud-platform google-kubernetes-engine kubectl

我已尝试以下操作,但虽然它列出了显示 cloud.google.com/gke-spot=true 的节点选择器,但它没有更明确地描述它是否在 Spot Pod 上运行:

kubectl describe pod/nginx-2-deployment-#########-##### -n my-namespace

最佳答案

以下是检查自动驾驶仪工作负载是否在 Spot Pod 上运行的 3 种可能情况:

  1. 据此 official doc ,如果您指定 cloud.google.com/gke-spot=true节点选择器或节点中的标签 Pod 规范或 list 中的亲和性然后GKE 自动配置节点仅在现场 Pod 上运行。这 表示当您请求 Spot Pod 时,Autopilot 会自动 配置 Spot VM、添加污点和容忍度并管理 自动缩放和调度。

当您使用nodeSelector时在部署中需要 Spot Pod。您需要指定cloud.google.com/gke-spot=true为您的部署添加标签。

当您使用node affinity时要请求 Spot Pod,您可以指定要使用的节点关联类型,如下所示:

  • requiredDuringSchedulingIgnoredDuringExecution: Must use Spot Pods .
  • preferredDuringSchedulingIgnoredDuringExecution: Use Spot Pods on a best-effort basis .

使用 **kubectl describe pod POD_NAME 检查 list ** 。 当您检查 list 时,如果此标签处于部署中,则表明工作负载仅在 Spotpod 上运行。

  • 您还可以使用此 matchselector交叉检查节点选择器标签
  • To verify this, check the labels specified in the Pod specification's nodeSelector field, under spec: nodeSelector.

    To see how nodes in your cluster are labeled, run the following command:

    kubectl get nodes --show-labels

    To attach a label to a node, run the following command:

    kubectl label nodes NODE_NAME LABEL_KEY=LABEL_VALUE

    Replace the following:

    NODE_NAME: the desired node.
    LABEL_KEY: the label's key.

    LABEL_VALUE:the label's value.

  • 或者通过使用这个 doc ,您还可以验证集群是否在自动驾驶模式下运行。在 GKE Autopilot 集群中,Spot Pod 是在 Compute Engine Spot 虚拟机支持的节点上运行的 Pod。
  • To verify that your cluster is created in Autopilot mode, run the following command:

    gcloud container clusters describe <CLUSTER_NAME> --region <REGION>

    The output contains the following: autopilot: enabled: true

    关于google-cloud-platform - 如何判断 GKE Autopilot 工作负载是否正在 Spot Pod 上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76250136/

    相关文章:

    google-cloud-platform - 更新 GCP Composer 和 Airflow 镜像失败

    kubernetes - 如何从一个集群获取 Kubernetes secret 并应用于另一个集群?

    google-app-engine - 在本地连接云实例以作为服务运行的 laravel 项目

    google-cloud-platform - 谷歌容器生成器 : How to cache dependencies between two builds

    docker - 在Docker镜像的kubernetes安装卷中找不到现有的二进制可执行文件

    kubernetes - GKE 集群的权限

    docker - 如何在容器中执行动态代码?

    azure - 如何撤消 kubectl 删除节点

    kubernetes - 使用 kubectl 命令从远程 url 传递 list 文件

    node.js - NW.JS 加载 grpc 二进制模块失败