社区版部署环境准备
事先准备Kubernetes集群用于部署knative
选定isitio用来路由和治理流量
需要部署的Knative组件
Serving
Eventing
Kn(Knative CLI)
环境要求
单节点的Kubernetes集群,需要至少有6个CPU核心,6G内存和30G磁盘空间
多节点的Kubernetes集群,每个节点至少有2个CPU核心,4G内存和20G磁盘空间
安装步骤
- 部署Serving核心组件
- 部署网络层(Networking layer)组件Istio
部署knative
部署CRD
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.11.1/serving-crds.yaml
查看CRD
kubectl api-versions
kubectl api-resources --api-group=serving.knative.dev
部署核心组件
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.11.1/serving-core.yaml
查看资源
[root@ip-172-17-11-227 ~]# kubectl get deploy -n knative-serving
NAME READY UP-TO-DATE AVAILABLE AGE
activator 1/1 1 1 37s 激活器,支持pod缩减至0用到的组件
autoscaler 1/1 1 1 37s 扩缩容组件KPA
controller 1/1 1 1 37s 支持CRD运行的关键组件
webhook 1/1 1 1 37s
部署istio
将拥有标签的资源先创建出来
kubectl apply -l knative.dev/crd-install=true -f https://github.com/knative/net-istio/releases/download/knative-v1.11.0/istio.yaml
部署整个清单资源的所有资源
kubectl apply -f https://github.com/knative/net-istio/releases/download/knative-v1.11.0/istio.yaml
查看命名空间
kubectl get ns | grep istio-system
查看pod
[root@ip-172-17-11-227 ~]# kubectl get pods -n istio-system
NAME READY STATUS RESTARTS AGE
istio-ingressgateway-6bd6df57b4-lqjh9 1/1 Running 0 102s
istio-ingressgateway-6bd6df57b4-scksb 1/1 Running 0 102s
istio-ingressgateway-6bd6df57b4-vg6kz 1/1 Running 0 102s
istiod-5f859db56c-dzf8k 1/1 Running 0 102s
istiod-5f859db56c-ln7sz 1/1 Running 0 86s
istiod-5f859db56c-z4k87 0/1 Pending 0 86s
部署net-istio
kubectl apply -f https://github.com/knative/net-istio/releases/download/knative-v1.11.0/net-istio.yaml
查看已爆露网格外部IP
[root@ip-172-17-11-227 ~]# kubectl --namespace istio-system get service istio-ingressgateway
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.100.187.5 wqrqrqrqr464wr46463w131-123456789.us-west-2.elb.amazonaws.com 15021:31018/TCP,80:32413/TCP,443:32187/TCP 12m
验证安装
可以看到多了两个pod
[root@ip-172-17-11-227 ~]# kubectl --namespace knative-serving get pods
NAME READY STATUS RESTARTS AGE
activator-7f784dcbf6-sqmnq 1/1 Running 0 28m
autoscaler-598c8cfdcd-j25x8 1/1 Running 0 28m
controller-965f89bb8-h2k6p 1/1 Running 0 28m
net-istio-controller-85bcc98664-b7grp 1/1 Running 0 3m47s
net-istio-webhook-94698797b-qc6wg 1/1 Running 0 3m47s
webhook-67c799bbb6-jbvr5 1/1 Running 0 28m
查看访问入口
[root@ip-172-17-11-227 ~]# kubectl get svc -n istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.100.187.5 asfwqr465466werq3464wqr43434-12345678.us-west-2.elb.amazonaws.com 15021:31018/TCP,80:32413/TCP,443:32187/TCP 21m
istiod ClusterIP 10.100.122.84 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 21m
knative-local-gateway ClusterIP 10.100.184.87 <none> 80/TCP 10m
部署Knative CLI
curl -Lo https://storage.googleapis.com/knative-nightly/client/latest/kn-linux-amd64 /usr/bin/kn
chmod +x /usr/bin/kn
kn service apply --help