kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch20/lab
2024-02-20 17:15:27 +08:00
..
solution 新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件 2024-02-20 17:15:27 +08:00
timecheck-controller 新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件 2024-02-20 17:15:27 +08:00
README.md 新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件 2024-02-20 17:15:27 +08:00
timecheck-test.yaml 新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件 2024-02-20 17:15:27 +08:00

Ch20 lab

Setup

Deploy the custom controller:

kubectl apply -f lab/timecheck-controller/

Try to create custom resource:

kubectl apply -f lab/timecheck-test.yaml

Check the controller logs:

kubectl logs -l app=timecheck-controller --tail 100

This controller doesn't handle the situation where the CRD doesn't exist, so the container exits and the Pod will keep restarting

Sample Solution

The CRD specifies the structure of the custom timecheck resource.

kubectl apply -f lab/solution/timecheck-crd.yaml

Restart the controller - it will be in CrashLoopBackOff status by now:

kubectl delete pods -l app=timecheck-controller

Now you can create the custom resource:

kubectl apply -f lab/timecheck-test.yaml

Check the controller has created a Deployment:

kubectl logs -l app=timecheck-controller --tail 4

List the timecheck resources:

kubectl get tc

And check the logs from the timecheck app:

kubectl logs -l app=timecheck -c logger

Teardown

Delete the CRD:

kubectl delete crd timechecks.ch20.kiamol.net

And the controller:

kubectl delete -f lab/timecheck-controller/