forked from Ayush7-BIT/Google-Facilitator-Program-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Set Up and Configure a Cloud Environment in Google Cloud
103 lines (54 loc) · 3.04 KB
/
Set Up and Configure a Cloud Environment in Google Cloud
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Firstly Let's Create Environment Variables!!
export USER_NAME2=
Task 1 --------------------------------------------------------
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 ---------------------------------------------------------
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 ------------------------------------------------------------
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 -------------------------------------------------------------
gcloud sql instances create griffin-dev-db --root-password password --region=us-east1 --database-version=MYSQL_5_7
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 ---------------------------------------------------------------
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 ----------------------------------------------------------------
sed -i "s/username_goes_here/wp_user/g" wp-k8s/wp-env.yaml
sed -i "s/username_goes_here/stormwind_rules/g" wp-k8s/wp-env.yaml
cd wp-k8s
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
TASK 7 -----------------------------------------------------------------
sed -i "s/YOUR_SQL_INSTANCE/griffin-dev-db/g" wp-deployment.yaml
kubectl create -f wp-deployment.yaml
kubectl create -f wp-service.yaml
kubectl get svc -w
TASK 8 -----------------------------------------------------------------
FOLLOW THE VIDEO
TASK 9 -----------------------------------------------------------------
gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID --member=user:$USER_NAME2 --role=roles/editor
YOU ARE DOING GREAT!!
THANK YOU FOR WATCHING!!