GSP-321: Set Up and Configure a Cloud Environment in Google Cloud

GSP-321: Set Up and Configure a Cloud Environment in Google Cloud

Overview

Task - 1 : Create development VPC manually

1gcloud compute networks create griffin-dev-vpc --subnet-mode custom
2
3gcloud compute networks subnets create griffin-dev-wp --network=griffin-dev-vpc --region us-east1 --range=192.168.16.0/20
4
5gcloud compute networks subnets create griffin-dev-mgmt --network=griffin-dev-vpc --region us-east1 --range=192.168.32.0/20

Task - 2 : Create production VPC manually

 1gsutil cp -r gs://cloud-training/gsp321/dm .
 2
 3cd dm
 4
 5sed -i s/SET_REGION/us-east1/g prod-network.yaml
 6
 7gcloud deployment-manager deployments create prod-network \
 8    --config=prod-network.yaml
 9
10cd ..

Task - 3 : Create bastion host

1gcloud compute instances create bastion --network-interface=network=griffin-dev-vpc,subnet=griffin-dev-mgmt  --network-interface=network=griffin-prod-vpc,subnet=griffin-prod-mgmt --tags=ssh --zone=us-east1-b
2
3gcloud compute firewall-rules create fw-ssh-dev --source-ranges=0.0.0.0/0 --target-tags ssh --allow=tcp:22 --network=griffin-dev-vpc
4
5gcloud compute firewall-rules create fw-ssh-prod --source-ranges=0.0.0.0/0 --target-tags ssh --allow=tcp:22 --network=griffin-prod-vpc

Task - 4 : Create and configure Cloud SQL Instance

1gcloud sql instances create griffin-dev-db --root-password password --region=us-east1
2
3gcloud sql connect griffin-dev-db
4
5CREATE DATABASE wordpress;
6GRANT ALL PRIVILEGES ON wordpress.* TO "wp_user"@"%" IDENTIFIED BY "stormwind_rules";
7FLUSH PRIVILEGES;
8
9exit

Task - 5 : Create Kubernetes cluster

 1gcloud container clusters create griffin-dev \
 2  --network griffin-dev-vpc \
 3  --subnetwork griffin-dev-wp \
 4  --machine-type n1-standard-4 \
 5  --num-nodes 2  \
 6  --zone us-east1-b
 7
 8
 9gcloud container clusters get-credentials griffin-dev --zone us-east1-b
10
11cd ~/
12
13gsutil cp -r gs://cloud-training/gsp321/wp-k8s .

Task - 6 : Prepare the Kubernetes cluster

  • Open Editor -> wp-k8s -> wp-env.yaml Change username and password to:
1username : wp_user
2password : stormwind_rules
  • Save.
1cd wp-k8s
2
3kubectl create -f wp-env.yaml
4
5gcloud iam service-accounts keys create key.json \
6    --iam-account=cloud-sql-proxy@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com
7kubectl create secret generic cloudsql-instance-credentials \
8    --from-file key.json

Task - 7 : Create a WordPress deployment

  • In editor: wp-deployment.yaml -> replace YOUR_SQL_INSTANCE with griffin-dev-db.

  • Save.

1kubectl create -f wp-deployment.yaml
2kubectl create -f wp-service.yaml

Task - 8 : Enable monitoring

  • Navigation Menu -> Kubernetes Engine -> Services and Ingress -> Copy Endpoint's address.

  • Navigation Menu -> Monitoring -> Uptime Checks -> + CREATE UPTIME CHECK

1   Title : Wordpress Uptime
  • Next -> Target
1   Hostname : {Endpoint's address} (without http...)
2   Path : /
  • Next -> Next -> Create

Task - 9 : Provide access for an additional engineer

  • Navigation Menu -> IAM & Admin -> IAM -> ADD
1New Member : {Username 2 from Lab instruction page}
2Role : Project -> Editor
  • Save.

Congratulations, you're all done with the lab 😄