部署 Knative 服务¶
在本教程中,您将部署一个 Hello world
Knative服务,该服务接受环境变量TARGET
并打印Hello ${TARGET}!
运行命令部署服务:
kn service create hello \
--image gcr.io/knative-samples/helloworld-go \
--port 8080 \
--env TARGET=World
Expected output
Service hello created to latest revision 'hello-world' is available at URL:
http://hello.default.${LOADBALANCER_IP}.sslip.io
${LOADBALANCER_IP}
above depends on your type of cluster,
for kind
it will be 127.0.0.1
for minikube
depends on the local tunnel.
-
将以下YAML复制到名为
hello.yaml
的文件中:apiVersion: serving.knative.dev/v1 kind: Service metadata: name: hello spec: template: spec: containers: - image: gcr.io/knative-samples/helloworld-go ports: - containerPort: 8080 env: - name: TARGET value: "World"
-
运行命令部署Knative Service:
kubectl apply -f hello.yaml
Expected output
service.serving.knative.dev/hello created