Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Syed-Hassaan/6167d3daef0a4f6856fb78e98159d31e to your computer and use it in GitHub Desktop.
Save Syed-Hassaan/6167d3daef0a4f6856fb78e98159d31e to your computer and use it in GitHub Desktop.
Set Up and Configure a Cloud Environment in Google Cloud: Challenge Lab # GSP321
######################################################################################
## Set Up and Configure a Cloud Environment in Google Cloud: Challenge Lab # GSP321 ##
######################################################################################
====================== TASK 1: Create development VPC manually ======================
gcloud compute networks create griffin-dev-vpc --subnet-mode custom
gcloud compute networks subnets create griffin-dev-wp --network=griffin-dev-vpc --region us-east1 --range=192.168.16.0/20
gcloud 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 ======================
gsutil cp -r gs://cloud-training/gsp321/dm .
----------------------------------------------------------------
cd dm
sed -i s/SET_REGION/us-east1/g prod-network.yaml
gcloud deployment-manager deployments create prod-network \
--config=prod-network.yaml
-----------------------------------------------------------------
cd ..
====================== TASK 3: Create bastion host ======================
gcloud 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
gcloud compute firewall-rules create fw-ssh-dev --source-ranges=0.0.0.0/0 --target-tags ssh --allow=tcp:22 --network=griffin-dev-vpc
gcloud 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 ======================
gcloud sql instances create griffin-dev-db --root-password password --region=us-east1
gcloud sql connect griffin-dev-db
---------------------------------------------------------------------------------------
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO "wp_user"@"%" IDENTIFIED BY "stormwind_rules";
FLUSH PRIVILEGES;
----------------------------------------------------------------------------------------
exit
====================== TASK 5: Create Kubernetes cluster ======================
gcloud container clusters create griffin-dev \
--network griffin-dev-vpc \
--subnetwork griffin-dev-wp \
--machine-type n1-standard-4 \
--num-nodes 2 \
--zone us-east1-b
-------------------------------------------------------------------------
gcloud container clusters get-credentials griffin-dev --zone us-east1-b
-------------------------------------------------------------------------
cd ~/
gsutil cp -r gs://cloud-training/gsp321/wp-k8s .
-------------------------------------------------------------------------
====================== TASK 6, 7, 8 ======================
gsutil cp -r gs://cloud-training/gsp321/wp-k8s .
cd wp-k8s
sed -i s/username_goes_here/wp_user/g wp-env.yaml
sed -i s/password_goes_here/stormwind_rules/g wp-env.yaml
----------------------------------------------------------------------------------
kubectl create -f wp-env.yaml
gcloud iam service-accounts keys create key.json --iam-account=cloud-sql-proxy@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com
kubectl create secret generic cloudsql-instance-credentials --from-file key.json
----------------------------------------------------------------------------------
I=$(gcloud sql instances describe griffin-dev-db --format="value(connectionName)")
sed -i s/YOUR_SQL_INSTANCE/$I/g wp-deployment.yaml
kubectl create -f wp-deployment.yaml
kubectl 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 Title : Wordpress Uptime
// Next -> Target Hostname : {Endpoint's address} (without http...) Path : / // Next -> Next -> Create
====================== TASK 9: Provide access for an additional engineer ======================
// Navigation Menu -> IAM & Admin -> IAM -> ADD New Member : {Username 2 from Lab instruction page} Role : Project -> Editor
// Save.
######################################################################################
## Set Up and Configure a Cloud Environment in Google Cloud: Challenge Lab # GSP321 ##
######################################################################################
@fabi6ferreira
Copy link

Helpful, thank you so much, pal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment