Serverless之knative1.6安装(一)
1.安装Knative-Serving;
# 安装knative的CRD资源
[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
2.通过apiresources来查看;
[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
3.安装Knative-Serving镜像等等;
[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
4.查看镜像是否安装成功;已经安装成功;
[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
5.安装网络插件;
这里选择Istio来作为knative的网关,Knative不再强依赖于Istio,但是knative仍然倾向使用Istio。但是已经不是强依赖,因为Istio带有许多Knative不使用的功能,特别的是,Knative只需要某种入口网关的功能,而不需要网格功能,例如故障注入或自动重试。
当然也可以使用Kourier,Kourier是专门为knative开发的,除此之外,网关还有其他构建和测试的替代方案(Contour、Ambassador、Kong和Gloo)
[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 52m
6.查看我们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
7.安装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)
8.随后就可以使用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
我们一直奔跑在进步的旅途