02-knative-serving部署
2023-12-20 03:22:37
- 示例环境
- Kubernetes: v1.27.1
- Knative: v1.12
- networking layer: istio
- 可用的部署方式
- 基于YAML配置文档直接部署
- Serving和Eventing需要分别进行部署
- 借助Knative Operator进行部署
- 首先部署Knative Operator
- 通过Operator的KnativeServing部署Serving
- 通过Operator的KnativeEventing资源部署Eventing
- 基于YAML配置文档直接部署
- 需要部署的Knative组件
- Serving
- Eventing
- kn
1.1 部署serving
-
环境要求
- For prototyping purposes
- 单节点的Kubernetes集群,有2个可用的CPU核心,以及4g内存;
- For production purposes
- 单节点的Kubernetes集群,需要至少有6个CPU核心、6G内存和30G磁盘空间
- 多节点的Kubernetes集群中,每个节点至少有2个CPU核心,4G内存和20G磁盘空间
- Kubernetes版本最低为v1.26
- For prototyping purposes
-
安装步骤
- 部署Serving核心组件
- 部署网络层(networking layer)组件
- Istio、Contour、Kourier三选一
- (可选)配置DNS
- (可选) 部署Serving扩展
- HPA:用于支持Kubernetes的HPA
- Cert Manager:用于为工作负载自动签发TLS证书
- Encrypt HTTP01:用于为工作负载自动签发TLS证书
-
以YAML文件进行Serving部署
-
参考官方文档:https://knative.dev/docs/install/yaml-install/serving/install-serving-with-yaml/
-
部署serving的crd:
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.12.0/serving-crds.yaml
-
部署serving核心组件
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.12.0/serving-core.yaml
-
安装 a networking layer(这里以istio为例)
kubectl apply -l knative.dev/crd-install=true -f https://github.com/knative/net-istio/releases/download/knative-v1.12.0/istio.yaml kubectl apply -f https://github.com/knative/net-istio/releases/download/knative-v1.12.0/istio.yaml kubectl apply -f https://github.com/knative/net-istio/releases/download/knative-v1.12.0/net-istio.yaml kubectl --namespace istio-system get service istio-ingressgateway
-
配置DNS,因为我们是测试环境,所以选择"no dns",来配置,可以从集群外部访问的域名
kubectl patch configmap/config-domain \ --namespace knative-serving \ --type merge \ --patch '{"data":{"example.com":""}}'
-
安装HPA控制器
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.12.0/serving-hpa.yaml
-
安装kn
wget https://github.com/knative/client/releases/download/knative-v1.11.2/kn-linux-amd64 cp kn-linux-amd64 /usr/local/bin/kn chmod +x /usr/local/bin/kn
-
确认下载成功
root@k-master01:~# kubectl get pods -n knative-serving NAME READY STATUS RESTARTS AGE activator-58b9474547-7nnh6 1/1 Running 0 18m autoscaler-c88f8c8dc-zfvjv 1/1 Running 0 18m autoscaler-hpa-5877fb58d6-84m5j 1/1 Running 0 64s controller-84cd85bcc-wg9q8 1/1 Running 0 18m net-istio-controller-79f97565f4-dc6m8 1/1 Running 0 2m34s net-istio-webhook-f7c89b4fd-jwcqs 1/1 Running 0 2m34s webhook-6bbbc5867c-dw7vs 1/1 Running 0 18m
root@k-master01:~# kubectl get pods -n istio-system NAME READY STATUS RESTARTS AGE istio-ingressgateway-584c594ff8-2f8mg 1/1 Running 0 5m2s istio-ingressgateway-584c594ff8-7clr9 1/1 Running 0 5m2s istio-ingressgateway-584c594ff8-w7tq5 1/1 Running 0 5m2s istiod-78c4f7f756-kv4mh 1/1 Running 0 5m2s istiod-78c4f7f756-kxbjw 1/1 Running 0 4m47s istiod-78c4f7f756-pldrm 1/1 Running 0 4m47s
-
暴露istio-ingressgateway
给node01上邦一个ip地址:
ip addr add 192.168.58.100/24 dev ens33
kubectl edit svc istio-ingressgateway -n istio-system
-
-
运行一个demo的service
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 spec: containers: #- image: gcr.io/knative-samples/helloworld-go - image: ikubernetes/helloworld-go ports: - containerPort: 8080 env: - name: TARGET value: "World"
测试请求
kubectl get ksvc
本机测试:
curl -H "Host: hello.default.example.com" 192.168.58.100 Hello World!
文章来源:https://blog.csdn.net/weixin_38753143/article/details/135068192
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!