在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

1.在Apollo的portal创建dubbo消费者项目

(1)添加dubbo消费者项目

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

(2)在dubbo消费者项目中添加配置项

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

(3)发布

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

2.通过jenkins构建dubbo消费者镜像

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

3.登录私有仓库harbor查看是否已上传

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

4.修改之前的dubbo消费者的deployment.yaml资源配置清单

在运维主机mfyxw50.mfyxw.com上操作

[root@mfyxw50 ~]# cat > /data/k8s-yaml/dubbo-demo-consumer/deployment.yaml << EOF
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:apollo_20200709_1441
        ports:
        - containerPort: 8080
          protocol: TCP
        - containerPort: 20880
          protocol: TCP
        env:
        - name: JAR_BALL
          value: dubbo-client.jar
        - name: C_OPTS
          value: -Denv=dev -Dapollo.meta=http://config.od.com
        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
EOF

5.重新应用dubbo消费者的deployment.yaml资源配置清单

在master节点(mfyxw30.mfyxw.com或mfyxw40.mfyxw.com)任意一台执行

[root@mfyxw30 ~]# kubectl get pod -n app
NAME                                   READY   STATUS    RESTARTS   AGE
dubbo-demo-consumer-6c7f6f598b-l2gdx   1/1     Running   12         23d
dubbo-demo-service-6c99776d74-xxkr7    1/1     Running   4          28h
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consumer/deployment.yaml
deployment.extensions/dubbo-demo-consumer configured
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n app
NAME                                  READY   STATUS    RESTARTS   AGE
dubbo-demo-consumer-ccb4d6549-g6h6k   1/1     Running   0          3s
dubbo-demo-service-6c99776d74-xxkr7   1/1     Running   4          28h

6.查看Apollo的portal是否已经有dubbo消费者实例连接上

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

7.登录dubbo-monitor查看Apollo的dubbo消费者是否注册进入

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

8.访问demo.od.com/hello?name=apollo

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

上一篇:net core k8s jenkins 前后端自动部署shell备份


下一篇:FILE和fstream