背景

实际使用中,部署好kafka集群后,需要管理集群,那么一个好的web控制台就显得尤为重要了。

Apache Kafka UI 是一个简单的工具,可让您的数据流可观察,帮助更快地发现和解决问题并提供最佳性能。其轻量级仪表板可以轻松跟踪 Kafka 集群的关键指标 - 代理、主题、分区、生产和消耗。

直接上部署代码,亲测可用

开源链接

https://github.com/provectus/kafka-ui

效果预览

部署

配置文件

kafka-ui-cm

注意,如果是想管理多个 kafka 集群,则需要配置多个集群信息,并在配置文件中不同的索引号以示区分。例如 _0,_1,_2,如下图所示

---
apiVersion: v1
data:
  ANNOTATION: 'DYNAMIC_CONFIG_ENABLED: true'
  AUTH_TYPE: LOGIN_FORM
  KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: ${实例0的kafka地址}
  KAFKA_CLUSTERS_0_NAME: ${kafka-0的名字}
  KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL: SSL
  KAFKA_CLUSTERS_1_BOOTSTRAPSERVERS: ${实例1的kafka地址}
  KAFKA_CLUSTERS_1_NAME: ${kafka-1的名字}
  KAFKA_CLUSTERS_1_PROPERTIES_SECURITY_PROTOCOL: SSL
  SPRING_SECURITY_USER_NAME: admin
  SPRING_SECURITY_USER_PASSWORD: ${设置管理员密码}
  TZ: UTC
kind: ConfigMap
metadata:
  labels:
    app: kafka-ui-cm
  name: kafka-ui-cm
  namespace: xxx

deployment 和 service

kafka-ui

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations: {}
  labels:
    k8s.kuboard.cn/name: kafka-ui
  name: kafka-ui
  namespace: xxx
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: kafka-ui
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/restartedAt: '2023-11-28T16:21:38+08:00'
      creationTimestamp: null
      labels:
        app: kafka-ui
    spec:
      containers:
        - envFrom:
            - configMapRef:
                name: kafka-ui-cm
          image: 'provectuslabs/kafka-ui:latest'
          imagePullPolicy: Always
          name: kafka-ui
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30

---
apiVersion: v1
kind: Service
metadata:
  annotations: {}
  labels:
    app: kafka-ui
  name: kafka-ui
  namespace: xxx
spec:
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
  ports:
    - nodePort: 32204
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: kafka-ui
  sessionAffinity: None
  type: NodePort

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