当前位置:   article > 正文

235. Jenkins老头持续构建dubbo服务消费者_jenkins dubbo 服务

jenkins dubbo 服务

一、交付dubbo-monitor到k8s集群中

dubbo-monitor工具
dubbo-monitor源码包:https://github.com/Jeromefromcn/dubbo-monitor.git

下载源码
[root@k8s7-200.host.com /opt/src]# unzip dubbo-monitor-master.zip 

修改配置
cat /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.log4j.file=logs/dubbo-monitor.log

优化脚本;
[root@k8s7-200.host.com /opt/src/dubbo-monitor/dubbo-monitor-simple/bin]# tail start.sh
JAVA_MEM_OPTS=""
BITS=`java -version 2>&1 | grep -i 64-bit`
if [ -n "$BITS" ]; then
    JAVA_MEM_OPTS=" -server -Xmx128m -Xms128m -Xmn32m -XX:PermSize=16m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
    JAVA_MEM_OPTS=" -server -Xms128m -Xmx128m -XX:PermSize=16m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi

echo -e "Starting the $SERVER_NAME ...\c"
exec java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main > $STDOUT_FILE 2>&1


[root@k8s7-200.host.com /opt/src]# cp -a dubbo-monitor /data/dockerfile/
[root@k8s7-200.host.com /data/dockerfile/dubbo-monitor]# docker build . -t harbor.od.com/infra/dubbo-monitor:latest
[root@k8s7-200.host.com /data/dockerfile/dubbo-monitor]# docker push harbor.od.com/infra/dubbo-monitor:latest
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

1. 准备k8s资源配置清单

[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# pwd
/data/k8s-yaml/dubbo-monitor

1[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# cat deployment.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[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# cat service.yaml 
kind: Service
apiVersion: v1
metadata: 
  name: dubbo-monitor
  namespace: infra
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector: 
    app: dubbo-monitor
  clusterIP: None
  type: ClusterIP
  sessionAffinity: None

3[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# cat 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79

2.应用资源配置清单

[root@k8s7-21.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/deployment.yaml
[root@k8s7-21.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/service.yaml
[root@k8s7-21.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/ingress.yaml

  • 1
  • 2
  • 3
  • 4

3.配置DNS解析

[root@k8s7-11.host.name ~]# tail /var/named/od.com.zone
dubbo-monitor	   A    10.4.7.10
[root@k8s7-11.host.name ~]# systemctl restart named
  • 1
  • 2
  • 3

在这里插入图片描述

二、Jenkins持续构建dubbo服务消费者

1.CI流水线构建

在这里插入图片描述

缓存目录
root@jenkins-7c85c8cb57-m6cvg:~/.m2# pwd
/root/.m2

2.检查

在这里插入图片描述
在这里插入图片描述

3.准备k8s资源配置清单

[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# pwd
/data/k8s-yaml/dubbo-demo-consume
1.[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# cat deployment.yaml 
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-consumer
  namespace: app
  labels: 
    name: dubbo-demo-consumer
spec:
  replicas: 1
  selector:
    matchLabels: 
      name: dubbo-demo-consumer
  template:
    metadata:
      labels: 
        app: dubbo-demo-consumer
        name: dubbo-demo-consumer
    spec:
      containers:
      - name: dubbo-demo-consumer
        image: harbor.od.com/app/dubbo-demo-consumer:master_200814_1700
        env:
        - name: JAR_BALL
          value: dubbo-client.jar
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      terminationGracePeriodSeconds: 30
  strategy:
    type: RollingUpdate
    rollingUpdate: 
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600

2.[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# cat service.yaml 
kind: Service
apiVersion: v1
metadata: 
  name: dubbo-demo-consumer
  namespace: app
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector: 
    app: dubbo-demo-consumer

3.[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# cat ingress.yaml 
kind: Ingress
apiVersion: extensions/v1beta1
metadata: 
  name: dubbo-demo-consumer
  namespace: app
spec:
  rules:
  - host: demo.od.com
    http:
      paths:
      - path: /
        backend: 
          serviceName: dubbo-demo-consumer
          servicePort: 8080


应用资源配置清单
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consume/deployment.yaml
deployment.extensions/dubbo-demo-consumer created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consume/service.yaml
service/dubbo-demo-consumer created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consume/ingress.yaml
ingress.extensions/dubbo-demo-consumer created
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77

4.检查docker运行情况及dubbo-monitor

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

5.DNS解析

[root@k8s7-11.host.name ~]# tail /var/named/od.com.zone 
demo	  	   A	10.4.7.10
[root@k8s7-11.host.name ~]# dig -t A demo.od.com @10.4.7.11 +short
10.4.7.10
  • 1
  • 2
  • 3
  • 4

6.浏览器访问

http://demo.od.com/hello?name=yinwucheng
在这里插入图片描述

7.资源扩容

在这里插入图片描述
项目介绍:

dubb-demo-service和consumer就是典型的无状态服务,k8s最易管理的就是无状态服务,可以无限弹性扩容;目前前端业务已经由3个服务支撑,可承受更大的并发,这是dubbo自己提供的负载均衡机制;consumer扩容是由k8s来做的,ingress机制(找一个service对应两个不同的pod,通过标签选择器)
在这里插入图片描述
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/169574
推荐阅读
相关标签
  

闽ICP备14008679号