This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
script.sh
executable file
·60 lines (49 loc) · 2 KB
/
script.sh
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
#! /bin/bash
# Initialization of Script
gcloud init < a
gcloud container clusters create io
cd kubernetes
# Create a Kubernetes cluster and launch Nginx container
if (kubectl create deployment nginx --image=nginx:1.10.0
kubectl expose deployment nginx --port 80 --type LoadBalancer)
then
printf "\n\e[1;96m%s\n\n\e[m" 'Created Kubernetes cluster & Nginx container: Checkpoint Completed (1/5)'
sleep 2.5
# Create Monolith pods and service
if (kubectl create -f pods/monolith.yaml
kubectl create secret generic tls-certs --from-file tls/
kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf
kubectl create -f pods/secure-monolith.yaml
kubectl create -f services/monolith.yaml)
then
printf "\n\e[1;96m%s\n\n\e[m" 'Monlith pods and service created: Checkpoint Completed (2/5)'
sleep 2.5
# Allow traffic to the monolith service on the exposed nodeport
if gcloud compute firewall-rules create allow-monolith-nodeport \
--allow=tcp:31000
then
printf "\n\e[1;96m%s\n\n\e[m" 'Traffic allowed: Checkpoint Completed (3/5)'
sleep 2.5
# Adding Labels to Pods
if kubectl label pods secure-monolith 'secure=enabled'
then
printf "\n\e[1;96m%s\n\n\e[m" 'Label added: Checkpoint Completed (4/5)'
sleep 2.5
# Deploying Applications with Kubernetes
if (kubectl create -f deployments/auth.yaml
kubectl create -f services/auth.yaml
kubectl create -f deployments/hello.yaml
kubectl create -f services/hello.yaml
kubectl create configmap nginx-frontend-conf --from-file=nginx/frontend.conf
kubectl create -f deployments/frontend.yaml
kubectl create -f services/frontend.yaml)
then
printf "\n\e[1;96m%s\n\n\e[m" 'Applications Deployed: Checkpoint Completed (5/5)'
sleep 2.5
printf "\n\e[1;92m%s\n\n\e[m" 'Lab Completed'
fi
fi
fi
fi
fi
gcloud auth revoke --all