Deploy and Manage Cloud Environments with Google Cloud: Challenge Lab
cd /work/dmsed -i s/SET_REGION/us-east1/g prod-network.yamlgcloud deployment-manager deployments create prod-network --config=prod-network.yamlgcloud config set compute/zone us-east1-bgcloud container clusters create kraken-cluster- \--num-nodes 2 \--network kraken-prod-vpc \--subnetwork kraken-prod-subnet\--zone us-east1-bgcloud container clusters get-credentials kraken-cluster-gcloud config set compute/zone us-east1-bgcloud compute instances create kraken-admin- --network-interface="subnet=kraken-mgmt-subnet" --network-interface="subnet=kraken-prod-subnet"gcloud config set compute/zone us-east1-bgcloud container clusters get-credentials spinnaker-tutorialDECK_POD=$(kubectl get pods --namespace default -l "cluster=spin-deck" -o jsonpath="{.items[0].metadata.name}")kubectl port-forward --namespace default $DECK_POD 8080:9000 >> /dev/null &cd sample-apptouch agit config --global user.email "$(gcloud config get-value account)"git config --global user.name "Student"git commit -a -m "change"git tag v1.0.1git push --tags
Deploy and Manage Cloud Environments with Google Cloud: Challenge Lab
gcloud container clusters create kraken-prod-946 --num-nodes 2 --network kraken-prod-vpc --subnetwork kraken-prod-subnet --zone us-east1-b
gcloud container clusters create kraken-prod-{name} --num-nodes 2 --network kraken-prod-vpc --subnetwork kraken-prod-subnet --zone us-east1-b
cd /work/dmsed -i s/SET_REGION/us-east1/g prod-network.yamlgcloud deployment-manager deployments create prod-network --config=prod-network.yamlgcloud config set compute/zone us-east1-bgcloud container clusters create kraken-prod \--num-nodes 2 \--network kraken-prod-vpc \--subnetwork kraken-prod-subnet\--zone us-east1-bgcloud container clusters get-credentials kraken-prodcd /work/k8sfor F in $(ls *.yaml); do kubectl create -f $F; done
gcloud container clusters create kraken-cluster-172 \ --num-nodes 2 \ --network kraken-prod-vpc \ --subnetwork kraken-prod-subnet\ --zone us-east1-b
gcloud container clusters get-credentials kraken-cluster-172
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUSkraken-cluster-172 us-east1-b 1.21.6-gke.1500 35.231.184.48 e2-medium 1.21.6-gke.1500 2 RUNNING
Task 2 : Setup the Admin instance
gcloud config set compute/zone us-east1-bgcloud compute instances create kraken-admin --network-interface="subnet=kraken-mgmt-subnet" --network-interface="subnet=kraken-prod-subnet"
gcloud compute instances create kraken-admin-936 --network-interface="subnet=kraken-mgmt-subnet" --network-interface="subnet=kraken-prod-subnet" gcloud compute instances create {name} --network-interface="subnet=kraken-mgmt-subnet" --network-interface="subnet=kraken-prod-subnet"
kraken-admin-936
Create alert
Open monitoring Create an alert Configure the policy to email your email and set
Resource Type : VM InstanceMetric : CPU utilizationFilter : instance_nameValue : kraken-adminCondition : is aboveThreshold : 50%For : 1 minute
export EMAIL=$(gcloud auth list --filter=status:ACTIVE --format="value(account)")cat >> channel.json << EOF{"type": "email","displayName": "Alert notifications","description": "An address to send email","labels": {"email_address": "$EMAIL"},}EOFgcloud beta monitoring channels create --channel-content-from-file="channel.json"
export CHANNEL=$(gcloud beta monitoring channels list --format="value(name)")cat >> alert.json << EOF{"combiner":"OR","conditions":[{"conditionThreshold":{"aggregations":[{"alignmentPeriod":"60s","perSeriesAligner":"ALIGN_MEAN"}],"comparison":"COMPARISON_GT","duration":"60s","filter":"metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\" metric.label.\"instance_name\"=\"kraken-admin-936\"","thresholdValue":0.5,"trigger":{"count":1}},"displayName":"GCE VM Instance - CPU utilization for kraken-admin-936"}],"displayName":"kraken-admin-936","enabled":true,"notificationChannels":["$CHANNEL"]}EOFgcloud alpha monitoring policies create --policy-from-file="alert.json"
export CHANNEL=$(gcloud beta monitoring channels list --format="value(name)")cat >> alert.json << EOF{"combiner":"OR","conditions":[{"conditionThreshold":{"aggregations":[{"alignmentPeriod":"60s","perSeriesAligner":"ALIGN_MEAN"}],"comparison":"COMPARISON_GT","duration":"60s","filter":"metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\" metric.label.\"instance_name\"=\"kraken-admin\"","thresholdValue":0.5,"trigger":{"count":1}},"displayName":"GCE VM Instance - CPU utilization for kraken-admin"}],"displayName":"kraken-admin","enabled":true,"notificationChannels":["$CHANNEL"]}EOF
gcloud alpha monitoring policies create --policy-from-file="alert.json"
Task 3 : Verify the Spinnaker deployment
Switch to cloudshell, run
gcloud config set compute/zone us-east1-bgcloud container clusters get-credentials spinnaker-tutorialDECK_POD=$(kubectl get pods --namespace default -l "cluster=spin-deck" -o jsonpath="{.items[0].metadata.name}")kubectl port-forward --namespace default $DECK_POD 8080:9000 >> /dev/null &
https://github.com/Kathuria/Qwiklabs-Challenge-Speedrun-Solution/blob/master/gcp-cloud-architecture-challenge-lab.md https://sakurasatio.blogspot.com/2021/10/gsp314.html