zoukankan      html  css  js  c++  java
  • 在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战

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

    (1)添加dubbo消费者项目

    image-20200709141046777

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

    image-20200709141152341

    image-20200709141359126

    (3)发布

    image-20200709141459422

    image-20200709141507940

    image-20200709141516052

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

    image-20200709144143422

    image-20200709151103574

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

    image-20200709151150606

    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消费者实例连接上

    image-20200709151927823

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

    image-20200709152208891

    image-20200709152215361

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

    image-20200709152320881

  • 相关阅读:
    Sql Server2012连接不上问题
    WinForm的App.config写法
    (原)centos 防火墙开放端口命令
    Linux下rsync的用法
    Centos7下部署minio
    arthas简单使用
    在Docker中运行MinIO单点模式
    中台是什么
    Kubernetes K8S之Ingress详解与示例
    Rancher2.x平台搭建与使用
  • 原文地址:https://www.cnblogs.com/Heroge/p/13277561.html
Copyright © 2011-2022 走看看