kubernetes实战-交付dubbo服务到k8s集群(五)交付dubbo-monitor监控服务到k8s

爱⌒轻易说出口 提交于 2020-04-23 07:32:35

首先下载 dubbo-monitor源码包 7-200

dubbo-monitor是监控zookeeper状态的一个服务,另外还有dubbo-admin,效果一样,感兴趣的可以自己研究一下。

# cd /opt/src
# wget https://github.com/Jeromefromcn/dubbo-monitor/archive/master.zip
# yum -y install unzip
# unzip master.zip
# mv dubbo-monitor-mster dubbo-monitor
# cd /opt/src/dubbo-monitor

修改配置文件:对应修改,不要全部删除内容。

# vi /opt/src/dubbo-monitor/dubbo-monitor-simple/conf/dubbo_origin.properties
dubbo.registry.address=zookeeper://zk1.od.com:2181?backup=zk2.od.com:2181,zk3.od.com:2181
dubbo.protocol.port=20880
dubbo.jetty.port=8080
dubbo.jetty.directory=/dubbo-monitor-simple/monitor
dubbo.statistics.directory=/dubbo-monitor-simple/statistics
dubbo.charts.directory=/dubbo-monitor-simple/charts
dubbo.log4j.file=logs/dubbo-monitor.log

优化修改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

制作资源配置清单:

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

2、svc.yaml

# vi svc.yaml
kind: Service
apiVersion: v1
metadata: 
  name: dubbo-monitor
  namespace: infra
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector: 
    app: dubbo-monitor

3、ingress.yaml

# vi ingress.yaml
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

应用资源配置清单: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

 

这个服务是有web页面的,我们添加dns解析:

# vi /var/named/od.com.zone

# systemctl restart named
# dig -t A dubbo-monitor.od.com @10.4.7.11 +short

 

 

 

 这里已经可以看到我们之前部署的dubbo-demo-service服务了,启动了两个进程来提供服务。

 至此,dubbo-monitor监控服务已经部署完成。

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!