Skip to content

Instantly share code, notes, and snippets.

@magicdrums
Last active April 4, 2022 15:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicdrums/868fe9b4adca4d4cfecc5e2a9313b7c1 to your computer and use it in GitHub Desktop.
Save magicdrums/868fe9b4adca4d4cfecc5e2a9313b7c1 to your computer and use it in GitHub Desktop.
Qwiklabs - Google Cloud Platform
Tarea 1: Create a project jumphost instance
Run command:
gcloud compute instances create <NOMBRE_INSTANCIA> \
--network nucleus-vpc \
--zone us-east1-b \
--machine-type f1-micro \
--image-family debian-9 \
--image-project debian-cloud \
--scopes cloud-platform \
--no-address
Tarea 2: Create a Kubernetes service cluster
Run command:
gcloud container clusters create <NOMBRE_CLUSTER_K8S> \
--num-nodes 1 \
--network nucleus-vpc \
--region us-east1
gcloud container clusters get-credentials <NOMBRE_CLUSTER_K8S> \
--region us-east1
kubectl create deployment hello-server \
--image=gcr.io/google-samples/hello-app:2.0
kubectl expose deployment hello-server \
--type=LoadBalancer \
--port <PORT>
Tarea 3: Set up an HTTP load balancer
Run command:
#########################################################
# ATENCION AQUI!!! #
# Recomiendo copiar y pegar el que esta en el ejercicio #
#########################################################
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 us-east1
gcloud compute instance-groups managed create web-server-group \
--base-instance-name web-server \
--size 2 \
--template web-server-template \
--region us-east1
gcloud compute firewall-rules create <NOMBRE_RULE_FIREWALL> \
--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 us-east1
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 us-east1 \
--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 list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment