Deploy and Manage Cloud Environments with Google Cloud: Challenge Lab

cd /work/dm
sed -i s/SET_REGION/us-east1/g prod-network.yaml
gcloud deployment-manager deployments create prod-network --config=prod-network.yaml
gcloud config set compute/zone us-east1-b
gcloud container clusters create kraken-cluster- \
--num-nodes 2 \
--network kraken-prod-vpc \
--subnetwork kraken-prod-subnet\
--zone us-east1-b
gcloud container clusters get-credentials kraken-cluster-
gcloud config set compute/zone us-east1-b
gcloud compute instances create kraken-admin- --network-interface="subnet=kraken-mgmt-subnet" --network-interface="subnet=kraken-prod-subnet"
gcloud config set compute/zone us-east1-b
gcloud container clusters get-credentials spinnaker-tutorial
DECK_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-app
touch a
git config --global user.email "$(gcloud config get-value account)"
git config --global user.name "Student"
git commit -a -m "change"
git tag v1.0.1
git 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/dm
sed -i s/SET_REGION/us-east1/g prod-network.yaml
gcloud deployment-manager deployments create prod-network --config=prod-network.yaml
gcloud config set compute/zone us-east1-b
gcloud container clusters create kraken-prod \
--num-nodes 2 \
--network kraken-prod-vpc \
--subnetwork kraken-prod-subnet\
--zone us-east1-b
gcloud container clusters get-credentials kraken-prod
cd /work/k8s
for 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 STATUS
kraken-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-b
gcloud 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 Instance
Metric : CPU utilization
Filter : instance_name
Value : kraken-admin
Condition : is above
Threshold : 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"
},
}
EOF
gcloud 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"
]
}
EOF
gcloud 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-b
gcloud container clusters get-credentials spinnaker-tutorial
DECK_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://www.courseintern.com/post/qwiklabs/challenge-labs/gsp314-deploy-and-manage-cloud-environments-with-google-cloud/

https://github.com/Kathuria/Qwiklabs-Challenge-Speedrun-Solution/blob/master/gcp-cloud-architecture-challenge-lab.md https://sakurasatio.blogspot.com/2021/10/gsp314.html