1.下载软件包
首先下载 dubbo-monitor源码包 7-200
dubbo-monitor是监控zookeeper状态的一个服务,另外还有dubbo-admin,效果一样,感兴趣的可以自己研究一下。
[root@hdss7-200 src]# # yum -y install unzip
[root@hdss7-200 src]# #unzip dubbo-monitor
[root@hdss7-200 src]# # mv dubbo-monitor-mster dubbo-monitor
[root@hdss7-200 src]# cd /opt/src/dubbo-monitor
[root@hdss7-200 dubbo-monitor]# vi /opt/src/dubbo-monitor/dubbo-monitor-simple/conf/dubbo_origin.properties
优化修改Dockerfile并限制jvm资源,将最后的exec命令的后台&符号删除,并且将exec命令下面的都干掉:
sed -r -i -e '/^nohup/{p;:a;N;$!ba;d}' ./dubbo-monitor-simple/bin/start.sh && sed -r -i -e "s%^nohup(.*)%exec \1%" ./dubbo-monitor-simple/bin/start.sh
执行docker build并上传镜像到我们的私有仓库:
cp -a dubbo-monitor/ /data/dockerfile/
cd /data/dockerfile/dubbo-monitor
docker build . -t harbor.od.com/infra/dubbo-monitor:latest
docker push harbor.od.com/infra/dubbo-monitor:latest
2 制作资源配置清单:
1、dp.yaml
# mkdir /data/k8s-yaml/dubbo-monitor
# cd /data/k8s-yaml/dubbo-monitor
vi dp.yaml
kind: Deployment apiVersion: extensions/v1beta1 metadata: name: dubbo-monitor namespace: infra labels: name: dubbo-monitor spec: replicas: 1 selector: matchLabels: name: dubbo-monitor template: metadata: labels: app: dubbo-monitor name: dubbo-monitor spec: containers: - name: dubbo-monitor image: harbor.od.com/infra/dubbo-monitor:latest ports: - containerPort: 8080 protocol: TCP - containerPort: 20880 protocol: TCP imagePullPolicy: IfNotPresent imagePullSecrets: - name: harbor restartPolicy: Always terminationGracePeriodSeconds: 30 securityContext: runAsUser: 0 schedulerName: default-scheduler strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 revisionHistoryLimit: 7 progressDeadlineSeconds: 600
svc
kind: Service apiVersion: v1 metadata: name: dubbo-monitor namespace: infra spec: ports: - protocol: TCP port: 8080 targetPort: 8080 selector: app: dubbo-monitor
ingress
kind: Ingress apiVersion: extensions/v1beta1 metadata: name: dubbo-monitor namespace: infra spec: rules: - host: dubbo-monitor.od.com http: paths: - path: / backend: serviceName: dubbo-monitor servicePort: 8080
3应用资源配置清单:node节点
# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/dp.yaml
# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/svc.yaml
# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/ingress.yaml
验证:
# kubectl get pod -n infra