应用创建
创建和使用Knative Service资源方式有两种:
kn service
资源配置文件
群组:serving.knative.dev/v1
template
traffic 用于创建或更新Route对像
命令行创建
[root@ip-172-17-11-227 bin]# kn service create demoapp --image=ikubernetes/demoapp:v1.0
Warning: Kubernetes default value is insecure, Knative may default this to secure in a future release: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation, spec.template.spec.containers[0].securityContext.capabilities, spec.template.spec.containers[0].securityContext.runAsNonRoot, spec.template.spec.containers[0].securityContext.seccompProfile
Creating service 'demoapp' in namespace 'default':
0.058s The Route is still working to reflect the latest desired specification.
0.073s Configuration "demoapp" is waiting for a Revision to become ready.
7.785s ...
7.834s Ingress has not yet been reconciled.
7.949s Ready to serve.
Service 'demoapp' created to latest revision 'demoapp-00001' is available at URL:
http://demoapp.default.svc.cluster.local # 集群内部访问地址
查看configuration
[root@ip-172-17-11-227 ~]# kubectl get configuration
NAME LATESTCREATED LATESTREADY READY REASON
demoapp demoapp-00001 demoapp-00001 True
查看revision
[root@ip-172-17-11-227 ~]# kubectl get revision
NAME CONFIG NAME K8S SERVICE NAME GENERATION READY REASON ACTUAL REPLICAS DESIRED REPLICAS
demoapp-00001 demoapp 1 True 0 0
查看route
[root@ip-172-17-11-227 ~]# kubectl get route
NAM服务器托管网E URL READY REASON
demoapp http://demoapp.default.yht.com True
查看kpa
[root@ip-172-17-11-227 ~]# kubectl get kpa
NAME DESIREDSCALE ACTUALSCALE READY REASON
demoapp-00001 0 0 False NoTraffic
查看vs
服务外部访问由knative-ingress-gateway负责
服务内部访问:如果istio注入了sidcar功能,则由mesh负责,否则则由knative-local-gateway则责管理
[root@ip-172-17-11-227 ~]# kubectl get vs
NAME GATEWAYS HOSTS AGE
demoapp-ingress ["knative-serving/knative-ingress-gateway","knative-serving/knative-local-gateway"] ["demoapp.default","demoapp.default.yht.com","demoapp.default.svc","demoapp.default.svc.cluster.local"] 3h37m
demoapp-mesh ["mesh"]
查看ksvc
[root@ip-172-17-11-227 ~]# kubectl get ksvc
NAME URL LATESTCREATED LATESTREADY READY REASON
demoapp http://demoapp.default.yht.com demoapp-00001 demoapp-00001 True
[root@ip-172-17-11-227 ~]#
查看deployment
[root@ip-172-17-11-227 ~]# kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
demoapp-00001-deployment 0/0 0 0 6h4m
[root@ip-172-17-11-227 ~]#
查看svc
[root@ip-172-17-11-227 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
demoapp ExternalName knative-local-gateway.istio-system.svc.cluster.local 80/TCP 6h4m
demoapp-00001 ClusterIP 10.100.82.54 80/TCP,443/TCP 6h4m
demoapp-00001-private ClusterIP 10.100.19.175 80/TCP,443/TCP,9090/TCP,9091/TCP,8022/TCP,8012/TCP 6h4m
kubernetes ClusterIP 10.100.0.1
[root@ip-172-17-11-227 ~]# kn service list
NAME URL LATEST AGE CONDITIONS READY REASON
demoapp http://demoapp.default.yht.com demoapp-00001 20h 3 OK / 3 True
Yaml创建
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
spec:
template:
metadata:
# This is the name of our new "Revision," it must follow the convention {service-name}-{revision-name}
name: hello-world # 这个是revision名字
spec:
containers:
#- image: gcr.io/knative-samples/helloworld-go
- image: ikubern服务器托管网etes/helloworld-go
ports:
- containerPort: 8080
env:
- name: TARGET
value: "World"
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net