本篇内容介绍了“K8S怎么部署Kafka界面管理工具”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
kafka-manager 是雅虎开源的apache-kafka管理工具,是用Scala编写的,可以在web页面进行kafka的相关操作。
下载kafka-manager-2.0.0.2.zip,在解压目录的conf下的application.conf文件里,修改kafka-manager.zkhosts地址和cmake.zkhosts地址为:
zok-0.zk-hs.wiseco.svc.cluster.local:2181,zok-1.zk-hs.wiseco.svc.cluster.local:2181,zok-2.zk-hs.wiseco.svc.cluster.local:2181
[root@k8s-storage01 kafkamanager]# pwd
/home/k8s_deploy/fin/online/deploy/kafkamanager
[root@k8s-storage01 kafkamanager]# ll
total 59228
-rw-r--r-- 1 root root 353 Jan 27 17:42 Dockerfile
-rw-r--r-- 1 root root 60639694 Jan 27 17:48 kafka-manager-2.0.0.2.zip
[root@k8s-storage01 kafkamanager]# unzip kafka-manager-2.0.0.2.zip
[root@k8s-storage01 kafkamanager]# ll
total 59228
-rw-r--r-- 1 root root 353 Jan 27 17:42 Dockerfile
drwxr-xr-x 6 root root 4096 Jan 27 18:09 kafka-manager-2.0.0.2
-rw-r--r-- 1 root root 60639694 Jan 27 17:48 kafka-manager-2.0.0.2.zip
[root@k8s-storage01 kafkamanager]# cd kafka-manager-2.0.0.2/conf/
[root@k8s-storage01 conf]# vim application.conf
...........
...........
kafka-manager.zkhosts="zok-0.zk-hs.wiseco.svc.cluster.local:2181,zok-1.zk-hs.wiseco.svc.cluster.local:2181,zok-2.zk-hs.wiseco.svc.cluster.local:2181"
...........
...........
basicAuthentication.enabled=true #这里启用了用户密码登录,默认false不启用 (除了这里启用用户登录, 后面也可以启用ldap)
basicAuthentication.enabled=${?KAFKA_MANAGER_AUTH_ENABLED}
...........
...........
basicAuthentication.username="admin"
basicAuthentication.username=${?KAFKA_MANAGER_USERNAME}
basicAuthentication.password="AdMin@123" #修改用户登录密码
basicAuthentication.password=${?KAFKA_MANAGER_PASSWORD}
...........
...........
重新打包
[root@k8s-storage01 conf]# cd ../../
[root@k8s-storage01 kafkamanager]# ll
total 59228
-rw-r--r-- 1 root root 353 Jan 27 17:42 Dockerfile
drwxr-xr-x 6 root root 4096 Jan 27 18:09 kafka-manager-2.0.0.2
-rw-r--r-- 1 root root 60639694 Jan 27 17:48 kafka-manager-2.0.0.2.zip
[root@k8s-storage01 kafkamanager]# rm -rf kafka-manager-2.0.0.2.zip
[root@k8s-storage01 kafkamanager]# tar -zvcf kafka-manager-2.0.0.2.tar.gz kafka-manager-2.0.0.2
[root@k8s-storage01 kafkamanager]# rm -rf kafka-manager-2.0.0.2
[root@k8s-storage01 kafkamanager]# ll
total 58000
-rw-r--r-- 1 root root 353 Jan 27 17:42 Dockerfile
-rw-r--r-- 1 root root 59387703 Jan 27 18:13 kafka-manager-2.0.0.2.tar.gz
制作Dockerfile镜像
[root@k8s-storage01 kafkamanager]# cat Dockerfile
FROM 192.168.10.10/wiseco/jdk1.8.0_192
RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
ENV LANG en_US.UTF-8
ADD kafka-manager-2.0.0.2.tar.gz /opt/
RUN mv /opt/kafka-manager-2.0.0.2 /opt/kafka-manager
EXPOSE 9000
CMD ["/opt/kafka-manager/bin/kafka-manager"]
上传到harbor仓库
[root@k8s-storage01 kafkamanager]# docker build -t 192.168.10.10/wiseco/kafka-manager-2.0.0.2:v1 .
[root@k8s-storage01 kafkamanager]# docker push 192.168.10.10/wiseco/kafka-manager-2.0.0.2:v1
[root@k8s-master01 kafkamanager]# pwd
/opt/k8s/k8s-project/kafka_zk/kafkamanager
[root@k8s-master01 kafkamanager]# cat kafkamanager.yaml
apiVersion: v1
kind: Service
metadata:
name: kafkamanager
namespace: wiseco
labels:
app: kafkamanager
spec:
type: NodePort
selector:
app: kafkamanager
ports:
- name: http
port: 9000
targetPort: 9000
nodePort: 39921
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kafkamanager
namespace: wiseco
spec:
replicas: 1
minReadySeconds: 10
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
selector:
matchLabels:
app: kafkamanager
template:
metadata:
labels:
app: kafkamanager
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- kafkamanager
topologyKey: "kubernetes.io/hostname"
terminationGracePeriodSeconds: 120
containers:
- name: kafkamanager
image: 192.168.10.10/wiseco/kafka-manager-2.0.0.2:v1
imagePullPolicy: Always
ports:
- name: cport
containerPort: 9000
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 500m
memory: 400Mi
lifecycle:
postStart:
exec:
command: ["/bin/sh","-c","touch /tmp/health"]
livenessProbe:
exec:
command: ["test","-e","/tmp/health"]
initialDelaySeconds: 5
timeoutSeconds: 5
periodSeconds: 10
readinessProbe:
tcpSocket:
port: cport
initialDelaySeconds: 15
timeoutSeconds: 5
periodSeconds: 20
创建并查看
[root@k8s-master01 kafkamanager]# kubectl apply -f kafkamanager.yaml
[root@k8s-master01 kafkamanager]# kubectl get pods -n wiseco|grep kafkamanager
kafkamanager-6b966689f6-mr9tq 1/1 Running 0 2m51s
[root@k8s-master01 kafkamanager]# kubectl get svc -n wiseco|grep kafkamanager
kafkamanager NodePort 10.254.240.254 <none> 9000:39921/TCP 2m55s
使用K8S的nodeport端口访问kafkamanager
登录用户是:admin
登录密码是:AdMin@123
“K8S怎么部署Kafka界面管理工具”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。