本文档介绍了如何通过提示 Compute Advisor(由 Gemini 提供支持的 AI 赋能界面)来规划和设计集群。如需详细了解在创建 GKE 集群之前或创建时必须配置的组件,请参阅 GKE 概览。
Compute Advisor 可帮助您评估硬件选项、估算部署费用,并查看集群的推荐配置。 为了提供量身定制的建议,Compute Advisor 会评估您的Google Cloud 项目,检查您的配额限制、现有预留、承诺使用折扣 (CUD)、默认区域和可用区以及任何资源位置限制条件。通过使用 Compute Advisor 帮助您进行规划,您可以在创建或修改 GKE 集群之前为工作负载实现最佳配置。
限制
在 Google Cloud 控制台中向 Compute Advisor 提示时,您无法直接创建、修改或删除资源。
准备工作
当您使用 Google Cloud 控制台访问 Google Cloud 服务和 API 时,无需设置身份验证。
所需的角色
如需获得访问和提示 Gemini 所需的权限,请让您的管理员为您授予项目的 Kubernetes Engine Cluster Viewer (roles/container.clusterViewer) IAM 角色。
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
此预定义角色包含访问 Gemini 和向 Gemini 发出提示所需的权限。如需查看所需的确切权限,请展开所需权限部分:
所需权限
如需访问 Gemini 并向其发出提示,您需要具备以下权限:
-
如需查看集群列表,请执行以下操作:
container.clusters.list
在 Google Cloud 控制台中访问 Compute Advisor
如需在 Google Cloud 控制台中访问 Compute Advisor,请完成以下步骤:
在 Google Cloud 控制台中,前往概览页面。
在使用 Compute Advisor 设计基础架构部分中,您可以查看以下内容:
上一个屏幕截图中显示的界面元素如下:
快速操作提示卡片:一组卡片,每张卡片都包含一个示例提示。如果您点击某个卡片, Google Cloud 控制台会自动使用示例提示词填充提示词框。
提示词框:您可以在此字段中输入并提交提示词。如需提交提示,请点击提交提示。
查看过往对话:此功能可让您查看过往对话的详细信息并继续对话,或者在不再需要时删除对话。
对话记录侧边栏:显示近期对话。只有在您开始从概览页面发出提示后,此面板才会显示。您可以通过以下方式与此面板互动:
如要发起新对话,请点击发起新对话。
如需继续最近的对话,请在最近的对话部分中点击相应对话。
如需查看所有对话的列表,请点击查看全部。在我的历史记录页面上,您可以查看过往对话的详细信息并继续对话,也可以删除不再需要的对话。
向 Compute Advisor 提问
提交提示后,Compute Advisor 会开始生成回答。系统会显示一个窗格, Google Cloud 控制台会在该窗格中显示对提示的回答,如以下屏幕截图所示:
根据您的提示,回答窗格包含以下元素:
情境化依据:Compute Advisor 会自动评估您的项目情境,以提供高度量身定制的建议,包括配额限制、现有预留、CUD、默认区域和可用区以及任何资源位置限制。
交互式代码段:Compute Advisor 会生成 gcloud 命令、REST API 方法或 Terraform 资源。您可以复制并粘贴这些代码段,也可以在 Cloud Shell 中运行它们。
可视化画布:Compute Advisor 会将建议整理成结构化表格和对照比较。此视图可帮助您评估产品功能和架构方法。它还提供了适合您应用场景的实现方案。
以下部分概述了撰写提示的最佳实践,以及在创建或修改 GKE 集群之前可以使用的示例提示。
关于提示的最佳实践
为了从 Compute Advisor 获得最准确、最实用的建议,我们建议您按照代码块的方式构建提示。此方法通过使用清晰的参数声明、角色定义、具体说明和明确的输出格式来引导生成式 AI。
向 Compute Advisor 提示时,请考虑以下最佳实践:
专注于设计和规划:我们建议您不要提示 Compute Advisor 排查 GKE 集群错误。如需解决这些错误,请参阅排查 GKE 问题。
指定角色或身份:声明 Compute Advisor 应扮演的目标角色或身份,例如 IT 管理员、AI 研究员或平台工程师。这种方法可以引导生成的建议的语气、深度和专业水平。
提供明确的编号指令:将目标分解为具体的分步问题或任务。此方法可构建 Compute Advisor 的推理过程,并有助于确保 Compute Advisor 满足您的所有要求。
定义特定的输出格式:明确说明您希望如何设置建议的格式,例如分步说明、Markdown 比较表或随时可用的 gcloud 代码块。
利用自动上下文接地:您无需在提示中包含默认区域或可用区、可用配额、CUD 或资源位置限制。Compute Advisor 可以访问您的 Google Cloud 项目中的这些信息。
以迭代方式优化设计:您可以通过发送新提示来修改或扩展 Compute Advisor 生成的回答。例如,您可以让助理将网络建议添加到部署计划中,或修改存储要求,而无需开始新的对话。
示例提示
以下是可用于帮助您设计和优化 GKE 集群的提示示例:
集群拓扑和节点池配置:如需确定工作负载的最佳 GKE 模式、机器类型和节点池配置,请使用如下提示:
Act as a cloud architect. I need to design a GKE cluster topology for a scalable microservices application that requires both GPU nodes for AI inference and CPU nodes for general-purpose APIs. Please provide the following: 1. A comparison of running this workload on GKE Autopilot versus GKE Standard. 2. Recommendations for GKE machine types for the GPU node pool. 3. The optimal autoscaling and auto-provisioning settings. 4. A YAML manifest that configures tolerations for GPU taints, which are required for AI workloads. Format the comparison as a Markdown table, and provide the cluster creation steps as a ready-to-use gcloud CLI command.预配模型和费用优化:如需评估预配模型并优化批处理工作负载的资源利用率,请使用如下提示:
Act as an IT administrator. I need to design a cost-optimized GKE cluster to run large-scale batch processing workloads that are fault-tolerant. Please provide the following: 1. A cost and reliability comparison of using Spot VMs versus standard VMs in GKE node pools. 2. An explanation of how to configure Kueue for queueing training jobs. 3. A warning about the risk of latency for real-time inference when using Spot VMs. 4. A YAML manifest to deploy the workloads onto Spot VM nodes. Format the comparison as a Markdown table, and provide the manifest as a ready-to-use code block.有状态磁盘拓扑:如需为 GKE 上的高可用性数据库寻找优化的永久性存储架构,请使用如下提示:
Act as a storage engineer. I need to design a StatefulSet topology in GKE for a distributed database that relies on Persistent Disks. Please provide the following: 1. A comparison of regional Persistent Disks versus zonal Persistent Disks. 2. An explanation of how the standard-rwo StorageClass prevents deadlocks in zonal Persistent Disks. 3. A YAML manifest that shows how to deploy a stateful workload with the "volumeBindingMode: WaitForFirstConsumer" field. Format the response with Markdown headers, and provide the deployment manifest as a ready-to-use code block.Karpenter 迁移提示:如需规划从 AWS Karpenter 到 GKE 自动扩缩功能的迁移,请使用如下提示:
Act as a Kubernetes migration specialist. I am migrating an EKS cluster that uses Karpenter to GKE. Please translate my AWS Karpenter NodePool into a GKE custom ComputeClass. Please provide the following: 1. A summary that maps Karpenter concepts to GKE Node Auto-Provisioning (NAP) and ComputeClasses. 2. A YAML manifest that shows how a ComputeClass provides the same variety of instance types and weighting for Spot VMs as Karpenter. 3. The changes required in the Pod manifest to use the new ComputeClass. Format the mapping as a Markdown table, and provide the GKE manifests as code blocks that are ready to use.