gcloud auth list
-=> List the active account namegcloud config list project
-=> List project idsudo su -
-=> In the SSH terminal, to get root accessapt-get update
-=> Update your OSapt-get install nginx -y
-=> Install NGINXps auwx | grep nginx
-=> Confirm that NGINX is runninggcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone us-central1-f
-=> To create a new virtual machine instance from the command linegcloud compute instances create --help
-=> To see all the defaults, Press ENTER or the spacebar to scroll through the help content. To exit the content, type Qexit
-=> After connecting, disconnect from SSH by exiting from the remote shellgcloud init --console-only
-=> To use console based login instead of web browsergcloud config set compute/region us-central1
-=> Set the region to us-central1gcloud config get-value compute/region
-=> To view the project region settinggcloud config set compute/zone us-central1-b
-=> Set the zone to us-central1-bgcloud config get-value compute/zone
-=> To view the project zone settinggcloud config get-value project
-=> To view the project id for your projectgcloud compute project-info describe --project $(gcloud config get-value project)
-=> To view details about the projectexport PROJECT_ID=$(gcloud config get-value project)
-=> Create an environment variable to store your Project IDexport ZONE=$(gcloud config get-value compute/zone)
-=> Create an environment variable to store your Zoneecho -e "PROJECT ID: $PROJECT_ID\nZONE: $ZONE"
-=> To verify that your variables were set properlygcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone $ZONE
-=> To create your VMgcloud -h
-=> The gcloud tool offers simple usage guidelines that are available by adding the -h flag (for help) onto the end of any gcloud commandgcloud config --help
-=> You can access more verbose help by appending the --help flag onto a command or running the gcloud help commandgcloud help config
-=> Equivalent to gcloud config --help
gcloud config list
-=> View the list of configurations in your environmentgcloud config list --all
-=> To see all properties and their settingsgcloud components list
-=> List your componentsgcloud compute instances list
-=> List the compute instance available in the projectgcloud compute instances list --filter="name=('gcelab2')"
-=> List the gcelab2 virtual machinegcloud compute firewall-rules list
-=> List the Firewall rules in the projectgcloud compute firewall-rules list --filter="NETWORK:'default' AND ALLOW:'icmp'"
-=> List the Firewall rules for the default network where the allow rule matches an ICMP rulegcloud compute ssh gcelab2 --zone $ZONE
-=> To connect to your VM with SSHexit
gcloud compute firewall-rules list
gcloud compute instances add-tags gcelab2 --tags http-server,https-server
-=> Add a tag to the virtual machinegcloud compute firewall-rules create default-allow-http --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:80 --source-ranges=0.0.0.0/0 --target-tags=http-server
-=> Update the firewall rule to allowgcloud compute firewall-rules list --filter=ALLOW:'80'
-=> List the firewall rules for the projectcurl http://$(gcloud compute instances list --filter=name:gcelab2 --format='value(EXTERNAL_IP)')
-=> Verify communication is possible for http to the virtual machinegcloud logging logs list
-=> View the available logs on the systemgcloud logging logs list --filter="compute"
-=> View the logs that relate to compute resourcesgcloud logging read "resource.type=gce_instance" --limit 5
-=> Read the logs related to the resource type of gce_instancegcloud logging read "resource.type=gce_instance AND labels.instance_name='gcelab2'" --limit 5
-=> Read the logs for a specific virtual machinegcloud config set compute/zone us-central1-a
-=> To set your default compute zonegcloud container clusters create [CLUSTER-NAME]
-=> To create a clustergcloud container clusters get-credentials [CLUSTER-NAME]
-=> To authenticate the clusterkubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0
-=> To create a new Deployment hello-server from the hello-app container imagekubectl expose deployment hello-server --type=LoadBalancer --port 8080
-=> To create a Kubernetes Service, which is a Kubernetes resource that lets you expose your application to external traffickubectl get service
-=> To inspect the hello-server Servicehttp://[EXTERNAL-IP]:8080
-=> To view the application from your web browsergcloud container clusters delete [CLUSTER-NAME]
-=> To delete the clustergcloud config set compute/zone us-central1-a
-=> Set the default zonegcloud config set compute/region us-central1
-=> Set the default region gcloud compute instances create www1 \
--image-family debian-9 \
--image-project debian-cloud \
--zone us-central1-a \
--tags network-lb-tag \
--metadata startup-script="#! /bin/bash
sudo apt-get update
sudo apt-get install apache2 -y
sudo service apache2 restart
echo '<!doctype html><html><body><h1>www1</h1></body></html>' | tee /var/www/html/index.html"
gcloud compute firewall-rules create www-firewall-network-lb \
--target-tags network-lb-tag --allow tcp:80
gcloud compute instances list
-=> Run the following to list your instances. You'll see their IP addresses in the EXTERNAL_IP columncurl http://[IP_ADDRESS]
-=> Verify that each instance is running gcloud compute addresses create network-lb-ip-1 \
--region us-central1
gcloud compute http-health-checks create basic-check
-=> Add a legacy HTTP health check resource gcloud compute target-pools create www-pool \
--region us-central1 --http-health-check basic-check
gcloud compute target-pools add-instances www-pool \
--instances www1,www2,www3
gcloud compute forwarding-rules create www-rule \
--region us-central1 \
--ports 80 \
--address network-lb-ip-1 \
--target-pool www-pool
gcloud compute forwarding-rules describe www-rule --region us-central1
-=> To view the external IP address of the www-rule forwarding rule used by the load balancerwhile true; do curl -m1 IP_ADDRESS; done
-=> To access the external IP address gcloud compute instance-templates create lb-backend-template \
--region=us-central1 \
--network=default \
--subnet=default \
--tags=allow-health-check \
--image-family=debian-9 \
--image-project=debian-cloud \
--metadata=startup-script='#! /bin/bash
apt-get update
apt-get install apache2 -y
a2ensite default-ssl
a2enmod ssl
vm_hostname="$(curl -H "Metadata-Flavor:Google" \
http://169.254.169.254/computeMetadata/v1/instance/name)"
echo "Page served from: $vm_hostname" | \
tee /var/www/html/index.html
systemctl restart apache2'
gcloud compute instance-groups managed create lb-backend-group \
--template=lb-backend-template --size=2 --zone=us-central1-a
gcloud compute firewall-rules create fw-allow-health-check \
--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 addresses create lb-ipv4-1 \
--ip-version=IPV4 \
--global
gcloud compute health-checks create http http-basic-check \
--port 80
gcloud compute backend-services create web-backend-service \
--protocol=HTTP \
--port-name=http \
--health-checks=http-basic-check \
--global
gcloud compute backend-services add-backend web-backend-service \
--instance-group=lb-backend-group \
--instance-group-zone=us-central1-a \
--global
gcloud compute url-maps create web-map-http \
--default-service web-backend-service
gcloud compute target-http-proxies create http-lb-proxy \
--url-map web-map-http
gcloud compute forwarding-rules create http-content-rule \
--address=lb-ipv4-1\
--global \
--target-http-proxy=http-lb-proxy \
--ports=80