Â
https://cloud.google.com/compute/docs/labeling-resources?hl=ja
ã©ãã«ã¨ã¿ã°
ã©ãã«ã¯ããªã½ã¼ã¹ã«å¯¾ããã¯ã¨ãªå¯è½ãªã¢ããã¼ã·ã§ã³ã¨ãã¦ä½¿ç¨ã§ãã¾ãããããªã·ã¼ã®æ¡ä»¶ã®è¨å®ã«ã¯ä½¿ç¨ã§ãã¾ããã
ã¿ã°ã使ç¨ããã¨ãããªã·ã¼ãããç´°ããå¶å¾¡ãããã¨ã«ãã£ã¦ã
ãªã½ã¼ã¹ã«ç¹å®ã®ã¿ã°ãä»å ããã¦ãããã©ããã«åºã¥ãã¦ãæ¡ä»¶ä»ãã§ããªã·ã¼ã許å¯ã¾ãã¯æå¦ãããã¨ãå¯è½ã«ãªãã¾ãã
Â
VM ã©ãã«ã¨ãããã¯ã¼ã¯ ã¿ã°ã®é¢ä¿
以åã¯ãã©ãã«ã¨ã¿ã°ãé¢é£ãã¦ãã¾ããã
ãã¨ãã°ãwebserver:test ã©ãã«ã VM ã«è¿½å ããã¨ãCompute Engine ããã® VM ã« webserver ã¿ã°ãèªåçã«è¿½å ãã¦ãã¾ããã
ç¾å¨ãã©ãã«ã¨ã¿ã°ã¯äºãã«ç¬ç«ãã¦ãã¾ããVM ã«ã©ãã«ãä½æãã¦ããCompute Engine 㯠VM ã®ã¿ã°ãä½æãã¾ããã
VM ã«ã¿ã°ãä½æããå¿
è¦ãããå ´åã¯ãæåã§ä½æããå¿
è¦ãããã¾ãã
Â
-- 1. åä½æ¥
gcloud init
gcloud auth list
gcloud --version
gcloud projects create project01-9999999 \
--name="project01"
gcloud config list
gcloud config set project project01-9999999
gcloud config set compute/region asia-northeast1 --quiet
gcloud config set compute/zone asia-northeast1-a --quiet
Â
gcloud beta billing accounts list
gcloud beta billing projects link project01-9999999 --billing-account=111111-111111-111111
gcloud services enable compute.googleapis.com --project project01-9999999
-- 2. ã©ãã«ãé©ç¨ãããªã½ã¼ã¹ãä½æãã
Â
gcloud compute instances create vm01 \
--machine-type=e2-micro \
--image-project=centos-cloud \
--image=centos-7-v20221004 \
--network-interface=network-tier=STANDARD \
--labels key1=val1,key2=val2
gcloud compute instances list
Â
-- 3. æ¢åã®ãªã½ã¼ã¹ã¸ã®ã©ãã«ã®è¿½å ãæ´æ°
gcloud compute instances update vm01 \
--update-labels key1=val11,key3=val3Â
Â
-- 4. ã©ãã«ã表示ãã
gcloud compute instances describe vm01
-- 5. ã©ãã«ãåé¤ãã
gcloud compute instances update vm01 \
--remove-labels key2,key3Â
Â
-- 6. ã¯ãªã¼ã³ã¢ãã
gcloud compute instances delete vm01 --quiet
gcloud projects list
gcloud projects delete project01-9999999 -q
gcloud beta billing projects unlink project01-9999999
Â
Â
Â