This commit is contained in:
2024-02-20 17:15:27 +08:00
committed by huty
parent 6706e1a633
commit 34158042ad
1529 changed files with 177765 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
cd /kiamol/ch05
kubectl apply -f sleep/sleep.yaml
kubectl exec deploy/sleep -- sh -c 'echo ch05 > /file.txt; ls /*.txt'
kubectl get pod -l app=sleep -o jsonpath='{.items[0].status.containerStatuses[0].containerID}'
kubectl exec -it deploy/sleep -- killall5
kubectl get pod -l app=sleep -o jsonpath='{.items[0].status.containerStatuses[0].containerID}'
kubectl exec deploy/sleep -- ls /*.txt

View File

@@ -0,0 +1,9 @@
cd /kiamol/ch05
kubectl apply -f sleep/sleep-with-emptyDir.yaml
kubectl exec deploy/sleep -- ls /data
kubectl exec deploy/sleep -- sh -c 'echo ch05 > /data/file.txt; ls /data'
kubectl get pod -l app=sleep -o jsonpath='{.items[0].status.containerStatuses[0].containerID}'
kubectl exec deploy/sleep -- killall5
kubectl get pod -l app=sleep -o jsonpath='{.items[0].status.containerStatuses[0].containerID}'
kubectl exec deploy/sleep -- cat /data/file.txt

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch05
kubectl apply -f pi/v1/
kubectl wait --for=condition=Ready pod -l app=pi-web
kubectl get svc pi-proxy -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:8080/?dp=30000'
kubectl exec deploy/pi-proxy -- ls -l /data/nginx/cache

View File

@@ -0,0 +1,4 @@
cd /kiamol/ch05
kubectl delete pod -l app=pi-proxy
kubectl exec deploy/pi-proxy -- ls -l /data/nginx/cache

View File

@@ -0,0 +1,10 @@
cd /kiamol/ch05
kubectl apply -f pi/nginx-with-hostPath.yaml
kubectl exec deploy/pi-proxy -- ls -l /data/nginx/cache
#
curl http://localhost:8080/?dp=30000
kubectl delete pod -l app=pi-proxy
kubectl exec deploy/pi-proxy -- ls -l /data/nginx/cache

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch05
kubectl apply -f sleep/sleep-with-hostPath.yaml
kubectl exec deploy/sleep -- ls -l /var/log
kubectl exec deploy/sleep -- ls -l /node-root/var/log
kubectl exec deploy/sleep -- whoami

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch05
kubectl apply -f sleep/sleep-with-hostPath-subPath.yaml
kubectl exec deploy/sleep -- sh -c 'ls /pod-logs | grep _pi-'
kubectl exec deploy/sleep -- sh -c 'ls /container-logs | grep nginx'

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch05
kubectl label node $(kubectl get nodes -o jsonpath='{.items[0].metadata.name}') kiamol=ch05
kubectl get nodes -l kiamol=ch05
kubectl apply -f todo-list/persistentVolume.yaml
kubectl get pv

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch05
kubectl apply -f todo-list/postgres-persistentVolumeClaim.yaml
kubectl get pvc
kubectl get pv

View File

@@ -0,0 +1,4 @@
cd /kiamol/ch05
kubectl apply -f todo-list/postgres-persistentVolumeClaim-too-big.yaml
kubectl get pvc

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch05
kubectl apply -f sleep/sleep-with-hostPath.yaml
kubectl wait --for=condition=Ready pod -l app=sleep
kubectl exec deploy/sleep -- mkdir -p /node-root/volumes/pv01

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch05
kubectl apply -f todo-list/postgres/
sleep 30
kubectl logs -l app=todo-db --tail 1
kubectl exec deploy/sleep -- sh -c 'ls -l /node-root/volumes/pv01 | grep wal'

View File

@@ -0,0 +1,10 @@
cd /kiamol/ch05
kubectl apply -f todo-list/web/
kubectl wait --for=condition=Ready pod -l app=todo-web
kubectl get svc todo-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:8081/new'
#
kubectl delete pod -l app=todo-db
kubectl exec deploy/sleep -- ls -l /node-root/volumes/pv01/pg_wal

View File

@@ -0,0 +1,7 @@
cd /kiamol/ch05
kubectl apply -f todo-list/postgres-persistentVolumeClaim-dynamic.yaml
kubectl get pvc
kubectl get pv
kubectl delete pvc postgres-pvc-dynamic
kubectl get pv

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch05
kubectl get storageclass
chmod +x cloneDefaultStorageClass.sh ./cloneDefaultStorageClass.sh
kubectl get sc

View File

@@ -0,0 +1,7 @@
cd /kiamol/ch05
kubectl apply -f storageClass/postgres-persistentVolumeClaim-storageClass.yaml
kubectl apply -f storageClass/todo-db.yaml
kubectl get pvc
kubectl get pv
kubectl get pods -l app=todo-db

View File

@@ -0,0 +1,9 @@
# Exercises
These are scripted versions of the exercises in the chapter.
I used them to smoke-test the exercises on different clusters.
You can use them to save typing time, but be aware that it can take a few seconds for the results of the Kubernetes commands to take effect.
So the output won't always be the same as if you manually run the exercises.

View File

@@ -0,0 +1,4 @@
cd /kiamol/ch05
kubectl delete -f pi/v1 -f sleep/ -f storageClass/ -f todo-list/web -f todo-list/postgres -f todo-list/
kubectl delete sc kiamol