Jenkins Kubernetes静态agent节点的构建

网友投稿 764 2022-11-30

Jenkins Kubernetes静态agent节点的构建

Jenkins Kubernetes静态agent节点的构建

k8s部署静态节点

在命令行中启动节点 java -jar agent.jar -jnlpUrl -secret 942d7e769a43f65388751ee954af20e90fa0c5f8bdb19e0584db4cc61adab8ba -workDir "/var/jenkins"Run from agent command line, with the secret stored in a file: echo 942d7e769a43f65388751ee954af20e90fa0c5f8bdb19e0584db4cc61adab8ba > secret-filejava -jar agent.jar -jnlpUrl -secret @secret-file -workDir "/var/jenkins"

我们不需要对agent创建service去访问它,这就是一个执行引擎,执行完了挂掉 。

[root@master cicd]# cat agent.yaml kind: DeploymentapiVersion: apps/v1metadata: labels: k8s-app: jenkinsagent name: jenkinsagent namespace: devopsspec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: k8s-app: jenkinsagent template: metadata: labels: k8s-app: jenkinsagent namespace: devops name: jenkinsagent spec: containers: - name: jenkinsagent image: jenkins/inbound-agent securityContext: privileged: true imagePullPolicy: IfNotPresent resources: limits: cpu: 1000m memory: 2Gi requests: cpu: 500m memory: 512Mi env: - name: JENKINS_URL value: - name: JENKINS_SECRET value: 942d7e769a43f65388751ee954af20e90fa0c5f8bdb19e0584db4cc61adab8ba - name: JENKINS_AGENT_NAME value: build-02 - name: JENKINS_AGENT_WORKDIR value: /home/jenkins/workspace

[root@master cicd]# kubectl apply -f agent.yaml deployment.apps/jenkinsagent created[root@master cicd]# kubectl get pod -n devopsNAME READY STATUS RESTARTS AGEjenkins-797ccbdbc5-84jdl 1/1 Running 0 13mjenkinsagent-586d9594-8pn9w 1/1 Running 0 8s[root@master cicd]# kubectl logs -f jenkinsagent-586d9594-8pn9w -n devopsOct 28, 2021 3:22:40 AM hudson.remoting.jnlp.Main createEngineINFO: Setting up agent: build-02Oct 28, 2021 3:22:40 AM hudson.remoting.jnlp.Main$CuiListener INFO: Jenkins agent is running in headless mode.Oct 28, 2021 3:22:41 AM hudson.remoting.Engine startEngineINFO: Using Remoting version: 4.11Oct 28, 2021 3:22:41 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDirINFO: Using /home/jenkins/workspace/remoting as a remoting work directoryOct 28, 2021 3:22:41 AM org.jenkinsci.remoting.engine.WorkDirManager setupLoggingINFO: Both error and output logs will be printed to /home/jenkins/workspace/remotingOct 28, 2021 3:22:41 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: Locating server among [28, 2021 3:22:41 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolveINFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]Oct 28, 2021 3:22:41 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: Agent discovery successful Agent address: 139.198.166.235 Agent port: 50000 Identity: 67:e8:d2:73:d1:cf:01:f6:6c:a4:cb:b3:0f:25:8c:3dOct 28, 2021 3:22:41 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: HandshakingOct 28, 2021 3:22:41 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: Connecting to 139.198.166.235:50000Oct 28, 2021 3:22:41 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: Trying protocol: JNLP4-connectOct 28, 2021 3:22:41 AM org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader runINFO: Waiting for ProtocolStack to start.Oct 28, 2021 3:22:42 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: Remote identity confirmed: 67:e8:d2:73:d1:cf:01:f6:6c:a4:cb:b3:0f:25:8c:3dOct 28, 2021 3:22:42 AM hudson.remoting.jnlp.Main$CuiListener statusINFO: Connected

同样的,这个agent pod里面是没有mvn这些构建工具的,可以使用卷的形式挂载进去。或者使用这个镜像作为基础镜像将工具打入到这个镜像里面更加方便。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Jenkins Docker静态agent节点的构建
下一篇:内存 解决k8s集群环境内存不足导致容器被kill问题
相关文章

 发表评论

暂时没有评论,来抢沙发吧~