+7

Triển khai Confluent Kafka (Enterprise) cho Kubernetes

Confluent Kafka giúp dễ dàng kết nối các ứng dụng, hệ thống của bạn với các luồng dữ liệu và xử lý chúng theo thời gian thực. Confluent Platform cung cấp giải pháp để triển khai các cluster Kafka trên Docker và Kubernetes đơn giản hơn so với Apache Kafka

Điều kiện tiên quyết

  • Kubectl và Helm 3 đã được cài đặt
  • Đối với bài hướng dẫn này, cluster Kubernetes của bạn được giả định đã có một default dynamic storage provisioner. Dùng lệnh kubectl get sc để kiểm tra xem cluster Kubernetes đã có default dynamic storage provisioner hay chưa.

image.png

Bước 1: Tạo một namespace

kubectl create namespace confluent

Set namespace confluent thành namespace mặc định

kubectl config set-context --current --namespace confluent

Bước 2: Cài đặt Confluent Platform cho Kubernetes

Thêm Confluent vào Helm repository.

helm repo add confluentinc https://packages.confluent.io/helm
helm repo update

Cài đặt Confluent Platform sử dụng helm

helm upgrade --install confluent-operator confluentinc/confluent-for-kubernetes

Hãy chắc chắn rằng Operator đã running và ready trước khi đi đến bước tiếp theo

kubectl get pods

image.png

Bước 3: Cài đặt các components của Confluent Platform

Các components của Confluent Platform bao gồm:

  • Zookeepers
  • Kafka Brokers
  • Kafka Connectors
  • KsqlDB
  • Control Center (Kafka Web UI)
  • Schema Registry
  • Kafka Rest Proxy
kubectl apply -f https://raw.githubusercontent.com/confluentinc/confluent-kubernetes-examples/master/quickstart-deploy/confluent-platform.yaml

Cài đặt một producer app và tạo topic để test.

kubectl apply -f https://raw.githubusercontent.com/confluentinc/confluent-kubernetes-examples/master/quickstart-deploy/producer-app-data.yaml

Kiểm tra mọi thứ đã Running và Ready hay chưa:

kubectl get pods

image.png

Bước 4: Tạo External Load balancer cho Control Center

Tạo một file control-center.yaml với nội dung như sau:

apiVersion: v1
kind: Service
metadata:
  name: kafka-ui-lb
spec:
  type: LoadBalancer
  sessionAffinity: None
  selector:
    app: controlcenter
  ports:
    - name: kafka-ui-lb
      port: 9021
      protocol: TCP
      targetPort: 9021

Dùng kubectl để apply file cấu hình và kiểm tra xem Load balancer đã được tạo thành công hay chưa

kubectl apply -f control-center.yaml

kubectl get svc

image.png

Mở Web Browser và truy cập đến địa chỉ <External-IP>:9021

image.png

Giới thiệu sơ qua về Control Center:

Đây là giao diện chính: image.png

Brokers: Theo dõi tình trạng của các nút Brokers image.png

Topics: Xem lại các Topic đã tạo, xem msg bên trong từng Topic, Produce msg image.png

image.png

Connect: Quản lý các source, sink connectors image.png

KsqlDB: Xử lý các tác vụ liên quan đến Kafka Stream image.png


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí