@@ -40,7 +40,7 @@ kubectl create secret generic mysql-secrets \
4040kubectl apply -f mysql-pvc-oci-bv.yaml
4141```
4242
43- > Use mysql-pv -manual.yaml if deploying local
43+ > Use mysql-pvc -manual.yaml if deploying local
4444
4545#### Create Service for MySQL
4646
@@ -54,7 +54,27 @@ kubectl apply -f mysql-svc.yaml
5454kubectl apply -f mysql-dep.yaml
5555```
5656
57- #### Optional: Insert Data
57+ ### Deploy the Spring Boot Demo App
58+
59+ #### Create Service for Demo App
60+
61+ ``` shell
62+ kubectl apply -f app-svc.yaml
63+ ```
64+
65+ #### Create Deployment for Demo App
66+
67+ ``` shell
68+ kubectl apply -f app-dep.yaml
69+ ```
70+
71+ #### Optional: Check logs
72+
73+ ``` shell
74+ kubectl logs -l app=demoapp --follow
75+ ```
76+
77+ #### Optional: Insert Data to MySQL
5878
5979##### Connect to mysql
6080
87107pod " mysql-client" deleted
88108```
89109
90- ### Deploy the Spring Boot Demo App
110+ #### Optional: Test with port-forward
91111
92- #### Create Service for Demo App
112+ ``` shell
113+ kubectl port-forward deploy/demoapp 8081:8081
114+ ```
115+
116+ Navigate to http://localhost:8081/users
117+
118+ #### Test with LoadBalancer IP Address
93119
94120``` shell
95- kubectl apply -f app- svc.yaml
121+ kubectl get svc
96122```
97123
98- #### Create Deployment for Demo App
124+ Navigate to http://<demoapp_EXTERNAL_IP_ADDRESS>/users
125+
126+ ## Create Horizontal Pod Autoscaler for Demo App
127+
128+ ### Install metrics server
99129
100130``` shell
101- kubectl apply -f app-dep .yaml
131+ kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components .yaml
102132```
103133
104- #### Optional: Check logs
134+ ### Create autoscale for Demo App
105135
106136``` shell
107- kubectl logs -l app=demoapp --follow
137+ kubectl autoscale deployment demoapp --cpu-percent=30 --min=1 --max=10
108138```
109139
110- #### Optional: Test with port-forward
140+ ### Check HPA
111141
112142``` shell
113- kubectl logs -l app=demoapp --follow
143+ kubectl get hpa
114144```
145+
146+ ### Increase load
147+
148+ ``` shell
149+ kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c " while sleep 0.01; do wget -q -O- http://demoapp/users; done"
150+ ```
151+
152+ Within a minute or so, we should see the higher CPU load by executing:
153+
154+ ``` shell
155+ kubectl get hpa
156+ ```
157+
158+ ## Prometheus and Grafana
159+
160+ ### Install the grafana-prometheus stack
161+
162+ ``` shell
163+ helm install prometheus prometheus-community/kube-prometheus-stack
164+ ```
165+
166+ ### get the grafana admin password
167+
168+ ``` shell
169+ kubectl get secret prometheus-grafana \
170+ -o jsonpath=" {.data.admin-password}" | base64 --decode ; echo
171+ ```
172+
173+ ### Test Grafana with port-forward
174+
175+ ``` shell
176+ kubectl port-forward svc/prometheus-grafana 8085:80
177+ ```
178+
179+ Navigate to http://localhost:8085/
0 commit comments