1 简介
GKE(Google Kubernetes Engine)是一个K8s平台, 我们可以使用gcloud
来创建GKE集群。在开始之前,可以查看:《初始化一个GCP项目并用gcloud访问操作》。
2 创建GKE集群
2.1 打开API
在创建集群之前,需要打开Google API,不然无法操作:
$ gcloud services enable compute.googleapis.com
$ gcloud services enable container.googleapis.com
2.2 创建
K8s集群的节点机器类型多种多样,可以查看一下某个区都有哪些机器类型:
$ gcloud compute machine-types list | grep us-west
这里我选择一个便宜的:n1-standard-1。
使用 gcloud container clusters create
来创建:
$ gcloud container clusters create pkslow-k8s \
--zone us-west1-a \
--cluster-version 1.20.10-gke.1600 \
--machine-type n1-standard-1
WARNING: Currently VPC-native is not the default mode during cluster creation. In the future, this will become the default mode and can be disabled using `--no-enable-ip-alias` flag. Use `--[no-]enable-ip-alias` flag to suppress this warning.
WARNING: Starting with version 1.18, clusters will have shielded GKE nodes by default.
WARNING: Your Pod address range (`--cluster-ipv4-cidr`) can accommodate at most 1008 node(s).
WARNING: Starting with version 1.19, newly created clusters and node-pools will have COS_CONTAINERD as the default node image when no image type is specified.
Creating cluster pkslow-k8s in us-west1-a...done.