Arcade Trail: Containers & Load Balancing | GSP021

Solution for Arcade Trail: Containers & Load Balancing | GSP021. 1 lab: GSP021. Fast copy-paste commands for Google Cloud.

GSP021 — Orchestrating the Cloud with Kubernetes

Estimated time: 25 minutes

# 🚀 Orchestrating the Cloud with Kubernetes | GSP021 > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide helps learners understand Kubernetes orchestration, deploy containerized applications, configure networking, and manage microservices using Google Kubernetes Engine (GKE). Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Terms o

clear
ORANGE=


\033[38;5;208m'
CYAN=


\033[0;36m'
GREEN=


\033[0;32m'
YELLOW=


\033[0;33m'
MAGENTA=


\033[0;35m'
BOLD=


\033[1m'
RESET=


\033[0m'

echo "${ORANGE}${BOLD}   ____        _   _ _            __   ___              ${RESET}"
echo "${ORANGE}${BOLD}  / __ \      | | (_) |          / _| / _ \             ${RESET}"
echo "${ORANGE}${BOLD} | |  | |_ __| |__  _| |_  ___   | |_ | | | |_ __ ___  ${RESET}"
echo "${ORANGE}${BOLD} | |  | | '__| '_ \| | __| / _ \ |  _|| | | | '_ \ / __| ${RESET}"
echo "${ORANGE}${BOLD} | |__| | |  | |_) | | |_ | (_) || |  | |_| | |_) \__ \ ${RESET}"
echo "${ORANGE}${BOLD}  \____/|_|  |_.__/|_|\__| \___/ |_|   \___/| .__/|___/ ${RESET}"
echo "${ORANGE}${BOLD}                                            | |         ${RESET}"
echo "${ORANGE}${BOLD}                                            |_|         ${RESET}"
echo ""
echo "${MAGENTA}${BOLD}==========================================================${RESET}"
echo "${MAGENTA}${BOLD} STAGE 1: Cluster Setup & Code Retrieval                  ${RESET}"
echo "${MAGENTA}${BOLD}==========================================================${RESET}"

echo "${YELLOW}▶ Detecting compute zone...${RESET}"
export ZONE=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-zone])")
gcloud config set compute/zone $ZONE --quiet

echo "${YELLOW}▶ Creating Kubernetes Cluster 'io' (This will take ~3-5 minutes)...${RESET}"
gcloud container clusters create io --zone $ZONE --quiet 2>/dev/null || true
gcloud container clusters get-credentials io --zone $ZONE --quiet

echo "${YELLOW}▶ Copying source code (using gsutil)...${RESET}"
gsutil cp -r gs://spls/gsp021/* .
cd orchestrate-with-kubernetes/kubernetes

echo "${YELLOW}▶ Deploying Nginx 1.27.0...${RESET}"
kubectl create deployment nginx --image=nginx:1.27.0 2>/dev/null || true
kubectl expose deployment nginx --port 80 --type LoadBalancer 2>/dev/null || true

echo "${GREEN}${BOLD}✓ Stage 1 Complete. Wait ~45 seconds, then click 'Check my progress' for Task 2.${RESET}"
ORANGE=


\033[38;5;208m'
CYAN=


\033[0;36m'
GREEN=


\033[0;32m'
YELLOW=


\033[0;33m'
MAGENTA=


\033[0;35m'
BOLD=


\033[1m'
RESET=


\033[0m'

echo "${MAGENTA}${BOLD}==========================================================${RESET}"
echo "${MAGENTA}${BOLD} STAGE 2: Pods, Secrets, and Services                     ${RESET}"
echo "${MAGENTA}${BOLD}==========================================================${RESET}"

cd ~/orchestrate-with-kubernetes/kubernetes

echo "${YELLOW}▶ Creating fortune-app Pod...${RESET}"
kubectl create -f pods/fortune-app.yaml

echo "${YELLOW}▶ Creating TLS Secrets and Nginx ConfigMap...${RESET}"
kubectl create secret generic tls-certs --from-file tls/
kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf

echo "${YELLOW}▶ Creating secure-fortune Pod and Service...${RESET}"
kubectl create -f pods/secure-fortune.yaml
kubectl create -f services/fortune-app.yaml

echo "${YELLOW}▶ Creating firewall rule for NodePort (31000)...${RESET}"
gcloud compute firewall-rules create allow-fortune-nodeport --allow tcp:31000 --quiet

echo "${GREEN}${BOLD}✓ Stage 2 Complete. You may click 'Check my progress' for Task 7 objectives.${RESET}"
ORANGE=


\033[38;5;208m'
CYAN=


\033[0;36m'
GREEN=


\033[0;32m'
YELLOW=


\033[0;33m'
MAGENTA=


\033[0;35m'
BOLD=


\033[1m'
RESET=


\033[0m'

echo "${MAGENTA}${BOLD}==========================================================${RESET}"
echo "${MAGENTA}${BOLD} STAGE 3: Labels and Microservice Deployments             ${RESET}"
echo "${MAGENTA}${BOLD}==========================================================${RESET}"

cd ~/orchestrate-with-kubernetes/kubernetes

echo "${YELLOW}▶ Adding 'secure=enabled' label to secure-fortune Pod...${RESET}"
kubectl label pods secure-fortune 'secure=enabled'

echo "${YELLOW}▶ Creating Auth Deployment and Service...${RESET}"
kubectl create -f deployments/auth.yaml
kubectl create -f services/auth.yaml

echo "${YELLOW}▶ Creating Fortune Deployment and Service...${RESET}"
kubectl create -f deployments/fortune-service.yaml
kubectl create -f services/fortune-service.yaml

echo "${YELLOW}▶ Creating Frontend ConfigMap, Deployment, and Service...${RESET}"
kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
kubectl create -f deployments/frontend.yaml
kubectl create -f services/frontend.yaml

echo "${GREEN}${BOLD}✓ Stage 3 Complete!${RESET}"
echo "${ORANGE}${BOLD}Wait ~45 seconds for Kubernetes to provision the final Load Balancers, then check your progress for Tasks 8 and 10.${RESET}"
echo "${MAGENTA}${BOLD}==========================================================${RESET}"