Knative Event v1.11.4 部署

部署 Knative  Event  CRD

# kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.11.4/eventing-crds.yaml
customresourcedefinition.apiextensions.k8s.io/apiserversources.sources.knative.dev created
customresourcedefinition.apiextensions.k8s.io/brokers.eventing.knative.dev created
customresourcedefinition.apiextensions.k8s.io/channels.messaging.knative.dev created
customresourcedefinition.apiextensions.k8s.io/containersources.sources.knative.dev created
customresourcedefinition.apiextensions.k8s.io/eventtypes.eventing.knative.dev created
customresourcedefinition.apiextensions.k8s.io/parallels.flows.knative.dev created
customresourcedefinition.apiextensions.k8s.io/pingsources.sources.knative.dev created
customresourcedefinition.apiextensions.k8s.io/sequences.flows.knative.dev created
customresourcedefinition.apiextensions.k8s.io/sinkbindings.sources.knative.dev created
customresourcedefinition.apiextensions.k8s.io/subscriptions.messaging.knative.dev created
customresourcedefinition.apiextensions.k8s.io/triggers.eventing.knative.dev created

部署 Knative  Event 核心组件

下载 Knative  Event 核心组件

# wget https://github.com/knative/eventing/releases/download/knative-v1.11.4/eventing-core.yaml

替换 gcr.io

# sed -i 's@gcr.io@gcr.dockerproxy.com@g' eventing-core.yaml

部署 Knative  Event 核心组件

# kubectl apply -f eventing-core.yaml 
namespace/knative-eventing created
serviceaccount/eventing-controller created
clusterrolebinding.rbac.authorization.k8s.io/eventing-controller created
clusterrolebinding.rbac.authorization.k8s.io/eventing-controller-resolver created
clusterrolebinding.rbac.authorization.k8s.io/eventing-controller-source-observer created
clusterrolebinding.rbac.authorization.k8s.io/eventing-controller-sources-controller created
clusterrolebinding.rbac.authorization.k8s.io/eventing-controller-manipulator created
serviceaccount/pingsource-mt-adapter created
clusterrolebinding.rbac.authorization.k8s.io/knative-eventing-pingsource-mt-adapter created
serviceaccount/eventing-webhook created
clusterrolebinding.rbac.authorization.k8s.io/eventing-webhook created
rolebinding.rbac.authorization.k8s.io/eventing-webhook created
clusterrolebinding.rbac.authorization.k8s.io/eventing-webhook-resolver created
clusterrolebinding.rbac.authorization.k8s.io/eventing-webhook-podspecable-binding created
configmap/config-br-default-channel created
configmap/config-br-defaults created
configmap/default-ch-webhook created
configmap/config-ping-defaults created
configmap/config-features created
configmap/config-kreference-mapping created
configmap/config-leader-election created
configmap/config-logging created
configmap/config-observability created
configmap/config-sugar created
configmap/config-tracing created
deployment.apps/eventing-controller created
deployment.apps/pingsource-mt-adapter created
horizontalpodautoscaler.autoscaling/eventing-webhook created
poddisruptionbudget.policy/eventing-webhook created
deployment.apps/eventing-webhook created
service/eventing-webhook created
customresourcedefinition.apiextensions.k8s.io/apiserversources.sources.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/brokers.eventing.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/channels.messaging.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/containersources.sources.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/eventtypes.eventing.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/parallels.flows.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/pingsources.sources.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/sequences.flows.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/sinkbindings.sources.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/subscriptions.messaging.knative.dev unchanged
customresourcedefinition.apiextensions.k8s.io/triggers.eventing.knative.dev unchanged
clusterrole.rbac.authorization.k8s.io/addressable-resolver created
clusterrole.rbac.authorization.k8s.io/service-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/serving-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/channel-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/broker-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/flows-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/eventing-broker-filter created
clusterrole.rbac.authorization.k8s.io/eventing-broker-ingress created
clusterrole.rbac.authorization.k8s.io/eventing-config-reader created
clusterrole.rbac.authorization.k8s.io/channelable-manipulator created
clusterrole.rbac.authorization.k8s.io/meta-channelable-manipulator created
clusterrole.rbac.authorization.k8s.io/knative-eventing-namespaced-admin created
clusterrole.rbac.authorization.k8s.io/knative-messaging-namespaced-admin created
clusterrole.rbac.authorization.k8s.io/knative-flows-namespaced-admin created
clusterrole.rbac.authorization.k8s.io/knative-sources-namespaced-admin created
clusterrole.rbac.authorization.k8s.io/knative-bindings-namespaced-admin created
clusterrole.rbac.authorization.k8s.io/knative-eventing-namespaced-edit created
clusterrole.rbac.authorization.k8s.io/knative-eventing-namespaced-view created
clusterrole.rbac.authorization.k8s.io/knative-eventing-controller created
clusterrole.rbac.authorization.k8s.io/knative-eventing-pingsource-mt-adapter created
clusterrole.rbac.authorization.k8s.io/podspecable-binding created
clusterrole.rbac.authorization.k8s.io/builtin-podspecable-binding created
clusterrole.rbac.authorization.k8s.io/source-observer created
clusterrole.rbac.authorization.k8s.io/eventing-sources-source-observer created
clusterrole.rbac.authorization.k8s.io/knative-eventing-sources-controller created
clusterrole.rbac.authorization.k8s.io/knative-eventing-webhook created
role.rbac.authorization.k8s.io/knative-eventing-webhook created
validatingwebhookconfiguration.admissionregistration.k8s.io/config.webhook.eventing.knative.dev created
mutatingwebhookconfiguration.admissionregistration.k8s.io/webhook.eventing.knative.dev created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.eventing.knative.dev created
secret/eventing-webhook-certs created
mutatingwebhookconfiguration.admissionregistration.k8s.io/sinkbindings.webhook.sources.knative.dev created

