2020-05-16 Challenge Lab

2020-05-16  本文已影响0人  鸭鸭学语言
 gcloud config list project
 gcloud compute project-info describe --project qwiklabs-gcp-01-fde89cd6fa5b | grep default
   - key: google-compute-default-zone
    value: us-east1-b
  - key: google-compute-default-region
    value: us-east1

task 1:

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

task 2: 这里的service的名字 必须是nucleus-xxx 坑了一下

  gcloud config set compute/region us-east1
  gcloud container clusters create josie-thomas-cluster  --zone us-east1-b
  gcloud container clusters get-credentials josie-thomas-cluster
  kubectl create deployment nucleus-app --image=gcr.io/google-samples/hello-app:2.0  
  kubectl expose deployment nucleus-app --type=LoadBalancer --port=8080

task 3:我这个instance-template的start-script好像没运行起来。最后进到俩instance里手装的nginx -_-||

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 start-script=startup.sh
 gcloud compute target-pools create nginx-pool
 gcloud compute instance-groups managed create nginx-group --base-instance-name nginx --size 2 --template nginx-template --target-pool nginx-pool
 gcloud compute instances list
 gcloud compute firewall-rules create www-firewall --allow tcp:80
 
 gcloud compute http-health-checks create http-basic-check
 gcloud compute instance-groups managed set-named-ports nginx-group --named-ports http:80
 
 gcloud compute backend-services create nginx-backend --protocol HTTP --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 --global --target-http-proxy http-lb-proxy --ports 80
上一篇下一篇

猜你喜欢

热点阅读