kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch21/lab
2024-02-20 17:15:27 +08:00
..
knative 新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件 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
todo-list 新增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

Ch20 lab

Setup

Deploy Knative with Contour:

kubectl apply -f lab/knative/

Deploy the to-do app:

kubectl apply -f lab/todo-list/

Get the ingress URL:

kubectl get svc -n contour-external envoy -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:80'

Map your hosts file to use the Contour IP for todo.kiamol.local and api.todo.kiamol.local

Solution

I've used a Knative Service custom resource which specifies the API container image.

kubectl apply -f lab/solution/todo-api.yaml

Check the Knative Service is running:

kubectl get ksvc -n todo

Invoke the function:

curl --data 'Write KIAMOL ch22' http://api.todo.kiamol.local/todos

Print the function logs - you should see the event being published:

kubectl -n todo logs -l serving.knative.dev/service=api -c user-container

Print the save handler logs - you should see the new item being saved:

kubectl -n todo logs -l component=save-handler

Browse to http://todo.kiamol.local to see the new item