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ệnhkubectl get sc
để kiểm tra xem cluster Kubernetes đã có default dynamic storage provisioner hay chưa.
Bước 1: Tạo một namespace
1 2 | kubectl create namespace confluent |
Set namespace confluent thành namespace mặc định
1 2 | kubectl config set-context --current --namespace confluent |
Bước 2: Cài đặt Confluent Platform cho Kubernetes
Thêm Confluent vào Helm repository.
1 2 3 | helm repo add confluentinc https://packages.confluent.io/helm helm repo update |
Cài đặt Confluent Platform sử dụng helm
1 2 | 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
1 2 | kubectl get pods |
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
1 2 | 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.
1 2 | 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:
1 2 | kubectl get pods |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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
1 2 3 4 | kubectl apply -f control-center.yaml kubectl get svc |
Mở Web Browser và truy cập đến địa chỉ <External-IP>:9021
Giới thiệu sơ qua về Control Center:
Đây là giao diện chính:
Brokers: Theo dõi tình trạng của các nút Brokers
Topics: Xem lại các Topic đã tạo, xem msg bên trong từng Topic, Produce msg
Connect: Quản lý các source, sink connectors
KsqlDB: Xử lý các tác vụ liên quan đến Kafka Stream