https://mirrors.tuna.tsinghua.edu.cn/
清华大学镜像源
用这个镜像
root@master:~# docker images | grep harbor.wyh.net/baseimages/linux37-centos7.6-jdk
harbor.wyh.net/baseimages/linux37-centos7.6-jdk 8u212 78c62ab880f6 6 days ago 949MB
修改名称
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# mv jenkins.war jenkins-2.190.1.war
修改镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# vim Dockerfile
#Jenkins Version 2.164.3
FROM harbor.wyh.net/baseimages/linux37-centos7.6-jdk:8u212
MAINTAINER zhangshijie zhangshijie@magedu.net
ADD jenkins-2.190.1.war /apps/jenkins/
ADD run_jenkins.sh /usr/bin/
EXPOSE 8080
CMD ["/bin/run_jenkins.sh"]
增加可执行权限
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# chmod a+x *.sh
修改版本号
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# vim run_jenkins.sh
#!/bin/bash
cd /apps/jenkins && java -server -Xms1024m -Xmx1024m -Xss512k -jar jenkins-2.190.1.war --webroot=/apps/jenkins/jenkins-data --httpPort=8080
修改镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# vim build-command.sh
#!/bin/bash
docker build -t harbor.wyh.net/linux37/jenkins:v2.190.1 .
echo "镜像制作完成,即将上传至Harbor服务器"
sleep 1
docker push harbor.wyh.net/linux37/jenkins:v2.190.1
echo "镜像上传完成"
执行基础镜像
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# bash build-command.sh
后台运行
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# docker run -it -d -p 8901:8080 harbor.wyh.net/linux37/jenkins:v2.190.1
进入到容器里
root@master:/opt/k8s-data/dockerfile/linux37/jenkins# docker exec -it 69d50f8ab2d1f177c29f2fa3c7f86a521bbce609a6063590895347498f644c7a bash
把/root/.jenkins/放在后段存储上
[root@69d50f8ab2d1 ~]# ls /apps/jenkins/jenkins-data/
这个jenkins数据放在后段存储上
请从本地复制密码并粘贴到下面。
[root@a4289d376b5e yum.repos.d]# cat /root/.jenkins/secrets/initialAdminPassword
df95025a534e43cb8ad7dbdde7d928ff
访问端口
创建两个数据目录
root@haproxy1:~# mkdir /data/k8sdata/linux37/jenkins-root-data
root@haproxy1:~# mkdir /data/k8sdata/linux37/jenkins-data
修改镜像地址
root@master:/opt/k8s-data/yaml/linux37/jenkins# vim /opt/k8s-data/yaml/linux37/jenkins/jenkins.yaml
20 image: harbor.wyh.net/linux37/jenkins:v2.190.1
修改nfs服务器地址
root@master:/opt/k8s-data/yaml/linux37/jenkins/pv# vim jenkins-persistentvolume.yaml
---
apiVersion: v1
kind: PersistentVolume
metadata:
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-datadir-pv
namespace: linux37
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce
nfs:
server: 192.168.200.201
path: /data/k8sdata/linux37/jenkins-data
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-root-datadir-pv
namespace: linux37
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce
nfs:
server: 192.168.200.201
path: /data/k8sdata/linux37/jenkins-root-data
root@master:/opt/k8s-data/yaml/linux37/jenkins/pv# vim jenkins-persistentvolumeclaim.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: jenkins-datadir-pvc
namespace: linux37
spec:
volumeName: jenkins-datadir-pv
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 80Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: jenkins-root-data-pvc
namespace: linux37
spec:
volumeName: jenkins-root-datadir-pv
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 80Gi
root@master:/opt/k8s-data/yaml/linux37/jenkins/pv# kubectl apply -f jenkins-persistentvolume.yaml
先创建pv然后创建pvc
root@master:/opt/k8s-data/yaml/linux37/jenkins/pv# kubectl apply -f .
安装插件
删除jenkins容器
root@master:/opt/k8s-data/yaml/linux37/jenkins/pv# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4289d376b5e harbor.wyh.net/linux37/jenkins:v2.190.1 "/bin/run_jenkins.sh" 45 minutes ago Up 45 minutes 0.0.
root@master:/opt/k8s-data/yaml/linux37/jenkins/pv# docker rm -fv a4289d376b5e
root@master:/opt/k8s-data/yaml/linux37/jenkins# kubectl apply -f jenkins.yaml
进入到pod里
root@master:/opt/k8s-data/yaml/linux37/jenkins# kubectl exec -it linux37-jenkins-deployment-6c4b997f8-j2vw5 bash -n linux37
查看挂载信息
[root@linux37-jenkins-deployment-6c4b997f8-j2vw5 /]# df -Th | grep 192
192.168.200.201:/data/k8sdata/linux37/jenkins-root-data nfs4 98G 7.3G 86G 8% /root/.jenkins
192.168.200.201:/data/k8sdata/linux37/jenkins-data nfs4 98G 7.3G 86G 8% /apps/jenkins/jenkins-data
查看密钥
[root@linux37-jenkins-deployment-6c4b997f8-j2vw5 /]# cat /root/.jenkins/secrets/initialAdminPassword
e6a985ee2ce64436958c16079c496053
把插件拖过去
解压插件,插件有问题
root@haproxy1:/data/k8sdata/linux37/jenkins-root-data/plugins# tar xf jenkins-2.176.3-plugins-day2.tar.gz
进入pod
[root@linux37-jenkins-deployment-6c4b997f8-j2vw5 /]# java -server -Xms1024m -Xmx1024m -Xss512k -jar jenkins-2.190.1.war --webroot=/ap
启用jenkins
[root@linux37-jenkins-deployment-6c4b997f8-j2vw5 jenkins]# java -server -Xms1024m -Xmx1024m -Xss512k -jar jenkins-2.190.1.war --webroot=/apps/jenkins/jenkins-data --httpPort=8080
修改镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/provider# vim Dockerfile
#JDK Base Image
FROM harbor.wyh.net/baseimages/linux37-centos7.6-jdk:8u212
MAINTAINER zhangshijie "zhangshijie@magedu.net"
RUN yum install file nc -y
RUN mkdir -p /apps/dubbo/provider && useradd tomcat
ADD dubbo-demo-provider-2.1.5/ /apps/dubbo/provider
ADD run_java.sh /apps/dubbo/provider/bin
RUN chown tomcat.tomcat /apps -R
修改镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/provider# cat build-command.sh
#!/bin/bash
docker build -t harbor.wyh.net/linux37/dubbo-demo-provider:v2 .
sleep 3
docker push harbor.wyh.net/linux37/dubbo-demo-provider:v2
查看zookeeper地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/provider/dubbo-demo-provider-2.1.5# kubectl get service -n linux37 | grep zook
zookeeper ClusterIP 10.20.240.70 <none> 2181/TCP 47h
zookeeper1 NodePort 10.20.176.109 <none> 2181:42181/TCP,2888:61129/TCP,3888:60205/TCP 47h
zookeeper2 NodePort 10.20.199.253 <none> 2181:42182/TCP,2888:34907/TCP,3888:63351/TCP 47h
zookeeper3 NodePort 10.20.67.102 <none> 2181:42183/TCP,2888:49614/TCP,3888:51469/TCP 47h
创建busybox
root@master:/etc/ansible/manifests/dns/kube-dns# kubectl apply -f busybox.yaml
解析地址
root@master:/etc/ansible/manifests/dns/kube-dns# kubectl exec busybox nslookup zookeeper2
Server: 10.20.254.254
Address 1: 10.20.254.254 kube-dns.kube-system.svc.linux37.local
nslookup: can't resolve 'zookeeper2'
command terminated with exit code 1
修改zookper地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/provider# vim dubbo-demo-provider-2.1.5/conf/dubbo.properties
20 dubbo.registry.address=zookeeper://zookeeper1.linux37.svc.linux37.local:2181 | zookeeper://zookeeper2.linux37.svc.linux37.local:2181 | zookeeper://zookeep er3.linux37.svc.linux37.local:2181
打镜像
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/provider# bash build-command.sh
修改镜像地址
root@master:/opt/k8s-data/yaml/linux37/dubbo/provider# vim provider.yaml
20 image: harbor.wyh.net/linux37/dubbo-demo-provider:v2
创建provider
root@master:/opt/k8s-data/yaml/linux37/dubbo/provider# kubectl apply -f provider.yaml
进入到pod里
root@master:/opt/k8s-data/yaml/linux37/dubbo/provider# kubectl exec -it linux37-provider-deployment-5c5565c65b-hrxg9 bash -n linux37
修改zookerp地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/provider# vim dubbo-demo-provider-2.1.5/conf/dubbo.properties
20 dubbo.registry.address=zookeeper://zookeeper1.linux37.svc.linux37.local:2181 | zookeeper://zookeeper2.linux37.svc.linux37.local:2181 | zookeeper://zookeeper3.linux37.svc.linux 37.local:2181
修改消费者的镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/consumer# vim Dockerfile
FROM harbor.wyh.net/baseimages/linux37-centos7.6-jdk:8u212
修改镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/consumer# vim build-command.sh
#!/bin/bash
docker build -t harbor.wyh.net/linux37/dubbo-demo-consumer:v1 .
sleep 3
docker push harbor.wyh.net/linux37/dubbo-demo-consumer:v1
执行安装
root@master:/opt/k8s-
data/dockerfile/linux37/dubbo/consumer# bash build-command.sh
修改镜像地址
root@master:/opt/k8s-data/yaml/linux37/dubbo/consumer# vim consumer.yaml
20 image: harbor.wyh.net/linux37/dubbo-demo-consumer:v1
创建pod
root@master:/opt/k8s-data/yaml/linux37/dubbo/consumer# kubectl apply -f consumer.yaml
[root@linux37-provider-deployment-5c5565c65b-xhmkf log]# cd /apps/dubbo/provider/logs/stdout.log
查看日志信息
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/consumer# kubectl exec -it linux37-provider-deployment-5c5565c65b-xhmkf bash -n linux37
[root@linux37-provider-deployment-5c5565c65b-xhmkf logs]# tail -f stdout.log
[08:10:32] Hello world561, request from consumer: /172.31.104.168:50564
这个地址是消费者的pod地址
查看注册的生产者和消费者的信息
修改镜像地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/dubboadmin# vim Dockerfile
FROM harbor.wyh.net/linux37/linux37-centos7.6-tomcat:8.5.45
修改build地址
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/dubboadmin# vim build-command.sh
#!/bin/bash
TAG=$1
docker build -t harbor.wyh.net/linux37/dubboadmin:${TAG} .
sleep 3
docker push harbor.wyh.net/linux37/dubboadmin:${TAG}
修改启动脚本的内存大小
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/dubboadmin# vim catalina.sh
98 JAVA_OPTS="-server -Xms512m -Xmx512m -Xss512k -Xmn1g -XX:CMSInitiatingOccupancyFraction=65 -XX:+UseFastAccessorMethods -XX:+AggressiveOpts -XX:+Us eBiasedLocking -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=10 -XX:NewSize=2048M -XX:MaxNewSize=2048M -XX:NewRatio=2 -XX:PermSize=128m -XX:MaxPe rmSize=512m -XX:CMSFullGCsBeforeCompaction=5 -XX:+ExplicitGCInvokesConcurrent -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnable d -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods"
root@master:/opt/k8s-
修改zookper的地址
data/dockerfile/linux37/dubbo/dubboadmin# vim dubboadmin/WEB-INF/dubbo.properties
dubbo.registry.address=zookeeper://zookeeper1.linux37.svc.linux37.local:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
打镜像
root@master:/opt/k8s-data/dockerfile/linux37/dubbo/dubboadmin# bash build-command.sh v1
修改镜像地址
root@master:/opt/k8s-data/yaml/linux37/dubbo/dubboadmin# vim dubboadmin.yaml
19 - name: linux37-dubboadmin-spec
20 image: harbor.wyh.net/linux37/dubboadmin:v1
创建dubboadmin
root@master:/opt/k8s-data/yaml/linux37/dubbo/dubboadmin# kubectl apply -f dubboadmin.yaml
进入到pod里
root@master:/opt/k8s-data/yaml/linux37/dubbo/dubboadmin# kubectl exec -it linux37-dubboadmin-deployment-8f95966f6-4xgbj bash -n linux37
查看短裤
[root@linux37-dubboadmin-deployment-8f95966f6-fpmnz /]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 1 127.0.0.1:8005 0.0.0.0:*
LISTEN 0 100 0.0.0.0:8009 0.0.0.0:*
LISTEN 0 100 0.0.0.0:8080 0.0.0.0:*
访问dubboadmin账户密码都是root
查看对应都ip地址
网友评论