第一个 Serving 用例 Hello world
1. 创建一个名为 service.yaml
的文件,文件内容如下
service.yaml
的文件,文件内容如下apiVersion: serving.knative.dev/v1 # Current version of Knative
kind: Service
metadata:
name: helloworld-go # The name of the app
namespace: default # The namespace the app will use
spec:
template:
spec:
containers:
- image: gcr.io/knative-samples/helloworld-go # Reference to the image of the app
env:
- name: TARGET # The environment variable printed out by the sample app
value: "Go Sample v1"
2. 执行以下脚本
kubectl apply --filename service.yaml
查看 Knative 工作负载的命令
kubectl get ksvc helloworld-go
结果如下
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld-go http://helloworld-go.default.34.83.80.117.xip.io helloworld-go-96dtk helloworld-go-96dtk True
你的环境里如果没有修改过默认域名,URL 这一列应该显示的是 http://helloworld-go.default.example.com
测试方式
istio gateway 的 external ip配置了 xip.io 的话, 其中
# curl http://helloworld-go.default.34.83.80.117.xip.io
Hello World: Go Sample v1!
Last updated
Was this helpful?