查看 Knative  Event 资源

# kubectl get pods -n knative-eventing
NAME                                  READY   STATUS    RESTARTS   AGE
eventing-controller-745ffc85b-dqdwz   1/1     Running   0          3m47s
eventing-webhook-cd8b78bd8-pwnz7      1/1     Running   0          3m46s

部署 eventing-kafka-controller

下载 eventing-kafka-controller.yaml

# wget https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.11.4/eventing-kafka-controller.yaml

替换 gcr.io 地址

# sed -i 's@gcr.io@gcr.dockerproxy.com@g' eventing-kafka-controller.yaml

安装 eventing Kafka controller

# kubectl apply -f eventing-kafka-controller.yaml
configmap/kafka-broker-config created
configmap/kafka-channel-config created
customresourcedefinition.apiextensions.k8s.io/kafkachannels.messaging.knative.dev created
customresourcedefinition.apiextensions.k8s.io/consumers.internal.kafka.eventing.knative.dev created
customresourcedefinition.apiextensions.k8s.io/consumergroups.internal.kafka.eventing.knative.dev created
customresourcedefinition.apiextensions.k8s.io/kafkasinks.eventing.knative.dev created
customresourcedefinition.apiextensions.k8s.io/kafkasources.sources.knative.dev created
clusterrole.rbac.authorization.k8s.io/eventing-kafka-source-observer created
configmap/config-kafka-source-defaults created
configmap/config-kafka-autoscaler created
configmap/config-kafka-descheduler created
configmap/config-kafka-features created
configmap/config-kafka-leader-election created
configmap/config-kafka-scheduler created
configmap/kafka-config-logging created
configmap/config-namespaced-broker-resources created
configmap/config-tracing configured
clusterrole.rbac.authorization.k8s.io/knative-kafka-addressable-resolver created
clusterrole.rbac.authorization.k8s.io/knative-kafka-channelable-manipulator created
clusterrole.rbac.authorization.k8s.io/kafka-controller created
serviceaccount/kafka-controller created
clusterrolebinding.rbac.authorization.k8s.io/kafka-controller created
clusterrolebinding.rbac.authorization.k8s.io/kafka-controller-addressable-resolver created
deployment.apps/kafka-controller created
clusterrole.rbac.authorization.k8s.io/kafka-webhook-eventing created
serviceaccount/kafka-webhook-eventing created
clusterrolebinding.rbac.authorization.k8s.io/kafka-webhook-eventing created
mutatingwebhookconfiguration.admissionregistration.k8s.io/defaulting.webhook.kafka.eventing.knative.dev created
mutatingwebhookconfiguration.admissionregistration.k8s.io/pods.defaulting.webhook.kafka.eventing.knative.dev created
secret/kafka-webhook-eventing-certs created
validatingwebhookconfiguration.admissionregistration.k8s.io/validation.webhook.kafka.eventing.knative.dev created
deployment.apps/kafka-webhook-eventing created
service/kafka-webhook-eventing created

