Created
September 10, 2020 07:23
-
-
Save ashutoshpipriye/e609e00ca889c4be8c1aa4bee57906f4 to your computer and use it in GitHub Desktop.
Getting Started: Create and Manage Cloud Resources: Challenge Lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task 1: Create a project jumphost instance | |
Make sure you: | |
name the instance -- nucleus-jumphost | |
use the machine type -- f1-micro | |
use the default image type (Debian Linux) | |
Navigation menu > Compute engine > VM Instance | |
Name for the VM instance : nucleus-jumphost | |
Region : leave Default Region | |
Zone : leave Default Zone | |
Machine Type : f1-micro (Series - N1) | |
Boot Disk : use the default image type (Debian Linux) | |
Create. | |
Click Check my progress to verify the objective. | |
Task 2: Create a Kubernetes service cluster | |
The team is building an application that will use a service. This service will run on Kubernetes. | |
You need to: | |
Create a cluster (in the us-east1 region) to host the service | |
Use the Docker container hello-app (`gcr.io/google-samples/hello-app:2.0`) as a place holder, the team will replace the container with their own work later | |
Expose the app on port 8080 | |
Activate Cloud Shell ---- | |
Paste this cmd step by step | |
gcloud config set compute/zone us-east1-b | |
gcloud container clusters create nucleus-webserver1 | |
gcloud container clusters get-credentials nucleus-webserver1 | |
kubectl create deployment hello-app --image=gcr.io/google-samples/hello-app:2.0 | |
kubectl expose deployment hello-app --type=LoadBalancer --port 8080 | |
kubectl get service | |
Task 3: Setup an HTTP load balancer | |
We will serve the site via nginx web servers, but we want to ensure we have a fault tolerant environment, | |
so please create an HTTP load balancer with a managed instance group of two nginx web servers. | |
Use the following to configure the web servers, the team will replace this with their own configuration later. | |
You need to: | |
Create an instance template | |
Create a target pool | |
Create a managed instance group | |
Create a firewall rule to allow traffic (80/tcp) | |
Create a health check | |
Create a backend service and attach the manged instance group | |
Create a URL map and target HTTP proxy to route requests to your URL map | |
Create a forwarding rule | |
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 | |
1 .Create an instance template : | |
gcloud compute instance-templates create nginx-template \ | |
--metadata-from-file startup-script=startup.sh | |
2 .Create a target pool : | |
gcloud compute target-pools create nginx-pool | |
3 .Create a managed instance group : | |
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 | |
4 .Create a firewall rule to allow traffic (80/tcp) : | |
gcloud compute firewall-rules create www-firewall --allow tcp:80 | |
gcloud compute forwarding-rules create nginx-lb \ | |
--region us-east1 \ | |
--ports=80 \ | |
--target-pool nginx-pool | |
gcloud compute forwarding-rules list | |
5 .Create a health check : | |
gcloud compute http-health-checks create http-basic-check | |
gcloud compute instance-groups managed \ | |
set-named-ports nginx-group \ | |
--named-ports http:80 | |
6 .Create a backend service and attach the manged instance group : | |
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 | |
7 .Create a URL map and target HTTP proxy to route requests to your URL map : | |
gcloud compute url-maps create web-map \ | |
--default-service nginx-backend | |
gcloud compute target-http-proxies create http-lb-proxy \ | |
--url-map web-map | |
8 .Create a forwarding rule : | |
gcloud compute forwarding-rules create http-content-rule \ | |
--global \ | |
--target-http-proxy http-lb-proxy \ | |
--ports 80 | |
gcloud compute forwarding-rules list |
- the first step is to create load balancer
gcloud compute instance-templates create lb-backend-template \ --region=us-east1 \ --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'
yup , I know what was the problem
it was with the name
grant-tcp-rule-985
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can You please explain why we need target pool here?Is it because they have asked or is there any specific reason?