dubbo微服务接入apollo配置中心_第1张图片

现在我们有两个配置项:

dubbo微服务接入apollo配置中心_第2张图片

点击发布:

dubbo微服务接入apollo配置中心_第3张图片

构建成功后修改deployment中的镜像版本号:

[root@hdss7-200 dubbo-demo-service]# cat dp.yaml

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_191208_1614

        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: Always

      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

[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-service/dp.yaml

[root@hdss7-21 ~]# kubectl get pod -n app

NAME                                   READY   STATUS    RESTARTS   AGE

dubbo-demo-consumer-7f57887dd4-8vvpg   1/1     Running   0          23h

dubbo-demo-service-58d98d958-x9pdr     1/1     Running   0          97s

dubbo微服务接入apollo配置中心_第4张图片

dubbo服务消费端接入apollo:

创建项目:

dubbo微服务接入apollo配置中心_第5张图片

创建配置项:

dubbo微服务接入apollo配置中心_第6张图片

使用jenkins更新代码镜像:

dubbo微服务接入apollo配置中心_第7张图片

修改资源配置清单并重新应用:

[root@hdss7-200 dubbo-demo-consumer]# cat dp.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:apollo_191208_1635

        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

[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consumer/dp.yaml

pod起来以后,可以看到apollo上已经有实例链接过来了

dubbo微服务接入apollo配置中心_第8张图片