-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path21-health-probes.sh
41 lines (32 loc) · 1.95 KB
/
21-health-probes.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
# Deploy health probe demo application
#
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#types-of-probe
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
#
# https://github.com/JanneMattila/KubernetesProbeDemo
# https://github.com/JanneMattila/Echo
# Command: HEALTH-PROBE-1
kubectl apply -f healthprobe-app/
# Validate
# Command: HEALTH-PROBE-2
kubectl get deployment -n healthprobe-app
kubectl get pod -n healthprobe-app
kubectl get hpa -n healthprobe-app
kubectl get service -n healthprobe-app
healthprobe_app_ip=$(kubectl get service healthprobe-app-svc -n healthprobe-app -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
store_variable healthprobe_app_ip
echo $healthprobe_app_ip
curl $healthprobe_app_ip
curl -s $healthprobe_app_ip/api/healthcheck | jq .
curl -s $healthprobe_app_ip/api/healthcheck/readiness --verbose
curl -s $healthprobe_app_ip/api/healthcheck/liveness --verbose
curl -s -X POST --data '{ "readiness": true, "liveness": true }' -H "Content-Type: application/json" "http://$healthprobe_app_ip/api/healthcheck" | jq .
healthprobe_app_server=$(curl -s $healthprobe_app_ip/api/healthcheck | jq -r .server)
echo $healthprobe_app_server
curl -s -X POST --data "{ \"shutdown\": true, \"condition\": \"$healthprobe_app_server\" }" -H "Content-Type: application/json" "http://$healthprobe_app_ip/api/healthcheck" --verbose
curl -s -X POST --data '{ "readiness": true, "liveness": true }' -H "Content-Type: application/json" "http://$healthprobe_app_ip/api/healthcheck" | jq .
curl -s -X POST --data '{ "readiness": true, "liveness": false, "livenessStatusCode": 429 }' -H "Content-Type: application/json" "http://$healthprobe_app_ip/api/healthcheck" | jq .
curl -s -X POST --data '{ "duration": 60 }' -H "Content-Type: application/json" "http://$healthprobe_app_ip/api/resourceusage"
kubectl top pod -n healthprobe-app
kubectl get deployment -n healthprobe-app
kubectl get pod -n healthprobe-app