下载 eventing-kafka-channel.yaml

# wget https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.11.4/eventing-kafka-channel.yaml

替换 gcr.io 地址

# sed -i 's@gcr.io@gcr.dockerproxy.com@g' eventing-kafka-channel.yaml

部署 eventing-kafka-channel

# kubectl apply -f eventing-kafka-channel.yaml
configmap/config-kafka-channel-data-plane created
clusterrole.rbac.authorization.k8s.io/knative-kafka-channel-data-plane created
serviceaccount/knative-kafka-channel-data-plane created
clusterrolebinding.rbac.authorization.k8s.io/knative-kafka-channel-data-plane created
deployment.apps/kafka-channel-dispatcher created
deployment.apps/kafka-channel-receiver created
service/kafka-channel-ingress created

查看资源

# kubectl get pods -n knative-eventing
NAME                                        READY   STATUS    RESTARTS   AGE
eventing-controller-745ffc85b-7v2jz         1/1     Running   0          2m22s
eventing-webhook-cd8b78bd8-pwtff            1/1     Running   0          2m22s
kafka-channel-dispatcher-7d488674cd-hfxkg   1/1     Running   0          30s
kafka-channel-receiver-bc8dc45b6-cqncx      1/1     Running   0          29s
kafka-controller-7cfdd9bb48-76m2d           1/1     Running   0          30s
kafka-webhook-eventing-5d94d64689-vl6xn     1/1     Running   0          30s

查看 kafka-channel api

# kubectl api-resources |grep channel
channels                          ch                                              messaging.knative.dev/v1                       true         Channel
inmemorychannels                  imc                                             messaging.knative.dev/v1                       true         InMemoryChannel
kafkachannels                     kc                                              messaging.knative.dev/v1beta1                  true         KafkaChannel

配置 KafkaChannel 为默认 channel

查看 KafkaChannel group 信息

# kubectl explain KafkaChannel
GROUP:      messaging.knative.dev
KIND:       KafkaChannel
VERSION:    v1beta1

...

default-channel-config.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: default-ch-webhook
  namespace: knative-eventing
  labels:
    eventing.knative.dev/release: devel
    app.kubernetes.io/version: devel
    app.kubernetes.io/part-of: knative-eventing
data:
  default-ch-config: |
    clusterDefault:
      apiVersion: messaging.knative.dev/v1
      kind: InMemoryChannel
    namespaceDefaults:
      default:               # 按需指定名称空间
        apiVersion: messaging.knative.dev/v1beta1
        kind: KafkaChannel
        spec:
          numPartitions: 5               # 在Topic上默认使用的partition的数量,默认为1;
          replicationFactor: 1           # 在Topic上默认使用的复制因子,其值不能大于Kafka上的broker数量,即可用节点数,默认值为1;

创建 default-channel

# kubectl apply -f default-channel-config.yaml
configmap/default-ch-webhook configured

