Dubbo
- Dubbo是阿里巴巴SOA服务化治理方案的核心框架
- Dubbo是一个分布式服务框架,致力于提高性能核透明化的RPC远程服务调用方案,以及SOA服务治理方案
- 只有在分布式的时候,才有dubbo这样的分布式服务框架的需求,并且本质上是远程服务调用的分布式框架
Dubbo能做什么
- 透明化的远程方法调用,就像调用本地方法一样调用远程方法,只需简单配置,没有任何API侵入
- 软负载均衡及容错机制,可在内网代替F5等硬件负载均衡器,降低成本,减少单点
- 服务自动注册与发现,不再需要写死服务提供地址,注册中心基于接口名查询服务提供者的IP地址,并且能够平滑添加或删除服务提供者
- Provider:暴露服务的服务提供方
- consumer: 调用远程服务的服务消费方
- Registry: 服务注册与发现的注册中心
- Monitor: 统计服务的调用次调和调用时间的监控中心
- container: 服务运行容器(载体)
zookeeper(zk集群)
- zookeeper时Dubbo微服务集群的注册中心
- 它的高可用机制和K8S的etcd集群一致
- Java编写
主机名 | 角色 | ip |
HDSS7-11.host.com | k8s代理节点1,zk1 | 10.4.7.11 |
HDSS7-12.host.com | k8s代理节点2,zk2 | 10.4.7.12 |
HDSS7-21.host.com | k8s运算节点1,zk3 | 10.4.7.21 |
HDSS7-22.host.com | k8s运算节点2,jenkins | 10.4.7.22 |
HDSS7-200.host.com | k8s运维节点(docker仓库) | 10.4.7.200 |
安装jdk1.8(3台zk角色主机)
mkdir /usr/java
tar xf jdk-8u221-linux-x64.tar.gz -C /usr/java/
ln -s /usr/java/jdk1.8.0_221 /usr/java/jdk
vim /etc/profile
export JAVA_HOME=/usr/java/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/bin:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
安装zookeeper(3台zk角色主机)
tar xf zookeeper-3.4.14.tar.gz -C /opt/
ln -s /opt/zookeeper-3.4.14 /opt/zookeeper
mkdir -pv /data/zookeeper/data /data/zookeeper/logs
vim /opt/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/logs
clientPort=2181
server.1=zk1.od.com:2888:3888
server.2=zk2.od.com:2888:3888
server.3=zk3.od.com:2888:3888
注意:各节点zk配置相同
dns解析
zk1 A 10.4.7.11
zk2 A 10.4.7.12
zk3 A 10.4.7.21
myid
HDSS7-11.host.com上:
/data/zookeeper/data/myid
1
HDSS7-12.host.com上:
/data/zookeeper/data/myid
2
HDSS7-21.host.com上:
/data/zookeeper/data/myid
3
依次启动zookeeper
/opt/zookeeper/bin/zkServer.sh start
查看server状态
/opt/zookeeper/bin/zkServer.sh status
[root@hdss7-11 zookeeper]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@hdss7-12 src]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@hdss7-21 src]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
登录
/opt/zookeeper/bin/zkCli.sh -server localhost:2181
部署jenkins
准备基础镜像
docker pull jenkins/jenkins:2.190.3
docker tag 22b8b9a84dbe harbor.od.com/public/jenkins:v2.190.3
docker push harbor.od.com/public/jenkins:v2.190.3
生成密钥对
ssh-keygen -t rsa -b 2048 -C "1226032602@qq.com" -N "" -f /root/.ssh/id_rsa
自定义Dockerfile
mkdir /data/dockerfile/jenkins/ -p
下载get-docker.sh,准备id_rsa和config.json(在/root/.docker/config.json)
curl -fsSL get.docker.com -o get-docker.sh
vim /data/dockerfile/jenkins/Dockerfile
FROM harbor.od.com/public/jenkins:v2.190.3
USER root
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
echo 'Asia/Shanghai' >/etc/timezone
ADD id_rsa /root/.ssh/id_rsa
ADD config.json /root/.docker/config.json
ADD get-docker.sh /get-docker.sh
RUN echo " StrictHostKeyChecking no" >> /etc/ssh/sshd_config &&\
/get-docker.sh
#指定aliyun镜像
/get-docker.sh --mirror Aliyun
docker build . -t harbor.od.com/infra/jenkins:v2.190.3
docker push harbor.od.com/infra/jenkins:v2.190.3
创建infra名称空间
kubectl create namespace infra
创建secret
kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=admin --docker-password=Harbor12345 -n infra
准备共享存储
yum install nfs-utils -y
cat /etc/exports
/data/nfs-volume 10.4.7.0/24(rw,no_root_squash)
mkdir -p /data/nfs-volume
systemctl start nfs
systemctl enable nfs
jenkins资源配置清单
mkdir /data/k8s-yaml/jenkins && mkdir /data/nfs-volume/jenkins_home && cd /data/k8s-yaml/jenkins
/data/k8s-yaml/jenkins下:
cat deployment.yaml
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: jenkins
namespace: infra
labels:
name: jenkins
spec:
replicas: 1
selector:
matchLabels:
name: jenkins
template:
metadata:
labels:
app: jenkins
name: jenkins
spec:
volumes:
- name: data
nfs:
server: hdss7-200
path: /data/nfs-volume/jenkins_home
- name: docker
hostPath:
path: /run/docker.sock
type: ''
containers:
- name: jenkins
image: harbor.od.com/infra/jenkins:v2.190.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
protocol: TCP
env:
- name: JAVA_OPTS
value: -Xmx512m -Xms512m
volumeMounts:
- name: data
mountPath: /var/jenkins_home
- name: docker
mountPath: /run/docker.sock
imagePullSecrets:
- name: harbor
securityContext:
runAsUser: 0
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
revisionHistoryLimit: 7
progressDeadlineSeconds: 600
cat svc.yaml
kind: Service
apiVersion: v1
metadata:
name: jenkins
namespace: infra
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
selector:
app: jenkins
cat ingress.yaml
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: jenkins
namespace: infra
spec:
rules:
- host: jenkins.od.com
http:
paths:
- path: /
backend:
serviceName: jenkins
servicePort: 80
kubectl apply -f http://k8s-yaml.od.com/jenkins/deployment.yaml
kubectl apply -f http://k8s-yaml.od.com/jenkins/svc.yaml
kubectl apply -f http://k8s-yaml.od.com/jenkins/ingress.yaml
配置dns解析
cat /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2020053007 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
$TTL 60 ; 1 minute
dns A 10.4.7.11
harbor A 10.4.7.200
k8s-yaml A 10.4.7.200
traefik A 10.4.7.10
dashboard A 10.4.7.10
zk1 A 10.4.7.11
zk2 A 10.4.7.12
zk3 A 10.4.7.21
jenkins A 10.4.7.10
jenkins登录
admin
admin123
Jenkins配置
configure global security
manager plugin
安装Blue Ocean插件
Blue Ocean
命令行测试Jenkins
kubectl exec -it -n infra jenkins-54b8469cf9-tllzq -- /bin/bash
whoami
docker login harbor.od.com
ssh -i /root/.ssh/id_rsa -T git@gitee.com
java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
安装maven
HDSS7-200.host.com上
tar xf apache-maven-3.6.1-bin.tar.gz -C /data/nfs-volume/jenkins_home/
mv apache-maven-3.6.1 maven-3.6.1-8u232
vim /data/nfs-volume/jenkins_home/maven-3.6.1-8u232/conf/settings.xml
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
制作dubbo微服务的底包镜像
docker pull stanleyws/jre8:8u112
docker tag fa3a085d6ef1 harbor.od.com/public/jre8:8u112
docker push harbor.od.com/public/jre8:8u112
mkdir /data/dockerfile/jre8
vim /data/dockerfile/jre8/Dockerfile
FROM harbor.od.com/public/jre8:8u112
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
echo 'Asia/Shanghai' >/etc/timezone
ADD config.yml /opt/prom/config.yml
ADD jmx_javaagent-0.3.1.jar /opt/prom/
WORKDIR /opt/project_dir
ADD entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]
cat config.yml
---
rules:
- pattern: '.*'
此jar包收集jvm运行状态
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar -O jmx_javaagent-0.3.1.jar
entrypoint脚本
cat entrypoint.sh
#!/bin/sh
M_OPTS="-Duser.timezone=Asia/Shanghai -javaagent:/opt/prom/jmx_javaagent-0.3.1.jar=$(hostname -i):${M_PORT:-"12346"}:/opt/prom/config.yml"
C_OPTS=${C_OPTS}
JAR_BALL=${JAR_BALL}
exec java -jar ${M_OPTS} ${C_OPTS} ${JAR_BALL}
构建镜像
build . -t harbor.od.com/base/jre8:8u112
docker push harbor.od.com/base/jre8:8u112
https://gitee.com/stanleywang/dubbo-demo-service
配置New job
dubbo-demo
Discard old builds
- Days to keep builds : 3
- Max # of builds to keep : 30
Add Parameter -> String Parameter
Name : app_name
Default Value :
Description : project name. e.g: dubbo-demo-service
Add Parameter -> String Parameter
Name : image_name
Default Value :
Description : project docker image name. e.g: app/dubbo-demo-service
Add Parameter -> String Parameter
Name : git_repo
Default Value :
Description : project git repository. e.g: https://gitee.com/stanleywang/dubbo-demo-service.git
Add Parameter -> String Parameter
Name : git_ver
Default Value :
Description : git commit id of the project.
Add Parameter -> String Parameter
Name : add_tag
Default Value :
Description : project docker image tag, date_timestamp recommended. e.g: 190117_1920
Add Parameter -> String Parameter
Name : mvn_dir
Default Value : ./
Description : project maven directory. e.g: ./
Add Parameter -> String Parameter
Name : target_dir
Default Value : ./target
Description : the relative path of target file such as .jar or .war package. e.g: ./dubbo-server/target
Add Parameter -> String Parameter
Name : mvn_cmd
Default Value : mvn clean package -Dmaven.test.skip=true
Description : maven command. e.g: mvn clean package -e -q -Dmaven.test.skip=true
Add Parameter -> Choice Parameter
Name : base_image
Default Value :
base/jre7:7u80
base/jre8:8u112
Description : project base image list in harbor.od.com.
Add Parameter -> Choice Parameter
Name : maven
Default Value :
3.6.0-8u181
3.2.5-6u025
2.2.1-6u025
Description : different maven edition.
Pipeline Script
pipeline {
agent any
stages {
stage('pull') { //get project code from repo
steps {
sh "git clone ${params.git_repo} ${params.app_name}/${env.BUILD_NUMBER} && cd ${params.app_name}/${env.BUILD_NUMBER} && git checkout ${params.git_ver}"
}
}
stage('build') { //exec mvn cmd
steps {
sh "cd ${params.app_name}/${env.BUILD_NUMBER} && /var/jenkins_home/maven-${params.maven}/bin/${params.mvn_cmd}"
}
}
stage('package') { //move jar file into project_dir
steps {
sh "cd ${params.app_name}/${env.BUILD_NUMBER} && cd ${params.target_dir} && mkdir project_dir && mv *.jar ./project_dir"
}
}
stage('image') { //build image and push to registry
steps {
writeFile file: "${params.app_name}/${env.BUILD_NUMBER}/Dockerfile", text: """FROM harbor.od.com/${params.base_image}
ADD ${params.target_dir}/project_dir /opt/project_dir"""
sh "cd ${params.app_name}/${env.BUILD_NUMBER} && docker build -t harbor.od.com/${params.image_name}:${params.git_ver}_${params.add_tag} . && docker push harbor.od.com/${params.image_name}:${params.git_ver}_${params.add_tag}"
}
}
}
}
构建
Pipeline dubbo-demo
This build requires parameters:
app_name
dubbo-demo-service
项目名称, 例: dubbo-demo-service
image_name
app/dubbo-demo-service
docker镜像名称,例:app/dubbo-demo-service
git_repo
https://gitee.com/stanleywang/dubbo-demo-service 项目所在的git中央仓库的地址,例如:https://gitee.com/stanleywang/dubbo-demo-service.git
git_ver
master
项目在git中央仓库所对应的项目的分支或版本号
add_tag
200605_1708
docker镜像标签的一部分,日期时间戳, 例如:200605_1630
mvn_dir
./
编译项目的目录,默认为项目的根目录
target_dir
./dubbo-server/target
编译完成项目后,产生的jar/war包所在的目录
mvn_cmd
mvn clean package -Dmaven.test.skip=true
执行编译所用的命令
部署
创建app名称空间
kubectl create namespace app
创建secret(在app名称空间中),为pull镜像使用
kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=admin --docker-password=Harbor12345 -n app
资源清单
cat deployment.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:master_200605_1708
ports:
- containerPort: 20880
protocol: TCP
env:
- name: JAR_BALL
value: dubbo-server.jar
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
部署
应用之前要确保zookeeper是正常的
kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-service/deployment.yaml
登录zk查看
/opt/zookeeper/bin/zkCli.sh -server localhost:2181
...省略若干
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 1] ls /
[dubbo, zookeeper]
[zk: localhost:2181(CONNECTED) 2] ls /dubbo
[com.od.dubbotest.api.HelloService]
dubbo-monitor工具
https://github.com/Jeromefromcn/dubbo-monitor
HDSS7-200.host.com上:
unzip dubbo-monitor-master.zip
mv dubbo-monitor-master dubbo-monitor
修改配置
vim /opt/src/dubbo-monitor/dubbo-monitor-simple/conf/dubbo_origin.properties
##
# Copyright 1999-2011 Alibaba Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
dubbo.container=log4j,spring,registry,jetty
dubbo.application.name=dubbo-monitor
dubbo.application.owner=OldboyEdu
dubbo.registry.address=zookeeper://zk1.od.com:2181?backup=zk2.od.com:2181,zk3.od.com:2181
dubbo.protocol.port=20880
dubbo.jetty.port=8080
dubbo.jetty.directory=/dubbo-monitor-simple/monitor
dubbo.charts.directory=/dubbo-monitor-simple/charts
dubbo.statistics.directory=/dubbo-monitor-simple/statistics
dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN
制作镜像
准备环境
修改启动脚本
cat start.sh
#!/bin/bash
sed -e "s/{ZOOKEEPER_ADDRESS}/$ZOOKEEPER_ADDRESS/g" /dubbo-monitor-simple/conf/dubbo_origin.properties > /dubbo-monitor-simple/conf/dubbo.properties
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/conf
SERVER_NAME=`sed '/dubbo.application.name/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
SERVER_PROTOCOL=`sed '/dubbo.protocol.name/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
SERVER_PORT=`sed '/dubbo.protocol.port/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
LOGS_FILE=`sed '/dubbo.log4j.file/!d;s/.*=//' conf/dubbo.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$1" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$1" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`java -version 2>&1 | grep -i 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx128m -Xms128m -Xmn32m -XX:PermSize=16m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms128m -Xmx128m -XX:PermSize=16m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
exec java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main > $STDOUT_FILE 2>&1
修改以上脚本一个命令
sed -r -i -e '/^nohup/{p;:a;N;$!ba;d}' ./dubbo-monitor-simple/bin/start.sh && sed -r -i -e "s%^nohup(.*)%exec \1%" ./dubbo-monitor-simple/bin/start.sh
cp -a dubbo-monitor /data/dockerfile/
cd /data/dockerfile/dubbo-monitor/
cat /data/dockerfile/dubbo-monitor/Dockerfile
FROM jeromefromcn/docker-alpine-java-bash
MAINTAINER Jerome Jiang
COPY dubbo-monitor-simple/ /dubbo-monitor-simple/
CMD /dubbo-monitor-simple/bin/start.sh
build镜像
docker build . -t harbor.od.com/infra/dubbo-monitor:latest
docker push harbor.od.com/infra/dubbo-monitor:latest
解析域名
cat /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2020053008 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
$TTL 60 ; 1 minute
dns A 10.4.7.11
harbor A 10.4.7.200
k8s-yaml A 10.4.7.200
traefik A 10.4.7.10
dashboard A 10.4.7.10
zk1 A 10.4.7.11
zk2 A 10.4.7.12
zk3 A 10.4.7.21
jenkins A 10.4.7.10
dubbo-monitor A 10.4.7.10
准备k8s资源配置清单
mkdir /data/k8s-yaml/dubbo-monitor
vi /data/k8s-yaml/dubbo-monitor/deployment.yaml
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: dubbo-monitor
namespace: infra
labels:
name: dubbo-monitor
spec:
replicas: 1
selector:
matchLabels:
name: dubbo-monitor
template:
metadata:
labels:
app: dubbo-monitor
name: dubbo-monitor
spec:
containers:
- name: dubbo-monitor
image: harbor.od.com/infra/dubbo-monitor:latest
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 20880
protocol: TCP
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
vi /data/k8s-yaml/dubbo-monitor/svc.yaml
kind: Service
apiVersion: v1
metadata:
name: dubbo-monitor
namespace: infra
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: dubbo-monitor
vi /data/k8s-yaml/dubbo-monitor/ingress.yaml
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: dubbo-monitor
namespace: infra
spec:
rules:
- host: dubbo-monitor.od.com
http:
paths:
- path: /
backend:
serviceName: dubbo-monitor
servicePort: 8080
应用资源配置清单
kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/deployment.yaml
kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/svc.yaml
kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/ingress.yaml
浏览器访问:
http://dubbo-monitor.od.com/
dubbo服务消费者(dubbo-demo-consumer)
app_name
dubbo-demo-consumer
项目名称, 例: dubbo-demo-service
image_name
app/dubbo-demo-consumer
docker镜像名称,例:app/dubbo-demo-service
git_repo
git@gitee.com:stanleywang/dubbo-demo-web.git
项目所在的git中央仓库的地址,例如:https://gitee.com/stanleywang/dubbo-demo-service.git
git_ver
master
项目在git中央仓库所对应的项目的分支或版本号
add_tag
200606_1131
docker镜像标签的一部分,日期时间戳, 例如:200605_1630
mvn_dir
./
编译项目的目录,默认为项目的根目录
target_dir
./dubbo-client/target
编译完成项目后,产生的jar/war包所在的目录
mvn_cmd
mvn clean package -e -q -Dmaven.test.skip=true
执行编译所用的命令
- Dubbo微服务
- 注册中心zookeeper(集群)
- 提供者(集群)
- 消费者(集群)
- 监控(dubbo-monitor/dubbo-admin)
- 在K8S内交付dubbo微服务
- 有可用的K8S集群
- 部署zk集群(通常放在K8S集群外,有状态)
- 部署Jenkins(以容器的形式交付在K8S集群内)
- root、时区、ssh-key、docker客户端、harbor连接配置
- 部署maven软件
- 制作dubbo微服务底包
- 配置Jenkins持续构建(CI)流水线
- 使用流水线构建项目,查看harbor仓库
- 使用资源配置清单,交付项目到K8S集群