(未显示同一用户的2个中间版本) | |||
第52行: | 第52行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= CLI = | |||
<syntaxhighlight lang="bash"> | |||
wget https://github.com/knative/client/releases/download/knative-v1.18.0/kn-linux-amd64 | |||
wget https://github.com/knative/func/releases/download/knative-v1.18.1/func_linux_amd64 | |||
sudo install kn-linux-amd64 /usr/local/bin/kn | |||
sudo install func_linux_amd64 /usr/local/bin/func | |||
</syntaxhighlight> | |||
= Test hello world= | |||
<syntaxhighlight lang="bash"> | |||
$ func create -l node helloworld | |||
$ cd helloworld | |||
$ func build | |||
A registry for function images is required. For example, 'docker.io/tigerteam'. | |||
? Registry for function images: docker.io/yai42 | |||
Note: building a function the first time will take longer than subsequent builds | |||
Building function image | |||
Still building | |||
Still building | |||
🙌 Function built: index.docker.io/yai42/helloworld:latest | |||
</syntaxhighlight> | |||
// https://hub.docker.com/repository/docker/yai42/helloworld | |||
<syntaxhighlight lang="bash"> | |||
$ func deploy | |||
function up-to-date. Force rebuild with --build | |||
Please provide credentials for image repository 'index.docker.io/yai42/helloworld'. | |||
? Username: yai42 | |||
? Password: ************************************ | |||
Credentials will not be saved. | |||
.. | |||
</syntaxhighlight> | |||
trouble shotting: | |||
<syntaxhighlight lang="bash"> | |||
$ kubectl get ksvc helloworld | |||
NAME URL LATESTCREATED LATESTREADY READY REASON | |||
helloworld http://helloworld.default.api.quillgen.com helloworld-00001 helloworld-00001 Unknown IngressNotConfigured | |||
</syntaxhighlight> | |||
must set ingress to kourier: | |||
kubectl get configmap/config-network -n knative-serving -o yaml | grep ingress | |||
Install metallb if external ip not configured, or change it to NodePort: | |||
<syntaxhighlight lang="bash"> | |||
$ kubectl --namespace kourier-system get service kouriervice kourier | |||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | |||
kourier LoadBalancer 10.106.110.17 172.20.0.0 80:30288/TCP,443:32450/TCP 118m | |||
</syntaxhighlight> | |||
Expected: | |||
<syntaxhighlight lang="bash"> | |||
$ kubectl --namespace kourier-system get service kouriervice kourier | |||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE | |||
kourier LoadBalancer 10.106.110.17 172.20.0.0 80:30288/TCP,443:32450/TCP 118m | |||
$ kubectl get ksvc helloworld | |||
NAME URL LATESTCREATED LATESTREADY READY REASON | |||
helloworld http://helloworld.default.api.quillgen.com helloworld-00001 helloworld-00001 True | |||
$ func list | |||
NAME NAMESPACE RUNTIME URL READY | |||
helloworld default http://helloworld.default.api.quillgen.com True | |||
$ curl -H "Host: helloworld.default.api.quillgen.com" http://172.20.0.0 | |||
{"query":{}} | |||
</syntaxhighlight> | |||
[[Category:Kubernetes]] | [[Category:Kubernetes]] | ||
[[Category:Linux/Unix]] | [[Category:Linux/Unix]] |
2025年5月6日 (二) 15:17的最新版本
Knative Serving
Install serving
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.18.0/serving-crds.yaml
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.18.0/serving-core.yaml
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.18.0/kourier.yaml
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'
Verify:
$ kubectl get pods -n knative-serving
NAME READY STATUS RESTARTS AGE
activator-cbf5b6b55-wbmf2 1/1 Running 0 3m7s
autoscaler-c5d454c88-5zncq 1/1 Running 0 3m7s
controller-84f96b7676-p26gh 1/1 Running 0 3m7s
net-kourier-controller-5bf7f49cc8-5dc9r 1/1 Running 0 2m44s
webhook-75d4fb6db5-cmvjl 1/1 Running 0 3m7s
verify kourier:
$ kubectl --namespace kourier-system get service kourier
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kourier LoadBalancer 10.106.110.17 <pending> 80:30288/TCP,443:32450/TCP 3m53s
Configure DNS
kubectl patch configmap/config-domain \
--namespace knative-serving \
--type merge \
--patch '{"data":{"api.quillgen.com":""}}'
Install eventing
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.18.0/eventing-crds.yaml
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.18.0/eventing-core.yaml
$ kubectl get pods -n knative-eventing
NAME READY STATUS RESTARTS AGE
eventing-controller-674c57ddb7-wrt4h 1/1 Running 0 9m25s
eventing-webhook-6d86554d4d-v5r5t 1/1 Running 0 9m25s
job-sink-5fdf4b8c5c-gjlts 1/1 Running 0 9m25s
CLI
wget https://github.com/knative/client/releases/download/knative-v1.18.0/kn-linux-amd64
wget https://github.com/knative/func/releases/download/knative-v1.18.1/func_linux_amd64
sudo install kn-linux-amd64 /usr/local/bin/kn
sudo install func_linux_amd64 /usr/local/bin/func
Test hello world
$ func create -l node helloworld
$ cd helloworld
$ func build
A registry for function images is required. For example, 'docker.io/tigerteam'.
? Registry for function images: docker.io/yai42
Note: building a function the first time will take longer than subsequent builds
Building function image
Still building
Still building
🙌 Function built: index.docker.io/yai42/helloworld:latest
// https://hub.docker.com/repository/docker/yai42/helloworld
$ func deploy
function up-to-date. Force rebuild with --build
Please provide credentials for image repository 'index.docker.io/yai42/helloworld'.
? Username: yai42
? Password: ************************************
Credentials will not be saved.
..
trouble shotting:
$ kubectl get ksvc helloworld
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld http://helloworld.default.api.quillgen.com helloworld-00001 helloworld-00001 Unknown IngressNotConfigured
must set ingress to kourier:
kubectl get configmap/config-network -n knative-serving -o yaml | grep ingress
Install metallb if external ip not configured, or change it to NodePort:
$ kubectl --namespace kourier-system get service kouriervice kourier
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kourier LoadBalancer 10.106.110.17 172.20.0.0 80:30288/TCP,443:32450/TCP 118m
Expected:
$ kubectl --namespace kourier-system get service kouriervice kourier
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kourier LoadBalancer 10.106.110.17 172.20.0.0 80:30288/TCP,443:32450/TCP 118m
$ kubectl get ksvc helloworld
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld http://helloworld.default.api.quillgen.com helloworld-00001 helloworld-00001 True
$ func list
NAME NAMESPACE RUNTIME URL READY
helloworld default http://helloworld.default.api.quillgen.com True
$ curl -H "Host: helloworld.default.api.quillgen.com" http://172.20.0.0
{"query":{}}