Apache Kafka Broker 强依赖 Apache Kafka Channel

下载 eventing-kafka-broker.yaml

# wget https://github.com/knative-extensions/eventing-kafka-broker/releases/download/knative-v1.11.4/eventing-kafka-broker.yaml

替换 gcr.io 地址

# sed -i 's@gcr.io@gcr.dockerproxy.com@g' eventing-kafka-broker.yaml

部署 eventing-kafka-broker

# kubectl apply -f eventing-kafka-broker.yaml
configmap/config-kafka-broker-data-plane created
clusterrole.rbac.authorization.k8s.io/knative-kafka-broker-data-plane created
serviceaccount/knative-kafka-broker-data-plane created
clusterrolebinding.rbac.authorization.k8s.io/knative-kafka-broker-data-plane created
deployment.apps/kafka-broker-dispatcher created
deployment.apps/kafka-broker-receiver created
service/kafka-broker-ingress created

查看资源

# kubectl get pods -n knative-eventing
NAME                                        READY   STATUS    RESTARTS   AGE
eventing-controller-745ffc85b-7v2jz         1/1     Running   0          3m45s
eventing-webhook-cd8b78bd8-pwtff            1/1     Running   0          3m45s
kafka-broker-dispatcher-58c684b5d9-rmhfj    1/1     Running   0          60s
kafka-broker-receiver-779ffbdb45-b6ht6      1/1     Running   0          60s
kafka-channel-dispatcher-7d488674cd-hfxkg   1/1     Running   0          113s
kafka-channel-receiver-bc8dc45b6-cqncx      1/1     Running   0          112s
kafka-controller-7cfdd9bb48-76m2d           1/1     Running   0          113s
kafka-webhook-eventing-5d94d64689-vl6xn     1/1     Running   0          113s

配置 kafka broker

configmap-kafka-broker-config.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: kafka-broker-config
  namespace: knative-eventing
data:
  # Number of topic partitions
  default.topic.partitions: "10"  # 在Topic上默认使用的partition的数量
  # Replication factor of topic messages.
  default.topic.replication.factor: "1"  # 在Topic上默认使用的复制因子,其值不能大于Kafka上的broker数量,即可用节点数
  # A comma separated list of bootstrap servers. (It can be in or out the k8s cluster)
  bootstrap.servers: "my-cluster-kafka-bootstrap.kafka:9092"   # 即Kafka集群的Bootstrap Server的访问入口

更新 kafka broker 配置

# kubectl apply -f configmap-kafka-broker-config.yaml
configmap/kafka-broker-config configured

配置 kafka broker 为默认的broker

configmap-default-br-config.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: config-br-defaults
  namespace: knative-eventing
data:
  default-br-config: |
    clusterDefault:
      brokerClass: MTChannelBasedBroker
      apiVersion: v1
      kind: ConfigMap
      name: config-br-default-channel
      namespace: knative-eventing
      delivery:
        retry: 10
        backoffPolicy: exponential
        backoffDelay: PT0.2S
    namespaceDefaults:
      default:
        brokerClass: Kafka
        apiVersion: v1
        kind: ConfigMap
        name: kafka-broker-config
        namespace: knative-eventing

更新默认 broker 类型配置

# kubectl apply -f configmap-default-br-config.yaml
configmap/config-br-defaults configured

配置 config-br-default-channel

config-br-default-channel.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/name: knative-eventing
    app.kubernetes.io/version: 1.11.4
  name: config-br-default-channel
  namespace: knative-eventing
data:
  channel-template-spec: |
    apiVersion: messaging.knative.dev/v1beta1
    kind: KafkaChannel

更新 config-br-default-channel

# kubectl apply -f config-br-default-channel.yaml
configmap/config-br-default-channel configured

参考文档

https://knative.dev/docs/install/yaml-install/eventing/install-eventing-with-yaml

posted @ 2023-10-13 17:55  小吉猫  阅读(26)  评论(0编辑  收藏  举报