随笔- 60  评论- 14  文章- 0 

在kubernetes集群里集成Apollo配置中心(4)之dubbo服务提供者连接apollo实战

1.登录portal.od.com(Apollo-portal),新建一个dubbo-demo-service项目

image-20200707212049474

image-20200707212313830

2.在Apollo项目中的dubbo-demo-service添加配置

image-20200707212818447

(1)添加dubbo.registry配置

image-20200707212944854

(2)添加dubbo.port

image-20200707213214745

(3)将dubbo.registry和dubbo.port分布

image-20200707213259262

image-20200707213327437

image-20200707213339395

3.使用jenkins构建镜像

image-20200707213618771

image-20200707213824086

image-20200708102327929

4.登录harbor查看是否已经上传镜像

image-20200708110546418

5.修改dubbo-demo-service之前的deployment资源配置清单

(1)修改deployment.yaml资源配置清单

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

[root@mfyxw50 ~]# cat > /data/k8s-yaml/dubbo-demo-service/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-service
  namespace: app
  labels:
    name: dubbo-demo-service
spec:
  replicas: 1
  selector:
    matchLabels:
      name: dubbo-demo-service
  template:
    metadata:
      labels:
        app: dubbo-demo-service
        name: dubbo-demo-service
    spec:
      containers:
      - name: dubbo-demo-service
        image: harbor.od.com/app/dubbo-demo-service:apollo_20200707_2136
        ports:
        - containerPort: 20880
          protocol: TCP
        env:
        - name: JAR_BALL
          value: dubbo-server.jar
        - name: C_OPTS
          value: -Denv=dev -Dapollo.meta=http://config.od.com
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
EOF

(2)重新应用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   11         21d
dubbo-demo-service-5bd9876c7d-pxpd9    1/1     Running   25         24d
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-service/deployment.yaml
deployment.extensions/dubbo-demo-service configured
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n app
NAME                                   READY   STATUS    RESTARTS   AGE
dubbo-demo-consumer-6c7f6f598b-l2gdx   1/1     Running   11         21d
dubbo-demo-service-6c99776d74-xxkr7    1/1     Running   0          3s

6.登录portal.od.com查看到dubbo-demo-service已经连接到apollo

image-20200708111829689

7.登录dubbo-monitor监控查看

image-20200708112028832

posted on 2020-07-09 09:25  杨枫哥  阅读(64)  评论(0编辑  收藏