0
点赞
收藏
分享

微信扫一扫

Serverless之Knative1.6安装(二)

官方部署文档: https://knative.dev/v1.6-docs/install/yaml-install/serving/install-serving-with-yaml/#prerequisites GitHub地址: https://github.com/knative/docs 在安装Knative之前,必须有一个K8s集群且版本是在1.22以上。否则无法安装knative。Knative最新版本为1.17 Knative 适用于 Kubernetes 的大多数本地部署。例如,您可以使用具有 3 个 CPU 和 4 GB 内存的本地单节点集群。 出于生产目的,建议:

  1. 如果集群中只有一个节点,则至少需要 6 个 CPU、6 GB 内存和 30 GB 磁盘存储。
  2. 如果集群中有多个节点,则每个节点至少需要 2 个 CPU、4 GB 内存和 20 GB 磁盘存储。
  3. 您有一个使用 Kubernetes v1.22 或更高版本的集群。

1.安装Knative Serving

1.1安装Knative所需要的CRD资源

可以通过wget下载yaml配置文件到本地。

wget https://github.com/knative/serving/releases/download/knative-v1.6.0/serving-crds.yaml

apply执行yaml文件
[root@knative-k8s-master-139 serving]# kubectl apply -f serving-crds.yaml
customresourcedefinition.apiextensions.k8s.io/certificates.networking.internal.knative.dev created
customresourcedefinition.apiextensions.k8s.io/configurations.serving.knative.dev created
customresourcedefinition.apiextensions.k8s.io/clusterdomainclaims.networking.internal.knative.dev created
customresourcedefinition.apiextensions.k8s.io/domainmappings.serving.knative.dev created
customresourcedefinition.apiextensions.k8s.io/ingresses.networking.internal.knative.dev created
customresourcedefinition.apiextensions.k8s.io/metrics.autoscaling.internal.knative.dev created
customresourcedefinition.apiextensions.k8s.io/podautoscalers.autoscaling.internal.knative.dev created
customresourcedefinition.apiextensions.k8s.io/revisions.serving.knative.dev created
customresourcedefinition.apiextensions.k8s.io/routes.serving.knative.dev created
customresourcedefinition.apiextensions.k8s.io/serverlessservices.networking.internal.knative.dev created
customresourcedefinition.apiextensions.k8s.io/services.serving.knative.dev created
customresourcedefinition.apiextensions.k8s.io/images.caching.internal.knative.dev created

可以通过apiresources来查看安装的CRD资源

[root@knative-k8s-master-139 serving]# kubectl api-resources | grep "knative"
metrics                                           autoscaling.internal.knative.dev/v1alpha1   true         Metric
podautoscalers                    kpa,pa          autoscaling.internal.knative.dev/v1alpha1   true         PodAutoscaler
images                            img             caching.internal.knative.dev/v1alpha1       true         Image
certificates                      kcert           networking.internal.knative.dev/v1alpha1    true         Certificate
clusterdomainclaims               cdc             networking.internal.knative.dev/v1alpha1    false        ClusterDomainClaim
ingresses                         kingress,king   networking.internal.knative.dev/v1alpha1    true         Ingress
serverlessservices                sks             networking.internal.knative.dev/v1alpha1    true         ServerlessService
configurations                    config,cfg      serving.knative.dev/v1                      true         Configuration
domainmappings                    dm              serving.knative.dev/v1beta1                 true         DomainMapping
revisions                         rev             serving.knative.dev/v1                      true         Revision
routes                            rt              serving.knative.dev/v1                      true         Route
services                          kservice,ksvc   serving.knative.dev/v1                      true         Service

1.2安装Knative的核心资源

namespace、rbac、configmap、deployment等等。

[root@knative-k8s-master-139 serving]# kubectl apply -f serving-core.yaml 
namespace/knative-serving created
clusterrole.rbac.authorization.k8s.io/knative-serving-aggregated-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/knative-serving-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/knative-serving-namespaced-admin created
clusterrole.rbac.authorization.k8s.io/knative-serving-namespaced-edit created
clusterrole.rbac.authorization.k8s.io/knative-serving-namespaced-view created
clusterrole.rbac.authorization.k8s.io/knative-serving-core created
clusterrole.rbac.authorization.k8s.io/knative-serving-podspecable-binding created
serviceaccount/controller created
clusterrole.rbac.authorization.k8s.io/knative-serving-admin created
clusterrolebinding.rbac.authorization.k8s.io/knative-serving-controller-admin created
clusterrolebinding.rbac.authorization.k8s.io/knative-serving-controller-addressable-resolver created
customresourcedefinition.apiextensions.k8s.io/images.caching.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/certificates.networking.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/configurations.serving.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/clusterdomainclaims.networking.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/domainmappings.serving.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/ingresses.networking.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/metrics.autoscaling.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/podautoscalers.autoscaling.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/revisions.serving.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/routes.serving.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/serverlessservices.networking.internal.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/services.serving.knative.dev unchanged
image.caching.internal.knative.dev/queue-proxy created
configmap/config-autoscaler created
configmap/config-defaults created
configmap/config-deployment created
configmap/config-domain created
configmap/config-features created
configmap/config-gc created
configmap/config-leader-election created
configmap/config-logging created
configmap/config-network created
configmap/config-observability created
configmap/config-tracing created
horizontalpodautoscaler.autoscaling/activator created
poddisruptionbudget.policy/activator-pdb created
deployment.apps/activator created
service/activator-service created
deployment.apps/autoscaler created
service/autoscaler created
deployment.apps/controller created
service/controller created
deployment.apps/domain-mapping created
deployment.apps/domainmapping-webhook created
service/domainmapping-webhook created
horizontalpodautoscaler.autoscaling/webhook created
poddisruptionbudget.policy/webhook-pdb created
deployment.apps/webhook created
service/webhook created
validatingwebhookconfiguration.admissionregistration.k8s.io/config.webhook.serving.knative.dev created
mutatingwebhookconfiguration.admissionregistration.k8s.io/webhook.serving.knative.dev created
mutatingwebhookconfiguration.admissionregistration.k8s.io/webhook.domainmapping.serving.knative.dev created
secret/domainmapping-webhook-certs created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.domainmapping.serving.knative.dev created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.serving.knative.dev created
secret/webhook-certs created

