如需扩展 Managed Service for Apache Spark on GKE 集群,请更新与 Spark 驱动程序或 Spark 执行器角色相关联的节点池的自动扩缩器配置。您可以在创建 GKE 上的 Managed Service for Apache Spark 集群时,指定 GKE 上的 Managed Service for Apache Spark 节点池及其关联的角色。
设置节点池自动扩缩
在创建 Managed Service for Apache Spark on GKE 虚拟集群时,您可以为 Managed Service for Apache Spark on GKE 节点池自动扩缩设置范围。如果未指定,则 Managed Service for Apache Spark on GKE 节点池会使用默认值进行自动扩缩(在 Managed Service for Apache Spark on GKE GA 版本中,默认值设置为最小值 = 1 和最大值 = 10,可能会发生变化)。如需获取特定的节点池自动扩缩最小值和最大值,请在创建 Managed Service for Apache Spark on GKE 虚拟集群时设置它们。
更新节点池自动扩缩
使用以下 GKE gcloud container node-pools update 命令更改 Managed Service for Apache Spark on GKE 节点池的自动扩缩配置。
gcloud container node-pools update NODE_POOL_NAME \ --cluster=GKE_CLUSTER_NAME \ --region=region \ --enable-autoscaling \ --min-nodes=min nodes (must be <= max-nodes) \ --max-nodes=max nodes (must be >= min-nodes) \
Spark 自动扩缩的工作原理
- 提交作业后,驱动程序 Pod 会调度到与 Spark 驱动程序角色关联的节点池上运行。
- 驱动程序 Pod 调用 GKE 调度器来创建执行器 Pod。
- 执行器 Pod 会调度到与 Spark 执行器角色关联的节点池上。
- 如果节点池有足够的 Pod 容量,Pod 会立即开始运行。 如果容量不足,GKE 集群自动扩缩器会将节点池扩容至用户指定的上限,以提供所请求的资源。当节点池容量过多时,GKE 集群自动扩缩器会将节点池缩容至用户指定的限制。