java8 安装
下载地址
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
按装
tar -zxvf jdk-1.8_linux-x64_bin.tar.gz -C /usr/local && ln -sv /usr/local/jdk-12.0.2 /usr/local/jdk-1.8 && echo "export PATH=$PATH:/usr/local/jdk-1.8/bin" >/etc/profile.d/java.sh source /etc/profile.d/java.sh
maven安装
下载地址
http://mirror.bit.edu.cn/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
安装
cd /usr/local/ && wget -c wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.0.5/source/apache-maven-3.0.5-src.tar.gz && tar -zxf apache-maven-3.0.5-bin.tar.gz && echo "export PATH=$PATH:/usr/local/apache-maven-3.0.5/bin" > /etc/profile.d/maven.sh && source /etc/profile.d/maven.sh
git安装
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc-c++ perl-ExtUtils-MakeMaker wget autoconf -y wget https://www.kernel.org/pub/software/scm/git/git-2.7.3.tar.gz tar xf git-2.7.3.tar.gz cd git-2.7.3 make configure ./configure --prefix=/usr/local/git make profix=/usr/local/git make install echo "export PATH=$PATH:/usr/local/git/bin" > /etc/profile.d/git.sh source /etc/profile.d/git.sh
dokcer私有仓库安装
https://www.cnblogs.com/Tempted/p/7768694.html
gitlab
https://www.cnblogs.com/straycats/p/7637373.html
https://www.cnblogs.com/cheng95/p/8037865.html
dockerfile
https://blog.csdn.net/u010075335/article/details/82861377
jenkins安装
tomcat 下载地址
http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
jenkins 下载地址
http://mirrors.jenkins.io/war-stable/latest/jenkins.war
tomcat发布jenkins
从官网下载 jenkins.war 至 $CATALINA_BASE/webapps,Tomcat 会自动部署;
浏览器访问:http://centos:8080/jenkins/
安装插件
gitlab ssh maven gitee
链接码云
https://www.jianshu.com/p/420ad5aea199
https://www.cnblogs.com/xiao987334176/p/11425560.html
java代码
https://gitee.com/pyhanwei/test.git
jenkins环境配置
java
maven
新建自由风格项目
此步骤需要先配置好码云凭据
此步骤需要先配置好192.168.88.101的免密钥
cp -r $WORKSPACE /opt/
scp -r $WORKSPACE root@192.168.88.101:/tmp/git/
构建一个maven项目
在 master上部署 一个tomcat
需要事先配置私有仓库
ExecStart=/opt/kube/bin/dockerd --insecure-registry 192.168.88.101:5000
kubectl apply -f tomcat.yaml
cat tomcat.yaml
1 apiVersion: v1 2 kind: Service 3 metadata: 4 name: tomcat-service 5 spec: 6 type: NodePort 7 ports: 8 - name: tomcat 9 port: 8080 10 nodePort: 31002 11 targetPort: 8080 12 protocol: TCP 13 selector: 14 run: tomcat 15 --- 16 apiVersion: apps/v1 17 kind: Deployment 18 metadata: 19 creationTimestamp: null 20 labels: 21 run: tomcat 22 name: tomcat 23 spec: 24 replicas: 1 25 selector: 26 matchLabels: 27 run: tomcat 28 strategy: {} 29 template: 30 metadata: 31 creationTimestamp: null 32 labels: 33 run: tomcat 34 spec: 35 containers: 36 - image: 192.168.88.101:5000/tomcat:latest 37 name: tomcat 38 ports: 39 - containerPort: 8080 40 resources: {} 41 status: {}
配置maven
pom.xml clean package
cp -r $WORKSPACE /opt/ bash /opt/deploy_docker.sh
cat /opt/deploy_docker.sh
cat /opt/deploy_docker.sh #!/bin/bash IMAGE="192.168.88.101:5000/tomcat:latest" IM="192.168.88.101:5000/tomcat" MASTER="192.168.88.101" tag=$(date +%s) set -e cat << EOF > /opt/Dockerfile FROM $IMAGE #ADD COPY test-maven/* /usr/local/tomcat/webapps/ROOT/ EOF DOCKERFILE="/opt/Dockerfile" docker build -t="tomcat:$tag" /opt/. docker tag tomcat:$tag $IMAGE docker push $IMAGE ssh root@$MASTER kubectl delete -f /root/yaml/tomcat.yaml ssh root@$MASTER kubectl apply -f /root/yaml/tomcat.yaml #ssh root@$MASTER kubectl get pod -o wide |grep tomcat docker rmi -f $IMAGE docker rmi -f tomcat:$tag docker images |grep $IM |awk '{print $3}' |xargs docker rmi -f