在kubernetes集群里集成Apollo配置中心(4)之dubbo服务提供者连接apollo实战
1.登录portal.od.com(Apollo-portal),新建一个dubbo-demo-service项目
2.在Apollo项目中的dubbo-demo-service添加配置
(1)添加dubbo.registry配置
(2)添加dubbo.port
(3)将dubbo.registry和dubbo.port分布
3.使用jenkins构建镜像
4.登录harbor查看是否已经上传镜像
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