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,5 @@
cd /kiamol/ch04
kubectl apply -f sleep/sleep.yaml
kubectl wait --for=condition=Ready pod -l app=sleep
kubectl exec deploy/sleep -- printenv HOSTNAME KIAMOL_CHAPTER

View File

@@ -0,0 +1,4 @@
cd /kiamol/ch04
kubectl apply -f sleep/sleep-with-env.yaml
kubectl exec deploy/sleep -- printenv HOSTNAME KIAMOL_CHAPTER

View File

@@ -0,0 +1,7 @@
cd /kiamol/ch04
kubectl create configmap sleep-config-literal --from-literal=kiamol.section='4.1'
kubectl get cm sleep-config-literal
kubectl describe cm sleep-config-literal
kubectl apply -f sleep/sleep-with-configMap-env.yaml
kubectl exec deploy/sleep -- sh -c 'printenv | grep "^KIAMOL"'

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch04
kubectl create configmap sleep-config-env-file --from-env-file=sleep/ch04.env
kubectl get cm sleep-config-env-file
kubectl apply -f sleep/sleep-with-configMap-env-file.yaml
kubectl exec deploy/sleep -- sh -c 'printenv | grep "^KIAMOL"'

View File

@@ -0,0 +1,7 @@
cd /kiamol/ch04
kubectl apply -f todo-list/todo-web.yaml
kubectl wait --for=condition=Ready pod -l app=todo-web
kubectl get svc todo-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:8080'
kubectl logs -l app=todo-web

View File

@@ -0,0 +1,4 @@
cd /kiamol/ch04
kubectl apply -f todo-list/configMaps/todo-web-config-dev.yaml
kubectl apply -f todo-list/todo-web-dev.yaml

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch04
kubectl exec deploy/todo-web -- sh -c 'ls -l /app/app*.json'
kubectl exec deploy/todo-web -- sh -c 'ls -l /app/config/*.json'
kubectl exec deploy/todo-web -- sh -c 'echo ch04 >> /app/config/config.json'

View File

@@ -0,0 +1,7 @@
cd /kiamol/ch04
kubectl logs -l app=todo-web
kubectl apply -f todo-list/configMaps/todo-web-config-dev-with-logging.yaml
sleep 120
kubectl exec deploy/todo-web -- sh -c 'ls -l /app/config/*.json'
kubectl logs -l app=todo-web

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch04
kubectl apply -f todo-list/todo-web-dev-broken.yaml
kubectl logs -l app=todo-web
kubectl get pods -l app=todo-web

View File

@@ -0,0 +1,7 @@
cd /kiamol/ch04
kubectl apply -f todo-list/todo-web-dev-no-logging.yaml
kubectl exec deploy/todo-web -- sh -c 'ls /app/config'
kubectl logs -l app=todo-web
kubectl get pods -l app=todo-web

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch04
kubectl create secret generic sleep-secret-literal --from-literal=secret=shh...
kubectl describe secret sleep-secret-literal
kubectl get secret sleep-secret-literal -o jsonpath='{.data.secret}'
kubectl get secret sleep-secret-literal -o jsonpath='{.data.secret}' | base64 -d

View File

@@ -0,0 +1,4 @@
cd /kiamol/ch04
kubectl apply -f sleep/sleep-with-secret.yaml
kubectl exec deploy/sleep -- printenv KIAMOL_SECRET

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch04
kubectl apply -f todo-list/secrets/todo-db-secret-test.yaml
kubectl get secret todo-db-secret-test -o jsonpath='{.data.POSTGRES_PASSWORD}'
kubectl get secret todo-db-secret-test -o jsonpath='{.metadata.annotations}'

View File

@@ -0,0 +1,5 @@
cd /kiamol/ch04
kubectl apply -f todo-list/todo-db-test.yaml
kubectl logs -l app=todo-db --tail 1
kubectl exec deploy/todo-db -- sh -c 'ls -l $(readlink -f /secrets/postgres_password)'

View File

@@ -0,0 +1,6 @@
cd /kiamol/ch04
kubectl apply -f todo-list/configMaps/todo-web-config-test.yaml
kubectl apply -f todo-list/secrets/todo-web-secret-test.yaml
kubectl apply -f todo-list/todo-web-test.yaml
kubectl exec deploy/todo-web-test -- cat /app/secrets/secrets.json

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,6 @@
cd /kiamol/ch04
kubectl delete -f sleep/
kubectl delete -f todo-list/
kubectl delete -f todo-list/configMaps/
kubectl delete -f todo-list/secrets/