在 Google Cloud 上安装

Kubernetes 最初由谷歌开发,用于为其容器引擎供电。因此,Kubernetes 集群是 Google 的一等公民。

在容器引擎中创建 Kubernetes 集群需要来自 Google Cloud SDK 的 gcloud 命令。要在本地安装此命令,请使用以下选项之一:

  • 使用交互式安装程序(对于新手来说最简单的方法):
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init
curl -Lo gcloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-142.0.0-linux-x86_64.tar.gz
tar xvf ./gcloud-sdk.tar.gz
./google-cloud-sdk/install.sh
gcloud init

安装 gcloud 后,创建一个 Kubernetes 集群:

# Give our cluster a name
CLUSTER_NAME=example-cluster

# Number of machines in the cluster.
NUM_NODES=3
    
gcloud container clusters create $CLUSTER_NAME --num_nodes=$NUM_VMS