1
+ # Creates and runs PDP on a kind-based clauster
2
+ # If running on Windows, run on Bash (e.g., Git Bash) or change file ext from .sh to .cmd
3
+ # .cmd works the same but you'll see echo lines twice
4
+
5
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Creating cluster. Now's a good time to go get coffee >>>>>>>>>>>>>>>>>"
6
+ kind create cluster
7
+
8
+ # Assumes kustomization.yaml lives in server/secets
9
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Create and add secrets to k8s environment >>>>>>>>>>>>>>>>>"
10
+ kubectl apply -k server/secrets
11
+
12
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Build images >>>>>>>>>>>>>>>>>"
13
+ docker-compose build
14
+
15
+ # So pods, specifically 'wait_for', have read access to API
16
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Give pods access to k8s API >>>>>>>>>>>>>>>>>"
17
+ kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods,services,deployments
18
+ kubectl create rolebinding default-pod-reader --role=pod-reader --serviceaccount=default:default --namespace=default
19
+
20
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Tag and push client container image >>>>>>>>>>>>>>>>>"
21
+ docker tag src_client localhost:5000/src-client:latest
22
+ kind load docker-image localhost:5000/src-client:latest
23
+
24
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Tag and push server container image >>>>>>>>>>>>>>>>>"
25
+ docker tag src_server localhost:5000/src-server:latest
26
+ kind load docker-image localhost:5000/src-server:latest
27
+
28
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Apply k8s deployment files to launch containers >>>>>>>>>>>>>>>>>"
29
+ kubectl apply -f k8s_conf
30
+
31
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Wait 20s in hopes that client service/container is live >>>>>>>>>>>>>>>>>"
32
+ sleep 20
33
+
34
+ echo " " ; echo " >>>>>>>>>>>>>>>>> Forwarding port 80 from cluster to localhost >>>>>>>>>>>>>>>>>"
35
+ echo " '>>>>>>>>>>>>>>>>> Forwarding...' means it's working and will forward until ^C "
36
+ echo " >>>>>>>>>>>>>>>>> To restart port-forwarding, 'kubectl port-forward service/client 80:80 '"
37
+ kubectl port-forward service/client 80:80
38
+ echo " " ; echo " >>>>>>>>>>>>>>>>> ^- Failed? Try running 'kubectl port-forward service/client 80:80' >>>>>>>>>>>>>>>>>"
0 commit comments