码迷,mamicode.com
首页 > 其他好文 > 详细

外部Jenkins调用容器中Slave配置实践

时间:2018-12-20 19:00:21      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:amp   宕机   dns   nohup   home   agent   出现   tla   pat   

1.Jenkins配置

实现动态生成的Slave节点并调用,解决构建项目出现slave节点任务堵塞或者是slave宕机问题。容器平台采用openshift。

参考配置文档:https://blog.csdn.net/felix_yujing/article/details/78725142

参考配置文档:https://www.imooc.com/article/35851

 

1.1 jenkins jnlp配置

技术分享图片

 

 

1.2.Kubernetes配置

名称: 默认使用Kubernetes即可

Kubernetes地址: 填写paas平台地址

Kubernetes证书: 填写paas平台中名称空间中的jenkins的secret中的token,选择ca.crt内容。

Kubernetes命名空间: 填写jenkins的项目空间 。

凭据: 通证书一样的获取方式,只不过获取的不再试ca.crt内容,而是token。复制创建jenkins的凭据,凭据选择secret text格式。

技术分享图片

技术分享图片

 2.Jenkins Slave配置

2.1 Dockerfile

镜像仓库:https://hub.docker.com/search/?q=openshift%20jenkins%20slave%20&type=image

FROM registry.it.com/openshift/jenkins-jnlp-slave:latest
USER root
 
RUN rm -fr /usr/share/jenkins/slave.jar
RUN rm -fr /usr/local/bin/jenkins-slave
 
COPY agent.jar /usr/share/jenkins/agent.jar
COPY jenkins-slave /usr/local/bin/jenkins-slave
 
RUN chmod 777 /usr/share/jenkins/agent.jar
RUN chmod 777 /usr/local/bin/jenkins-slave

 

2.2 JenkinsSlave脚本

#!/bin/bash
 
#env | grep "JENKINS" >>env.txt
#env | grep "JENKINS"
 
echo "[DEBUG] ----nohup java -jar /usr/share/jenkins/agent.jar -jnlpUrl ${JENKINS_URL}/computer/${JENKINS_AGENT_NAME}/slave-agent.jnlp -secret ${JENKINS_SECRET} -workDir /home/jenkins/agent >slave.log & -----"
 
 
java -jar /usr/share/jenkins/agent.jar -jnlpUrl ${JENKINS_URL}/computer/${JENKINS_AGENT_NAME}/slave-agent.jnlp -secret ${JENKINS_SECRET} -workDir "/home/jenkins/agent"

 

3.附加资料

jenkins slave pod的环境变量

