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