查看镜像是否安装成功;

[root@knative-k8s-master-139 serving-1.6]# kubectl get pods -n knative-serving
NAME                                     READY   STATUS    RESTARTS   AGE
activator-5f9df88fbb-n2rs2               1/1     Running   0          54m
autoscaler-c7d7bd5f-64pwz                1/1     Running   0          54m
controller-5f64fb5c49-xc5rc              1/1     Running   0          54m
domain-mapping-7499d44b7f-d4tmm          1/1     Running   0          54m
domainmapping-webhook-695848595b-82vts   1/1     Running   0          54m
net-istio-controller-c67797bd5-fw5h4     1/1     Running   0          47m
net-istio-webhook-588f859479-qrgzd       1/1     Running   0          47m
webhook-79d8bd799d-9w7pk                 1/1     Running   0          54m

1.3安装Knative所需网络插件;

这里选择Istio来作为Knative的网关;

[root@knative-k8s-master-139 serving-1.6]# kubectl apply -l knative.dev/crd-install=true -f https://github.com/knative/net-istio/releases/download/knative-v1.6.0/istio.yaml
[root@knative-k8s-master-139 serving-1.6]# kubectl apply -f https://github.com/knative/net-istio/releases/download/knative-v1.6.0/istio.yaml
[root@knative-k8s-master-139 serving-1.6]# kubectl apply -f https://github.com/knative/net-istio/releases/download/knative-v1.6.0/net-istio.yaml

查看istio-gateway网关 istio-ingressgateway用于在集群内部通讯; knative-local-gateway用于在集群内部进行通讯;

[root@knative-k8s-master-139 serving-1.6]# kubectl get svc -n istio-system
NAME                    TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)                                      AGE
istio-ingressgateway    LoadBalancer   10.96.173.xx   10.0.0.xx    15021:32062/TCP,80:30909/TCP,443:32520/TCP   53m
istiod                  ClusterIP      10.96.5.xx    <none>        15010/TCP,15012/TCP,443/TCP,15014/TCP        53m
knative-local-gateway   ClusterIP      10.96.28.xx   <none>        80/TCP  

查看istio名称空间中Pod的安装情况

[root@knative-k8s-master-139 serving-1.6]# kubectl get pods -n istio-system
NAME                                    READY   STATUS    RESTARTS   AGE
istio-ingressgateway-56dd774fd8-dv8vr   1/1     Running   0          49m
istio-ingressgateway-56dd774fd8-rrznb   1/1     Running   0          49m
istio-ingressgateway-56dd774fd8-zrxqp   1/1     Running   0          49m
istiod-744456f967-5786m                 1/1     Running   0          48m
istiod-744456f967-jls7f                 1/1     Running   0          49m
istiod-744456f967-stswh                 1/1     Running   0          48m

1.4安装Knative的CLI

官方文档: https://knative.dev/docs/client/install-kn/#install-kn-using-the-nightly-built-binary GitHub下载地址: https://github.com/knative/client/releases/download/knative-v1.6.0/kn-linux-amd64

[root@knative-k8s-master-139 bin]# wget https://github.com/knative/client/releases/download/knative-v1.6.0/kn-linux-amd64

# 复制到/usr/local/bin/;
[root@knative-k8s-master-139 ~]# cp kn-linux-amd64  /usr/local/bin/kn
# 赋予执行权限;
[root@knative-k8s-master-139 ~]# chmod +x /usr/local/bin/kn 
# 查看knative版本;
[root@knative-k8s-master-139 ~]# kn version
Version:      v20220713-local-bfdc0a21
Build Date:   2022-07-13 09:04:48
Git Revision: bfdc0a21
Supported APIs:
* Serving
  - serving.knative.dev/v1 (knative-serving v0.33.0)
* Eventing
  - sources.knative.dev/v1 (knative-eventing v0.33.0)
  - eventing.knative.dev/v1 (knative-eventing v0.33.0)

1.5随后就可以使用Knative Serving了;

[root@knative-k8s-master-139 ~]# kn --help
kn is the command line interface for managing Knative Serving and Eventing resources

Find more information about Knative at: https://knative.dev

Serving Commands:
  service      Manage Knative services
  revision     Manage service revisions
  route        List and describe service routes
  domain       Manage domain mappings
  container    Manage service's containers (experimental)

Eventing Commands:
  source       Manage event sources
  broker       Manage message brokers
  trigger      Manage event triggers
  channel      Manage event channels
  subscription Manage event subscriptions
  eventtype    Manage eventtypes

Other Commands:
  plugin       Manage kn plugins
  completion   Output shell completion code
  version      Show the version of this client
举报

相关推荐

0 条评论