[root@knative-k8s-master-139 ~]# kubectl api-resources | grep "knative"services kservice,ksvc serving.knative.dev/v1 true Service在这里你必须有一个kubernetes集群并且安装了Knative;安装部署文档在我上篇博客有说明;
# 可以使用--help来查看如何部署;[root@knative-k8s-master-139 ~]# kn service --help[root@knative-k8s-master-139 ~]# kn service create --help# [root@knative-k8s-master-139 ~]# kn service create helloworld-example \ # name就叫做hello-example; --image gcr.io/knative-samples/helloworld-go \ # 引用的容器镜像,使用knative提供的简单应用;--env TRAGET="First" # 注入示例应用需要的环境变量;Creating service 'helloworld-example' in namespace 'default': # 未指定namespace,在默认的default名称空间下; 0.042s The Route is still working to reflect the latest desired specification. 0.050s ... 0.090s Configuration "helloworld-example" is waiting for a Revision to become ready.575.648s ...575.679s Ingress has not yet been reconciled.575.748s Waiting for load balancer to be ready575.951s Ready to serve.Service 'helloworld-example' created to latest revision 'helloworld-example-00001' is available at URL:http://helloworld-example.default.example.com[root@knative-k8s-master-139 ~]# kn service listNAME URL LATEST AGE CONDITIONS READY REASONhelloworld-example http://helloworld-example.default.example.com helloworld-example-00001 12h 3 OK / 3 True 1.首先它给我们创建了一个deployment,我们可以看到此时的Pod Ready是处于0的,这是Knative独有的冷启动,在后续会说明;
[root@knative-k8s-master-139 ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEhelloworld-example-00001-deployment 0/0 0 0 12htools-test 1/1 1 1 12h2.为我们创建了一个Service,所有的SVC都是要注册到isto-ingressgateway上面的。它提供了一个外部访问入口和一个集群内部的访问入口;Knative只需要某种入口网关的功能,而不需要网格功能;
[root@knative-k8s-master-139 ~]# kubectl get svchelloworld-example ExternalName knative-local-gateway.istio-system.svc.cluster.local 80/TCP 3.我们为什么看不见创建的Pod呢?因为在没有人访问的情况下,Pod是无法启动会被置为0的状态;这就是Knative的KPA,Pod缩放至0;
[root@knative-k8s-master-139 ~]# kubectl get podsNAME READY STATUS RESTARTS AGEtools-test-8444596cb5-rvpf9 1/1 Running 0 12h1.我们启动一个终端访问这个Service是没有问题的;
[root@tools-test-8444596cb5-rvpf9 /]# curl helloworld-example.default.svcHello World![root@tools-test-8444596cb5-rvpf9 /]# while true; do curl --connect-timeout 1 helloworld-example.default; sleep .2; doneHello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!2.我们观察Pod的状态与deploy的状态,当我们持续访问的时候,Pod是会被拉起的;
[root@knative-k8s-master-139 ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEhelloworld-example-00001-deployment 1/1 1 1 12htools-test 1/1 1 1 12h[root@knative-k8s-master-139 ~]# kubectl get podshelloworld-example-00001-deployment-7787f5cf4f-rfwhb 2/2 Running 0 12stools-test-8444596cb5-rvpf9 1/1 Running 0 12h我们一直奔跑在进步的旅途
文章来自https://www.cnblogs.com/xunweidezui/p/16551412.html
| 留言与评论(共有 0 条评论) “” |