英文:
How can I tell if a GKE autopilot workload is running on a Spot Pod?
问题
我已尝试以下操作,但虽然它列出了显示 cloud.google.com/gke-spot=true 的节点选择器,但没有更具体地描述它是否在 Spot Pod 上运行:
kubectl describe pod/nginx-2-deployment-#########-##### -n my-namespace
英文:
I've tried the following, but though it lists the Node Selectors that show cloud.google.com/gke-spot=true, it doesn't describe anything more explicit about whether it's running on a Spot Pod:
kubectl describe pod/nginx-2-deployment-#########-##### -n my-namespace
答案1
得分: 2
以下是检查自动驾驶工作负载是否在 Spot Pod 上运行的三种可能情况:
-
根据官方文档,如果您在 Pod 规范或清单中的 nodeSelector 或节点亲和性中指定了
cloud.google.com/gke-spot=true
标签,GKE 会自动提供节点来运行仅限于 spot pod 的工作负载。这表示当您请求 Spot Pod 时,Autopilot 会自动提供 Spot VM,添加污点和容忍,并管理自动扩展和调度。当您在部署中使用 nodeSelector 要求 Spot Pod 时,需要在部署中指定
cloud.google.com/gke-spot=true
标签。当您使用 节点亲和性 请求 Spot Pod 时,可以指定要使用的节点亲和性类型,如下:
requiredDuringSchedulingIgnoredDuringExecution: 必须使用 Spot Pod
。preferredDuringSchedulingIgnoredDuringExecution: 尽力使用 Spot Pod
。
通过使用
**kubectl describe pod POD_NAME
** 来检查清单。如果在部署中检查到此标签,则表示工作负载仅在 spotpod 上运行。 -
您还可以使用此 matchselector 来交叉检查 nodeselector 标签
> 为了验证这一点,请检查 Pod 规范的 nodeSelector 字段下的指定标签。
> 要查看集群中的节点是如何标记的,请运行以下命令:
>
kubectl get nodes --show-labels
> 要为节点附加标签,请运行以下命令:
>
kubectl label nodes NODE_NAME LABEL_KEY=LABEL_VALUE
> 替换以下内容:
> NODE_NAME:所需节点。
> LABEL_KEY:标签的键。
> LABEL_VALUE:标签的值。
-
或者,通过使用此 文档,您可以验证集群是否以自动驾驶模式运行。在 GKE 自动驾驶集群中,Spot Pod 是在由 Compute Engine Spot VM 支持的节点上运行的 Pod。
> 要验证您的集群是否以自动驾驶模式创建,请运行以下命令:
>
gcloud container clusters describe <CLUSTER_NAME> --region <REGION>
输出包含以下内容:
autopilot: enabled: true
英文:
Below are the 3 possible scenarios to check the autopilot workload is running on Spot Pod :
- As per this official doc, if you Specify
cloud.google.com/gke-spot=true
label in a nodeSelector or node
affinity in your Pod specification or manifest then GKE
automatically provisions nodes to run on spot pods only. This
indicates that When you request Spot Pods, Autopilot automatically
provisions Spot VMs, adds taints and tolerations, and manages
autoscaling and scheduling.
When you use nodeSelector to require Spot Pods in a Deployment. You need to specify the cloud.google.com/gke-spot=true
label to your Deployment.
When you use node affinity to request Spot Pods, you can specify the type of node affinity to use, as follows:
requiredDuringSchedulingIgnoredDuringExecution: Must use Spot Pods
.preferredDuringSchedulingIgnoredDuringExecution: Use Spot Pods on a
.
best-effort basis
Check the manifest by using **kubectl describe pod POD_NAME
** .
When you check the manifest if this label is in deployment then it indicates that the workload is running on spotpod only.
- You can also use this matchselector to cross check the nodeselector labels
> 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.
- Or else By using this doc, you can also verify the cluster is running in autopilot mode. In GKE Autopilot clusters, Spot Pods are Pods that run on nodes backed by Compute Engine Spot VMs.
> 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论