프로그래밍/Docker

[qwiklab] 클라우드 리소스 생성 및 관리 : 챌린지 실습

Hithero 2021. 12. 14. 16:43

실습을 따라하면서 진행했는데도 어려워서 간단하게 적어두었다.

gcloud compute instances create nucleus-jumphost-815 --machine-type f1-micro --zone us-east1-b

gcloud config set compute/zone us-east1-b
gcloud container clusters create nucleus-cluster

gcloud container clusters get-credentials nucleus-cluster

kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:2.0

kubectl expose deployment hello-server --type=LoadBalancer --port 8082

cat << EOF > startup.sh
#! /bin/bash
apt-get update
apt-get install -y nginx
service nginx start
sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.html
EOF

gcloud compute instance-templates create nginx-template \
  --metadata-from-file=startup-script=./startup.sh


gcloud compute target-pools create nginx-pool --region us-east1

gcloud compute instance-groups managed create nginx-group --template=nginx-template --size=2 --zone=us-east1-b --target-pool=nginx-pool

gcloud compute instances list

gcloud compute firewall-rules create grant-tcp-rule-214 \
    --network=default \
    --action=allow \
    --direction=ingress \
    --source-ranges=130.211.0.0/22,35.191.0.0/16 \
    --target-tags=allow-health-check \
    --rules=tcp:80

gcloud compute health-checks create http http-basic-check \
        --port 80

gcloud compute instance-groups managed \
set-named-ports nginx-group \
--named-ports http:80


gcloud compute backend-services create nginx-backend \
    --protocol=HTTP \
    --port-name=http \
    --health-checks=http-basic-check \
    --global
gcloud compute backend-services add-backend nginx-backend \
        --instance-group=nginx-group \
        --instance-group-zone=us-east1-b \
        --global

gcloud compute url-maps create web-map \
    --default-service nginx-backend
gcloud compute target-http-proxies create http-lb-proxy \
    --url-map web-map


gcloud compute forwarding-rules create http-content-rule \
        --address=lb-ipv4-1\
        --global \
        --target-http-proxy=http-lb-proxy \
        --ports=80

 

-- reference

https://cloudvietnam18.wordpress.com/2020/09/13/answer-qwiklabs-getting-started-create-and-manage-cloud-resources-challenge-lab/

https://gist.github.com/Tambunan26/9063521fdf406645aad4527ccd069149

https://buildabetterworld.tistory.com/61

728x90
반응형