Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views2 pages

Creating and Managing Resource Challenge Lab

The document outlines the steps to create a Google Cloud infrastructure including a virtual machine instance, a Kubernetes cluster, and a web server deployment. It also includes commands to set up firewall rules, health checks, backend services, and HTTP load balancing. The script automates the installation of Nginx on the created instances and configures the necessary components for a web application deployment.

Uploaded by

anshgarg030404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Creating and Managing Resource Challenge Lab

The document outlines the steps to create a Google Cloud infrastructure including a virtual machine instance, a Kubernetes cluster, and a web server deployment. It also includes commands to set up firewall rules, health checks, backend services, and HTTP load balancing. The script automates the installation of Nginx on the created instances and configures the necessary components for a web application deployment.

Uploaded by

anshgarg030404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

export INSTANCE_NAME=nucleus-jumphost-547

export ZONE=us-west1-c
export REGION=us-west1
export PORT=8080
export FIREWALL_NAME=accept-tcp-rule-175

gcloud compute instances create $INSTANCE_NAME \


--network nucleus-vpc \
--zone $ZONE \
--machine-type e2-micro \
--image-family debian-10 \
--image-project debian-cloud

gcloud container clusters create nucleus-backend \


--num-nodes 1 \
--network nucleus-vpc \
--zone $ZONE

gcloud container clusters get-credentials nucleus-backend \


--zone $ZONE

kubectl create deployment hello-server \


--image=gcr.io/google-samples/hello-app:2.0

kubectl expose deployment hello-server \


--type=LoadBalancer \
--port $PORT

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 web-server-template \


--metadata-from-file startup-script=startup.sh \
--network nucleus-vpc \
--machine-type g1-small \
--region $ZONE

gcloud compute target-pools create nginx-pool --region=$REGION

gcloud compute instance-groups managed create web-server-group \


--base-instance-name web-server \
--size 2 \
--template web-server-template \
--region $REGION
gcloud compute firewall-rules create $FIREWALL_NAME \
--allow tcp:80 \
--network nucleus-vpc

gcloud compute http-health-checks create http-basic-check


gcloud compute instance-groups managed \
set-named-ports web-server-group \
--named-ports http:80 \
--region $REGION

gcloud compute backend-services create web-server-backend \


--protocol HTTP \
--http-health-checks http-basic-check \
--global

gcloud compute backend-services add-backend web-server-backend \


--instance-group web-server-group \
--instance-group-region $REGION \
--global

gcloud compute url-maps create web-server-map \


--default-service web-server-backend

gcloud compute target-http-proxies create http-lb-proxy \


--url-map web-server-map

gcloud compute forwarding-rules create http-content-rule \


--global \
--target-http-proxy http-lb-proxy \
--ports 80

gcloud compute forwarding-rules create $FIREWALL_NAME \


--global \
--target-http-proxy http-lb-proxy \
--ports 80
gcloud compute forwarding-rules list

You might also like