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,53 @@
# Ch07 lab
Run the app:
```
kubectl apply -f lab/pi/
```
Check the app and see it's broken:
```
kubectl describe pod -l app=pi-web
```
> The startup command for the app container uses a script which doesn't exist.
## Sample Solution
My updated [Deployment](solution/web.yaml) for the web app uses multiple containers.
Init containers:
- init container `init-1` writes the startup script file in an EmptyDir volume
- `init-2` makes the startup script executable
- `init-3` writes a text file with a fake app version.
App container:
- mounts the EmptyDir volume and runs the script at startup; serves the app on port 80.
Sidecar:
- runs a simple NCat HTTP server, serving the version number text file on port 8080.
Run the update and browse to your Service on port 8070 for Pi and 8071 for the version:
```
kubectl apply -f lab/solution/
```
> This is not the most efficient way to do this! It's just an example which makes use of multi-container Pods.
## Teardown
Delete the lab resources by their labels:
```
kubectl get all -l kiamol=ch07-lab
kubectl delete all -l kiamol=ch07-lab
```