使用 gcloud CLI 创建用户集群的示例

本页面提供使用 gcloud container bare-metal clusters create 命令创建 GKE on Bare Metal 用户集群的示例。创建用户集群后,您至少需要创建一个节点池。您可以使用 gcloud container bare-metal node-pools create 命令创建节点池。 命令使用的大多数设置都与集群和节点池配置文件中的字段相对应。

如需了解标志的说明,请参阅以下内容:

创建集群的示例

MetalLB

gcloud container bare-metal clusters create user-cluster-1 \
  --project=example-project-12345 \
  --location=europe-west1 \
  --admin-cluster-membership=projects/example-project-12345/locations/global/memberships/admin-cluster-1 \
  --version=1.15.11 \
  --admin-users=sara@example.com \
  --admin-users=amal@example.com \
  --island-mode-service-address-cidr-blocks=10.96.0.0/20 \
  --island-mode-pod-address-cidr-blocks=192.168.0.0/16 \
  --metal-lb-address-pools='pool=pool1,avoid-buggy-ips=True,manual-assign=True,addresses=10.251.134.80/32;10.251.133.0/24;10.251.131.70-10.251.131.74' \
  --control-plane-node-configs='node-ip=10.200.0.10' \
  --control-plane-node-configs='node-ip=10.200.0.11,labels=key2.1=value2.1' \
  --control-plane-node-configs='node-ip=10.200.0.12,labels=key3.1=value3.1;key3.2=value3.2' \
  --control-plane-node-labels=cp-node-pool-key=cp-node-pool-value \
  --control-plane-node-taints=dedicated=experimental:PreferNoSchedule \
  --control-plane-vip=172.16.20.61 \
  --control-plane-load-balancer-port=443 \
  --ingress-vip=10.251.134.80 \
  --lvp-share-path=/mnt/localpv-share \
  --lvp-share-storage-class=local-shared \
  --lvp-node-mounts-config-path=/mnt/localpv-disk \
  --lvp-node-mounts-config-storage-class=local-disks

(可选)如果您需要在工作器节点池的专用池中运行负载均衡器,则可以添加 --metal-lb-load-balancer-node-configs 标志。如需了解详情,请参阅 MetalLB 节点

手动负载均衡器

gcloud container bare-metal clusters create user-cluster-2 \
  --project=example-project-12345 \
  --location=europe-west1 \
  --admin-cluster-membership=projects/example-project-12345/locations/global/memberships/admin-cluster-1 \
  --version=1.15.11 \
  --admin-users=sara@example.com \
  --admin-users=amal@example.com \
  --island-mode-service-address-cidr-blocks=10.96.0.0/20 \
  --island-mode-pod-address-cidr-blocks=192.168.0.0/16 \
  --enable-manual-lb \
  --control-plane-node-configs='node-ip=10.200.0.10' \
  --control-plane-node-configs='node-ip=10.200.0.11,labels=key2.1=value2.1' \
  --control-plane-node-configs='node-ip=10.200.0.12,labels=key3.1=value3.1;key3.2=value3.2' \
  --control-plane-node-labels=cp-node-pool-key=cp-node-pool-value \
  --control-plane-node-taints=dedicated=experimental:PreferNoSchedule \
  --control-plane-vip=172.16.20.61 \
  --control-plane-load-balancer-port=443 \
  --ingress-vip=10.251.134.80 \
  --lvp-share-path=/mnt/localpv-share \
  --lvp-share-storage-class=local-shared \
  --lvp-node-mounts-config-path=/mnt/localpv-disk \
  --lvp-node-mounts-config-storage-class=local-disks

创建节点池

创建集群后,您可以使用 gcloud container bare-metal node-pools create 命令创建节点池:

gcloud container bare-metal node-pools create default-pool \
    --cluster=user-cluster-1  \
    --project=example-project-12345 \
    --location=us-west1 \
    --node-configs='node-ip=10.200.0.10' \
    --node-configs='node-ip=10.200.0.11,labels=key2.1=value2.1' \
    --node-labels=node-pool-key=node-pool-value \
    --node-taints=dedicated=experimental:PreferNoSchedule

如需了解标志,请参阅创建节点池

后续步骤