k8s中部署kafka-eagle

1.下载kafka-eagle镜像

docker pull buzhiyun/kafka-eagle

2.部署mysql数据库

mysql.yml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
    name: mysql-pv-claim
    namespace: infinovaiot
spec:
    accessModes: 
      - ReadWriteOnce
    resources:
        requests:
            storage: 30Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
    name: mysql
    namespace: infinovaiot
spec:
    replicas: 1
    selector:
        matchLabels:
            app: mysql
    template:
        metadata:
          labels:
            app: mysql
        spec:
            containers:
            - name: mysql
              image: 10.82.13.105/library/mysql:5.6
              imagePullPolicy: IfNotPresent
              args:
              - "--ignore-db-dir=lost+found"
              ports:
              - containerPort: 3306
              env:
              - name: POSTGRES_DB
                value: "kafka-eagle"
              - name: MYSQL_ROOT_PASSWORD
                value: "mysql"
              volumeMounts:
              - name: mysql
                mountPath: /var/lib/mysql/kafka-eagle
            volumes:
            - name: mysql
              persistentVolumeClaim:
                  claimName: mysql-pv-claim
---
apiVersion: v1
kind: Service
metadata:
  name: tb-mysql
  namespace: infinovaiot
spec:
  type: ClusterIP
  selector:
    app: mysql
  ports:
  - port: 3306
    name: mysql
---
apiVersion: v1
kind: Service
metadata:
  name: mysql-client
  namespace: infinovaiot
spec:
  type: NodePort
  ports:
    - port: 3306
      targetPort: 3306
      nodePort: 30006
  selector:
    app: mysql
---
                  

3.部署kafka

kafka部署可以参考:https://github.com/Yolean/kub...

开放JMX端口:5555

https://github.com/Yolean/kub...

4.部署kafka-eagle

system-config.properties文件:

######################################
# multi zookeeper&kafka cluster list
######################################
kafka.eagle.zk.cluster.alias=cluster1
cluster1.zk.list=zookeeper:2181

######################################
# zk client thread limit
######################################
kafka.zk.limit.size=25

######################################
# kafka eagle webui port
######################################
kafka.eagle.webui.port=8048

######################################
# kafka offset storage
######################################
cluster1.kafka.eagle.offset.storage=kafka

######################################
# enable kafka metrics
######################################
kafka.eagle.metrics.charts=true
kafka.eagle.sql.fix.error=true

######################################
# kafka sql topic records max
######################################
kafka.eagle.sql.topic.records.max=5000

######################################
# alarm email configure
######################################
kafka.eagle.mail.enable=false
kafka.eagle.mail.sa=alert_sa@163.com
kafka.eagle.mail.username=alert_sa@163.com
kafka.eagle.mail.password=mqslimczkdqabbbh
kafka.eagle.mail.server.host=smtp.163.com
kafka.eagle.mail.server.port=25

######################################
# alarm im configure
######################################
#kafka.eagle.im.dingding.enable=true
#kafka.eagle.im.dingding.url=https://oapi.dingtalk.com/robot/send?access_token=

#kafka.eagle.im.wechat.enable=true
#kafka.eagle.im.wechat.token=https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=xxx&corpsecret=xxx
#kafka.eagle.im.wechat.url=https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=
#kafka.eagle.im.wechat.touser=
#kafka.eagle.im.wechat.toparty=
#kafka.eagle.im.wechat.totag=
#kafka.eagle.im.wechat.agentid=

######################################
# delete kafka topic token
######################################
kafka.eagle.topic.token=keadmin

######################################
# kafka sasl authenticate
######################################
cluster1.kafka.eagle.sasl.enable=false
cluster1.kafka.eagle.sasl.protocol=SASL_PLAINTEXT
cluster1.kafka.eagle.sasl.mechanism=PLAIN
cluster1.kafka.eagle.sasl.jaas.config=kafka_client_jaas.conf

######################################
# kafka jdbc driver address
######################################
#kafka.eagle.driver=org.sqlite.JDBC
#kafka.eagle.url=jdbc:sqlite:/usr/local/ke.db
#kafka.eagle.username=root
#kafka.eagle.password=www.kafka-eagle.org
kafka.eagle.driver=com.mysql.jdbc.Driver
kafka.eagle.url=jdbc:mysql://tb-mysql:3306/kafka-eagle
kafka.eagle.username=root
kafka.eagle.password=mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-eagle
  namespace: infinovaiot
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      workload.user.cattle.io/workloadselector: deployment-kafka-kafka-eagle
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        workload.user.cattle.io/workloadselector: deployment-kafka-kafka-eagle
    spec:
      containers:
      - image: buzhiyun/kafka-eagle:latest
        imagePullPolicy: Always
        name: kafka-eagle
        ports:
        - containerPort: 8048
          name: 8048tcp01
          protocol: TCP
        resources: {}
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          procMount: Default
          readOnlyRootFilesystem: false
          runAsNonRoot: false
        stdin: true
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        tty: true
        volumeMounts:
        - mountPath: /opt/kafka-eagle/conf
          name: conf
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          defaultMode: 256
          name: kafka-eagle-config
          optional: false
        name: conf
---
apiVersion: v1
kind: Service
metadata:
  name: kafka-eagle-client
  namespace: infinovaiot
spec:
  type: NodePort
  ports:
    - port: 8048
      targetPort: 8048
      nodePort: 30048
  selector:
    workload.user.cattle.io/workloadselector: deployment-kafka-kafka-eagle
 

kafka_client_jaas.conf

KafkaClient {
  org.apache.kafka.common.security.plain.PlainLoginModule required
  username="admin"
  password="admin-secret";
};

分别执行以下命令:

kubectl apply -f mysql.yml

kubectl create configmap kafka-eagle-config -n infinovaiot --from-file=kafka_client_jaas.conf \
--from-file=system-config.properties

kubectl apply -f kafka-eagle.yml

5.浏览器访问

浏览器输入: http://ip:port30048/ke

账号:admin 密码:123456


沧海一粟
49 声望3 粉丝

好好学习,天天向上