技术分享图片
SSO_PORT_8443_TCP_ADDR=172.30.49.148
JENKINS_SECRET=0d5d47fe01f40be6a8619f15658c7ceabfb572dc8d0eaff81f09e8b7b7bc21be
KUBERNETES_PORT=tcp://172.30.0.1:443
GITLAB_CE_PORT_22_TCP_ADDR=172.30.101.86
GITLAB_CE_REDIS_SERVICE_PORT=6379
KUBERNETES_SERVICE_PORT=443
GITLAB_CE_REDIS_PORT=tcp://172.30.96.128:6379
JENKINS_JNLP_PORT=tcp://172.30.203.97:50000
JENKINS_JNLP_SERVICE_PORT=50000
TOMCAT_SERVICE_PORT_8080_TCP=tcp://172.30.83.232:8080
GITLAB_CE_REDIS_SERVICE_PORT_6379_REDIS=6379
GITLAB_CE_REDIS_PORT_6379_TCP_ADDR=172.30.96.128
SSO_PORT_8443_TCP_PORT=8443
HOSTNAME=jenkins-slave-3x91r-jng3h
CUS_SERVICE_PORT_8080_TCP_ADDR=172.30.126.105
SSO_PORT=tcp://172.30.49.148:8443
SSO_SERVICE_PORT=8443
GITLAB_CE_PORT_22_TCP_PORT=22
SSO_PORT_8443_TCP_PROTO=tcp
CUS_SERVICE_SERVICE_HOST=172.30.126.105
DEVOPS_SERVICE_PORT_35357_TCP=tcp://172.30.100.200:35357
GITLAB_CE_PORT_80_TCP_ADDR=172.30.101.86
JENKINS_JNLP_PORT_50000_TCP=tcp://172.30.203.97:50000
GITLAB_CE_PORT_22_TCP_PROTO=tcp
HOME=/home/jenkins
GITLAB_CE_REDIS_PORT_6379_TCP_PORT=6379
KUBERNETES_PORT_53_TCP_ADDR=172.30.0.1
GITLAB_CE_REDIS_PORT_6379_TCP_PROTO=tcp
CUS_SERVICE_PORT_8080_TCP_PORT=8080
JENKINS_PORT_80_TCP=tcp://172.30.217.110:80
CUS_SERVICE_PORT_8080_TCP_PROTO=tcp
GITLAB_CE_PORT_80_TCP_PORT=80
CUS_WEB_SERVICE_HOST=172.30.234.55
GITLAB_CE_PORT_80_TCP_PROTO=tcp
KUBERNETES_PORT_53_UDP_ADDR=172.30.0.1
KUBERNETES_PORT_53_TCP_PORT=53
KUBERNETES_PORT_53_TCP_PROTO=tcp
CUS_SERVICE_SERVICE_PORT=8080
CUS_SERVICE_PORT=tcp://172.30.126.105:8080
SSO_PORT_8443_TCP=tcp://172.30.49.148:8443
EUREKA_SERVICE_SERVICE_HOST=172.30.235.146
KUBERNETES_PORT_53_UDP_PORT=53
GATEWAY_SERVICE_SERVICE_HOST=172.30.61.82
KUBERNETES_SERVICE_PORT_DNS=53
KUBERNETES_PORT_53_UDP_PROTO=udp
GITLAB_CE_PORT_22_TCP=tcp://172.30.101.86:22
JAVA_VERSION=8u181
GATEWAY_SERVICE_PORT_9090_TCP_ADDR=172.30.61.82
GITLAB_CE_POSTGRESQL_PORT_5432_TCP_ADDR=172.30.120.59
GITLAB_CE_REDIS_PORT_6379_TCP=tcp://172.30.96.128:6379
CUS_SERVICE_PORT_8080_TCP=tcp://172.30.126.105:8080
DEVOPS_WEB_PORT_9002_TCP_ADDR=172.30.51.98
CUS_WEB_PORT=tcp://172.30.234.55:8088
DEVOPS_SERVICE_SERVICE_HOST=172.30.100.200
CUS_WEB_SERVICE_PORT=8088
GATEWAY_SERVICE_PORT_9090_TCP_PORT=9090
GITLAB_CE_PORT_80_TCP=tcp://172.30.101.86:80
CUS_WEB_PORT_8088_TCP_ADDR=172.30.234.55
GITLAB_CE_POSTGRESQL_SERVICE_HOST=172.30.120.59
CA_CERTIFICATES_JAVA_VERSION=20170531+nmu1
TERM=xterm
GITLAB_CE_POSTGRESQL_PORT_5432_TCP_PORT=5432
GATEWAY_SERVICE_PORT_9090_TCP_PROTO=tcp
EUREKA_SERVICE_PORT_8761_TCP_ADDR=172.30.235.146
KUBERNETES_PORT_443_TCP_ADDR=172.30.0.1
GATEWAY_SERVICE_SERVICE_PORT=9090
GATEWAY_SERVICE_PORT=tcp://172.30.61.82:9090
GITLAB_CE_POSTGRESQL_PORT_5432_TCP_PROTO=tcp
EUREKA_SERVICE_SERVICE_PORT=8761
EUREKA_SERVICE_PORT=tcp://172.30.235.146:8761
KUBERNETES_PORT_53_TCP=tcp://172.30.0.1:53
DEVOPS_WEB_PORT_9002_TCP_PORT=9002
DEVOPS_WEB_PORT_9002_TCP_PROTO=tcp
CUS_WEB_PORT_8088_TCP_PORT=8088
GITLAB_CE_SERVICE_PORT_22_SSH=22
JAVA_DEBIAN_VERSION=8u181-b13-2~deb9u1
AGENT_WORKDIR=/home/jenkins/agent
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_PORT_53_UDP=udp://172.30.0.1:53
DEVOPS_WEB_SERVICE_HOST=172.30.51.98
CUS_WEB_PORT_8088_TCP_PROTO=tcp
EUREKA_SERVICE_PORT_8761_TCP_PORT=8761
JENKINS_SERVICE_HOST=172.30.217.110
EUREKA_SERVICE_PORT_8761_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_PORT=443
DEVOPS_SERVICE_SERVICE_PORT=35357
DEVOPS_SERVICE_PORT=tcp://172.30.100.200:35357
KUBERNETES_PORT_443_TCP_PROTO=tcp
JENKINS_URL=http://10.130.210.151:8080/
GITLAB_CE_POSTGRESQL_PORT=tcp://172.30.120.59:5432
GITLAB_CE_POSTGRESQL_SERVICE_PORT=5432
LANG=C.UTF-8
JENKINS_AGENT_NAME=jenkins-slave-3x91r-jng3h
GATEWAY_SERVICE_PORT_9090_TCP=tcp://172.30.61.82:9090
KUBERNETES_SERVICE_PORT_DNS_TCP=53
GITLAB_CE_POSTGRESQL_PORT_5432_TCP=tcp://172.30.120.59:5432
GITLAB_CE_SERVICE_PORT_80_HTTP=80
DEVOPS_WEB_PORT=tcp://172.30.51.98:9002
DEVOPS_WEB_PORT_9002_TCP=tcp://172.30.51.98:9002
DEVOPS_WEB_SERVICE_PORT=9002
JENKINS_SERVICE_PORT=80
JENKINS_PORT=tcp://172.30.217.110:80
TOMCAT_SERVICE_PORT_8080_TCP_ADDR=172.30.83.232
TOMCAT_SERVICE_SERVICE_HOST=172.30.83.232
CUS_WEB_PORT_8088_TCP=tcp://172.30.234.55:8088
EUREKA_SERVICE_PORT_8761_TCP=tcp://172.30.235.146:8761
JENKINS_NAME=jenkins-slave-3x91r-jng3h
GITLAB_CE_SERVICE_HOST=172.30.101.86
KUBERNETES_PORT_443_TCP=tcp://172.30.0.1:443
KUBERNETES_SERVICE_PORT_HTTPS=443
DEVOPS_SERVICE_PORT_35357_TCP_ADDR=172.30.100.200
JENKINS_JNLP_PORT_50000_TCP_ADDR=172.30.203.97
TOMCAT_SERVICE_PORT_8080_TCP_PORT=8080
KUBERNETES_SERVICE_HOST=172.30.0.1
TOMCAT_SERVICE_PORT_8080_TCP_PROTO=tcp
JENKINS_SERVICE_PORT_WEB=80
GITLAB_CE_REDIS_SERVICE_HOST=172.30.96.128
JAVA_HOME=/docker-java-home
PWD=/home/jenkins
JENKINS_PORT_80_TCP_ADDR=172.30.217.110
JENKINS_JNLP_SERVICE_HOST=172.30.203.97
JENKINS_JNLP_SERVICE_PORT_AGENT=50000
DEVOPS_SERVICE_PORT_35357_TCP_PORT=35357
JENKINS_JNLP_PORT_50000_TCP_PORT=50000
TOMCAT_SERVICE_SERVICE_PORT=8080
JENKINS_JNLP_PORT_50000_TCP_PROTO=tcp
DEVOPS_SERVICE_PORT_35357_TCP_PROTO=tcp
TOMCAT_SERVICE_PORT=tcp://172.30.83.232:8080
SSO_SERVICE_HOST=172.30.49.148
JENKINS_PORT_80_TCP_PORT=80
GITLAB_CE_POSTGRESQL_SERVICE_PORT_5432_POSTGRESQL=5432
JENKINS_PORT_80_TCP_PROTO=tcp
GITLAB_CE_PORT=tcp://172.30.101.86:22
GITLAB_CE_SERVICE_PORT=22
View Code

 

外部Jenkins调用容器中Slave配置实践

标签:amp   宕机   dns   nohup   home   agent   出现   tla   pat   

原文地址:https://www.cnblogs.com/mascot1/p/10150542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!