赞
踩
dubbo-monitor工具
dubbo-monitor源码包:https://github.com/Jeromefromcn/dubbo-monitor.git
下载源码
[root@k8s7-200.host.com /opt/src]# unzip dubbo-monitor-master.zip
修改配置
cat /opt/src/dubbo-monitor/dubbo-monitor-simple/conf/dubbo_origin.properties
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.statistics.directory=/dubbo-monitor-simple/statistics
dubbo.log4j.file=logs/dubbo-monitor.log
优化脚本;
[root@k8s7-200.host.com /opt/src/dubbo-monitor/dubbo-monitor-simple/bin]# tail start.sh
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
[root@k8s7-200.host.com /opt/src]# cp -a dubbo-monitor /data/dockerfile/
[root@k8s7-200.host.com /data/dockerfile/dubbo-monitor]# docker build . -t harbor.od.com/infra/dubbo-monitor:latest
[root@k8s7-200.host.com /data/dockerfile/dubbo-monitor]# docker push harbor.od.com/infra/dubbo-monitor:latest
[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# pwd
/data/k8s-yaml/dubbo-monitor
1、[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# cat 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
2、[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# cat service.yaml
kind: Service
apiVersion: v1
metadata:
name: dubbo-monitor
namespace: infra
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: dubbo-monitor
clusterIP: None
type: ClusterIP
sessionAffinity: None
3、[root@k8s7-200.host.com /data/k8s-yaml/dubbo-monitor]# cat 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
[root@k8s7-21.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/deployment.yaml
[root@k8s7-21.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/service.yaml
[root@k8s7-21.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/ingress.yaml
[root@k8s7-11.host.name ~]# tail /var/named/od.com.zone
dubbo-monitor A 10.4.7.10
[root@k8s7-11.host.name ~]# systemctl restart named
缓存目录
root@jenkins-7c85c8cb57-m6cvg:~/.m2# pwd
/root/.m2
[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# pwd
/data/k8s-yaml/dubbo-demo-consume
1.[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# cat deployment.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:master_200814_1700
env:
- name: JAR_BALL
value: dubbo-client.jar
imagePullPolicy: IfNotPresent
imagePullSecrets:
- name: harbor
terminationGracePeriodSeconds: 30
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
revisionHistoryLimit: 7
progressDeadlineSeconds: 600
2.[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# cat service.yaml
kind: Service
apiVersion: v1
metadata:
name: dubbo-demo-consumer
namespace: app
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: dubbo-demo-consumer
3.[root@k8s7-200.host.com /data/k8s-yaml/dubbo-demo-consume]# cat ingress.yaml
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: dubbo-demo-consumer
namespace: app
spec:
rules:
- host: demo.od.com
http:
paths:
- path: /
backend:
serviceName: dubbo-demo-consumer
servicePort: 8080
应用资源配置清单
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consume/deployment.yaml
deployment.extensions/dubbo-demo-consumer created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consume/service.yaml
service/dubbo-demo-consumer created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-demo-consume/ingress.yaml
ingress.extensions/dubbo-demo-consumer created
[root@k8s7-11.host.name ~]# tail /var/named/od.com.zone
demo A 10.4.7.10
[root@k8s7-11.host.name ~]# dig -t A demo.od.com @10.4.7.11 +short
10.4.7.10
http://demo.od.com/hello?name=yinwucheng
项目介绍:
dubb-demo-service和consumer就是典型的无状态服务,k8s最易管理的就是无状态服务,可以无限弹性扩容;目前前端业务已经由3个服务支撑,可承受更大的并发,这是dubbo自己提供的负载均衡机制;consumer扩容是由k8s来做的,ingress机制(找一个service对应两个不同的pod,通过标签选择器)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。