0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GCP Terminalで繰り返し使うコマンドや資料をメモ

Last updated at Posted at 2022-06-01

Common

Machine Typeの選択

GCPinstances.info

Project, Region, Zoneを設定

環境変数を設定

export PROJECT_ID=<value>

環境変数を設定

gcloud config set project $PROJECT_ID
gcloud config set container/cluster cluster-1
gcloud config set compute/zone us-central1-c

Kubernetes Engine

GKEクラスターを作成

環境変数を設定

export CLUSTER_NAME=<value>
export MACHINE_TYPE=<value>

クラスターを作成

gcloud services enable container
gcloud container clusters create $CLUSTER_NAME --cluster-version latest --machine-type=$MACHINE_TYPE --num-nodes=3
gcloud container clusters get-credentials $CLUSTER_NAME
kubectl config current-context

GKEクラスターのノードプールを操作

環境変数を設定

export CLUSTER_NAME=<value>
export MACHINE_TYPE=<value>

ノードプールを追加

gcloud container node-pools create new-pool --cluster=$CLUSTER_NAME --machine-type=$MACHINE_TYPE --num-nodes=3

ノード数を変更

gcloud container clusters resize $CLUSTER_NAME --node-pool default-pool --num-nodes 4

Cloud Run

コンテナイメージをデプロイ

docker pull wordpress
docker tag wordpress gcr.io/$PROJECT_ID/wordpress
docker push gcr.io/$PROJECT_ID/wordpress
gcloud run deploy wordpress --region us-central1 --platform managed --image gcr.io/$PROJECT_ID/wordpress --port 80

Cloud Runで実行中のサービス一覧を表示

gcloud run services list
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?