day4-----k8s之交付dubbo服务的monitor(2)
回顾第一步pull代码第二步编译代码第三步打包第四步做docker镜像[root@hdss7-200 dubbo-demo-service]# cd /opt/src/[root@hdss7-200 src]# wget https://github.com/Jeromefromcn/dubbo-monitor/archive/master.zip--2021-09-03 00:06:44--ht
·
回顾
第一步pull代码
第二步编译代码
第三步打包
第四步做docker镜像
[root@hdss7-200 dubbo-demo-service]# cd /opt/src/
[root@hdss7-200 src]# wget https://github.com/Jeromefromcn/dubbo-monitor/archive/master.zip
--2021-09-03 00:06:44-- https://github.com/Jeromefromcn/dubbo-monitor/archive/master.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/Jeromefromcn/dubbo-monitor/zip/master [following]
--2021-09-03 00:06:45-- https://codeload.github.com/Jeromefromcn/dubbo-monitor/zip/master
Resolving codeload.github.com (codeload.github.com)... 13.229.189.0
Connecting to codeload.github.com (codeload.github.com)|13.229.189.0|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: ‘master.zip’
[ <
2021-09-03 00:07:19 (681 KB/s) - ‘master.zip’ saved [23468109]
[root@hdss7-200 src]# ll
total 598276
-rw-r--r-- 1 root root 9136463 Sep 4 2019 apache-maven-3.6.1-bin.tar.gz
-rw-r--r-- 1 root root 580021898 May 24 23:37 harbor-offline-installer-v1.8.3.tgz
-rw-r--r-- 1 root root 23468109 Sep 3 00:07 master.zip
[root@hdss7-200 src]# mv master.zip dubbo-monitor-master.zip
[root@hdss7-200 src]# unzip dubbo-monitor-master.zip
[root@hdss7-200 src]# ll
total 598280
-rw-r--r-- 1 root root 9136463 Sep 4 2019 apache-maven-3.6.1-bin.tar.gz
drwxr-xr-x 3 root root 4096 Jul 27 2016 dubbo-monitor-master
-rw-r--r-- 1 root root 23468109 Sep 3 00:07 dubbo-monitor-master.zip
-rw-r--r-- 1 root root 580021898 May 24 23:37 harbor-offline-installer-v1.8.3.tgz
[root@hdss7-200 src]# mv dubbo-monitor-master dubbo-monitor
[root@hdss7-200 src]# cd dubbo-monitor/
[root@hdss7-200 dubbo-monitor]# ll
total 12
-rw-r--r-- 1 root root 155 Jul 27 2016 Dockerfile
drwxr-xr-x 5 root root 4096 Jul 27 2016 dubbo-monitor-simple
-rw-r--r-- 1 root root 16 Jul 27 2016 README.md
[root@hdss7-200 dubbo-monitor]# cd dubbo-monitor-simple/
[root@hdss7-200 dubbo-monitor-simple]# ls
bin conf lib
[root@hdss7-200 dubbo-monitor-simple]# cd conf/
[root@hdss7-200 conf]# ls
dubbo_origin.properties
[root@hdss7-200 conf]# vi dubbo_origin.properties
[root@hdss7-200 conf]# cat 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
[root@hdss7-200 conf]# vi dubbo_origin.properties
[root@hdss7-200 conf]# cd ..
[root@hdss7-200 dubbo-monitor-simple]# ll
total 12
drwxr-xr-x 2 root root 4096 Jul 27 2016 bin
drwxr-xr-x 2 root root 4096 Sep 3 00:38 conf
drwxr-xr-x 2 root root 4096 Jul 27 2016 lib
[root@hdss7-200 dubbo-monitor-simple]# cd ..
[root@hdss7-200 dubbo-monitor]# ll
total 12
-rw-r--r-- 1 root root 155 Jul 27 2016 Dockerfile
drwxr-xr-x 5 root root 4096 Jul 27 2016 dubbo-monitor-simple
-rw-r--r-- 1 root root 16 Jul 27 2016 README.md
[root@hdss7-200 dubbo-monitor]#
下面需要更改下启动脚本
[root@hdss7-200 ~]# cd /opt/src/dubbo-monitor/dubbo-monitor-simple
[root@hdss7-200 dubbo-monitor-simple]# cd bin/
[root@hdss7-200 bin]# ls
dump.sh restart.sh server.sh start.bat start.sh stop.sh
[root@hdss7-200 bin]# vi start.sh
[root@hdss7-200 bin]# 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
[root@hdss7-200 bin]# cd ..
[root@hdss7-200 dubbo-monitor-simple]# ll
total 12
drwxr-xr-x 2 root root 4096 Sep 3 18:50 bin
drwxr-xr-x 2 root root 4096 Sep 3 00:38 conf
drwxr-xr-x 2 root root 4096 Jul 27 2016 lib
[root@hdss7-200 dubbo-monitor-simple]# cd ..
[root@hdss7-200 dubbo-monitor]# ll
total 12
-rw-r--r-- 1 root root 155 Jul 27 2016 Dockerfile
drwxr-xr-x 5 root root 4096 Jul 27 2016 dubbo-monitor-simple
-rw-r--r-- 1 root root 16 Jul 27 2016 README.md
[root@hdss7-200 dubbo-monitor]# cd ..
[root@hdss7-200 src]# ll
total 598280
-rw-r--r-- 1 root root 9136463 Sep 4 2019 apache-maven-3.6.1-bin.tar.gz
drwxr-xr-x 3 root root 4096 Jul 27 2016 dubbo-monitor
-rw-r--r-- 1 root root 23468109 Sep 3 00:07 dubbo-monitor-master.zip
-rw-r--r-- 1 root root 580021898 May 24 23:37 harbor-offline-installer-v1.8.3.tgz
[root@hdss7-200 src]# cp -a dubbo-monitor /data/dockerfile/
[root@hdss7-200 src]# cd /data/dockerfile/
[root@hdss7-200 dockerfile]# ll
total 12
drwxr-xr-x 3 root root 4096 Jul 27 2016 dubbo-monitor
drwxr-xr-x 2 root root 4096 Sep 1 00:08 jenkins
drwxr-xr-x 2 root root 4096 Sep 1 22:36 jre8
[root@hdss7-200 dockerfile]# cd dubbo-monitor/
[root@hdss7-200 dubbo-monitor]# ll
total 12
-rw-r--r-- 1 root root 155 Jul 27 2016 Dockerfile
drwxr-xr-x 5 root root 4096 Jul 27 2016 dubbo-monitor-simple
-rw-r--r-- 1 root root 16 Jul 27 2016 README.md
[root@hdss7-200 dubbo-monitor]# ca t Dockerfile
bash: ca: command not found...
Similar commands are::
'ac'
'sa'
[root@hdss7-200 dubbo-monitor]# cat Dockerfile
FROM jeromefromcn/docker-alpine-java-bash
MAINTAINER Jerome Jiang
COPY dubbo-monitor-simple/ /dubbo-monitor-simple/
CMD /dubbo-monitor-simple/bin/start.sh
[root@hdss7-200 dubbo-monitor]#
然后开始bulid镜像
[root@hdss7-200 dubbo-monitor]# docker build . -t harbor.od.com/infra/dubbo-monitor:latest
Sending build context to Docker daemon 26.21MB
Step 1/4 : FROM jeromefromcn/docker-alpine-java-bash
latest: Pulling from jeromefromcn/docker-alpine-java-bash
Image docker.io/jeromefromcn/docker-alpine-java-bash:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
420890c9e918: Pull complete
a3ed95caeb02: Pull complete
4a5cf8bc2931: Pull complete
6a17cae86292: Pull complete
4729ccfc7091: Pull complete
Digest: sha256:658f4a5a2f6dd06c4669f8f5baeb85ca823222cb938a15cfb7f6459c8cfe4f91
Status: Downloaded newer image for jeromefromcn/docker-alpine-java-bash:latest
---> 3114623bb27b
Step 2/4 : MAINTAINER Jerome Jiang
---> Running in 0a757ca4a586
Removing intermediate container 0a757ca4a586
---> 7881163266c0
Step 3/4 : COPY dubbo-monitor-simple/ /dubbo-monitor-simple/
---> 518aabde3f64
Step 4/4 : CMD /dubbo-monitor-simple/bin/start.sh
---> Running in dca2d123d3d4
Removing intermediate container dca2d123d3d4
---> b84a6be98ae6
Successfully built b84a6be98ae6
Successfully tagged harbor.od.com/infra/dubbo-monitor:latest
[root@hdss7-200 dubbo-monitor]# docker push harbor.od.com/infra/dubbo-monitor:latest
The push refers to repository [harbor.od.com/infra/dubbo-monitor]
790586f21147: Pushed
6c05aa02bec9: Pushed
1bdff01a06a9: Pushed
5f70bf18a086: Mounted from public/pause
e271a1fb1dfc: Pushed
c56b7dabbc7a: Pushed
latest: digest: sha256:e90c2e46f939533d09b0268606665b5325aecd74a848c38e55c0a2624d60c648 size: 2400
[root@hdss7-200 dubbo-monitor]#
准备资源配置清单
[root@hdss7-200 dubbo-monitor]# cd /data/k8s-yaml/
[root@hdss7-200 k8s-yaml]# mkdir dubbo-monitor
[root@hdss7-200 k8s-yaml]# cd dubbo-monitor/
[root@hdss7-200 dubbo-monitor]# vi dp.yaml
[root@hdss7-200 dubbo-monitor]# vi svc.yaml
[root@hdss7-200 dubbo-monitor]# vi ingress.yaml
[root@hdss7-200 dubbo-monitor]# cat dp.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
[root@hdss7-200 dubbo-monitor]# cat svc.yaml
kind: Service
apiVersion: v1
metadata:
name: dubbo-monitor
namespace: infra
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: dubbo-monitor
[root@hdss7-200 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@hdss7-200 dubbo-monitor]#
开始在21上启动服务pod
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/dp.yaml
deployment.extensions/dubbo-monitor created
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/svc.yaml
service/dubbo-monitor created
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/ingress.yaml
ingress.extensions/dubbo-monitor created
[root@hdss7-21 ~]#
然后在dashboard上能看到已经有pod产生了
想要访问页面是需要解析dns的,下面进行dns解析
[root@hdss7-11 ~]# vi /var/named/od.com.zone
[root@hdss7-11 ~]# cat /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2021052308 ; 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
[root@hdss7-11 ~]# systemctl restart named
[root@hdss7-11 ~]# dig -t A dubbo-monitor.od.com @10.4.7.11 +short
10.4.7.10
[root@hdss7-11 ~]#
在浏览器上就能看到了dubbo-monitor.od.com
点status可以看到它的一些基本信息
然后可以查看它的接口是在哪里,应该是能看到下面两个,service是提供者,若是提供者有问题就不能出现下面的service
更多推荐
已为社区贡献14条内容
所有评论(0)