[[GKEクラスタセットアップ]] を最初にやる。
#### 0. k8s バージョンチェック
```shell-session
$ gcloud container get-server-config --flatten="channels" --filter="channels.channel=REGULAR" \ --format="yaml(channels.channel,channels.validVersions)"
Fetching server config for asia-northeast1-a
---
channels:
channel: REGULAR
validVersions:
- 1.20.6-gke.1000
- 1.19.10-gke.1700
- 1.19.10-gke.1600
```
#### 1. GKEクラスタ作成
```shell-session
$ export PROJECT_ID=$(gcloud config list --format 'value(core.project)')
$ gcloud container clusters create sock-shop-01 \
--region asia-northeast1-a \
--release-channel regular \
--cluster-version 1.19.10-gke.1700 \
--image-type=cos \
--machine-type e2-standard-2 \
--workload-pool="$PROJECT_ID.svc.id.goog" \
--num-nodes 3 \
--no-enable-stackdriver-kubernetes
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).
Creating cluster sock-shop-01 in asia-northeast1-a... Cluster is being health-checked (master is healthy)...done.
kubeconfig entry generated for sock-shop-01.
...
```
参考: [単一ゾーンクラスタの作成 | Kubernetes Engine ドキュメント | Google Cloud](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster?hl=ja)
- [[GKEのWorkload Identityの設定]]
#### 2. GKEクラスタ ノードプール作成
```shell-session
$ gcloud container node-pools create control-pool \
--cluster sock-shop-01 \
--machine-type e2-medium \
--image-type=cos \
--num-nodes=1
$ gcloud container node-pools create analytics-pool \
--cluster sock-shop-01 \
--machine-type e2-small \
--image-type=cos \
--num-nodes=1
```
#### 3. Sock Shop環境構築
- [[GKEクラスタセットアップ]]
#### GKEノードのリサイズ
```shell-session
$ gcloud container clusters resize sock-shop-01 --node-pool=control-pool --num-nodes=1
```