Facebook
From raf, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 84
  1. Welcome to Cloud Shell! Type "help" to get started.
  2. Your Cloud Platform project in this session is set to qwiklabs-gcp-00-28dd9ddb92e8.
  3. Use “gcloud config set project [PROJECT_ID]” to change to a different project.
  4. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud auth list
  5.            Credentialed Accounts
  6. ACTIVE  ACCOUNT
  7. To set the active account, run:
  8.     $ gcloud config set account `ACCOUNT`
  9. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud config list project
  10. [core]
  11. project = qwiklabs-gcp-00-28dd9ddb92e8
  12. Your active configuration is: [cloudshell-18767]
  13. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud config set compute/zone us-central1-a
  14. Updated property [compute/zone].
  15. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud config set compute/region us-central1
  16. Updated property [compute/region].
  17. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ cat << EOF > startup.sh
  18. > #! /bin/bash
  19. > apt-get update
  20. > apt-get install -y nginx
  21. > service nginx start
  22. > sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.html
  23. > EOF
  24. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud compute instance-templates create nginx-temp
  25. late \
  26. >          --metadata-from-file startup-script=startup.sh
  27. Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-00-28dd9ddb92e8/global/instanceTemplates/nginx-temp
  28. late].
  29. NAME            MACHINE_TYPE   PREEMPTIBLE  CREATION_TIMESTAMP
  30. nginx-template  n1-standard-1               2021-02-23T07:02:07.227-08:00
  31. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud compute target-pools create nginx-pool
  32. Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-00-28dd9ddb92e8/regions/us-central1/targetPools/ngi
  33. nx-pool].
  34. NAME        REGION       SESSION_AFFINITY  BACKUP  HEALTH_CHECKS
  35. nginx-pool  us-central1  NONE
  36. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud compute instance-groups managed create nginx-group \
  37. >          --base-instance-name nginx \
  38. >          --size 2 \
  39. >          --template nginx-template \
  40. >          --target-pool nginx-pool
  41. Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-00-28dd9ddb92e8/zones/us-central1-a/instanceGroupManagers/nginx-group].
  42. NAME         LOCATION       SCOPE  BASE_INSTANCE_NAME  SIZE  TARGET_SIZE  INSTANCE_TEMPLATE  AUTOSCALED
  43. nginx-group  us-central1-a  zone   nginx               0     2            nginx-template     no
  44. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud compute instances list
  45. NAME        ZONE           MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
  46. nginx-h2sl  us-central1-a  n1-standard-1               10.128.0.2   104.197.62.209  RUNNING
  47. nginx-ppx6  us-central1-a  n1-standard-1               10.128.0.3   34.122.69.161   RUNNING
  48. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$ gcloud compute firewall-rules create www-firewall --allow tcp:80
  49. Creating firewall...⠹Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-00-28dd9ddb92e8/global/firewalls/www-firewall].
  50. Creating firewall...done.
  51. NAME          NETWORK  DIRECTION  PRIORITY  ALLOW   DENY  DISABLED
  52. www-firewall  default  INGRESS    1000      tcp:80        False
  53. student_00_4e6900e41e47@cloudshell:~ (qwiklabs-gcp-00-28dd9ddb92e8)$