Managing Deployments Using Kubernetes Engine
Solution for Managing Deployments Using Kubernetes Engine. 1 lab: GSP053. Fast copy-paste commands for Google Cloud.
GSP053 — Managing Deployments Using Kubernetes Engine
Estimated time: 25 minutes
# 🚀 Managing Deployments Using Kubernetes Engine > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created to help you understand why each step works. Attempt the lab yourself first and use this guide as a learning aid rather than as a shortcut to skip the underlying concepts. This guide is intended for educational purposes, hands-on practice, and Google Cloud certification preparation. It is not affiliated with, endorsed by, or officially supported by Google, Google Clou
# ==============================================================================
# Color Variables & Branding
# ==============================================================================
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
MAGENTA='\e[1;35m'
RED='\e[1;31m'
RESET='\e[0m'
BOLD='\e[1m'
clear
echo -e "${CYAN}${BOLD}"
cat << "EOF"
____ _ _ _ __ ___
/ __ \ | | (_) | / _| / _ \
| | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___
| | | | '__| '_ \| | __| / _ \ | _| | | | | '_ \/ __|
| |__| | | | |_) | | |_ | (_) || | | |_| | |_) \__ \
\____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/
| |
|_|
EOF
echo -e "${RESET}"
echo -e "${MAGENTA}${BOLD}>>> ORBIT OF OPS: GSP053 PART 1 INITIALIZED <<<${RESET}\n"
echo -e "${YELLOW}${BOLD}[Orbit of Ops] Auto-fetching Zone...${RESET}"
export ZONE=$(gcloud compute project-info describe \
--format="value(commonInstanceMetadata.items[google-compute-default-zone])" 2>/dev/null | tail -n 1)
if [[ -z "$ZONE" ]]; then
read -p "⚠️ Could not auto-detect Zone. Please enter the lab Zone (e.g., us-east1-d): " ZONE
export ZONE
fi
gcloud config set compute/zone $ZONE 2>/dev/null
echo -e "✅ Zone: ${GREEN}$ZONE${RESET}\n"
echo -e "${CYAN}${BOLD}[Orbit of Ops] Fetching sample code...${RESET}"
cd ~
gcloud storage cp -r gs://spls/gsp053/kubernetes . || true
cd kubernetes
echo -e "${YELLOW}${BOLD}[Orbit of Ops] Creating Kubernetes Cluster (This will take ~3-5 minutes)...${RESET}"
gcloud container clusters create bootcamp \
--machine-type e2-small \
--num-nodes 3 \
--scopes "https://www.googleapis.com/auth/projecthosting,storage-rw" || true
echo -e "${CYAN}${BOLD}[Orbit of Ops] Tasks 1 & 2: Deploying 'fortune-app-blue' and Service...${RESET}"
kubectl create -f deployments/fortune-app-blue.yaml || true
kubectl create -f services/fortune-app.yaml || true
echo -e "\n${GREEN}${BOLD}✅ Part 1 Complete. Check the first progress button in the lab window!${RESET}"# ==============================================================================
# Color Variables & Branding
# ==============================================================================
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
MAGENTA='\e[1;35m'
RESET='\e[0m'
BOLD='\e[1m'
echo -e "\n${MAGENTA}${BOLD}>>> ORBIT OF OPS: GSP053 PART 2 INITIALIZED <<<${RESET}\n"
# Ensure we are in the correct working directory
cd ~/kubernetes 2>/dev/null || true
echo -e "${YELLOW}${BOLD}[Orbit of Ops] Task 4: Creating Canary Deployment...${RESET}"
kubectl create -f deployments/fortune-app-canary.yaml || true
echo -e "${CYAN}${BOLD}[Orbit of Ops] Task 5: Executing Blue-Green Deployment...${RESET}"
# Update service to point only to blue (version 1.0.0)
kubectl apply -f services/fortune-app-blue-service.yaml || true
# Create the green deployment (version 2.0.0)
kubectl create -f deployments/fortune-app-green.yaml || true
# Update service to point to green
kubectl apply -f services/fortune-app-green-service.yaml || true
echo -e "\n${GREEN}${BOLD}🎉 All blocks executed successfully! You can now verify the final Canary and Blue-Green progress checks in the lab window!${RESET}"