简体   繁体   English

使用 docker 代理在 k8s 和管道上的 Jenkins

[英]Jenkins on k8s and pipeline with docker agent

I want to run my Jenkins behind k8s.我想在 k8s 后面运行我的 Jenkins。 We can achieve that with any standard helm chart or our own manifest files.我们可以使用任何标准的舵图或我们自己的清单文件来实现这一点。 In this case, Jenkins (master only) will run inside a container (Pod).在这种情况下,Jenkins(仅限主机)将在容器(Pod)内运行。

Now I also want to have a pipeline job that uses docker agent as described here现在我还想要一个使用 docker 代理的管道作业,如此所述

I am getting confused, about我越来越困惑,关于

  • how and where this docker container will be run (on the same node where Jenkins is running? and suppose the node capacity is over then it needs to run docker agent on a different node)这个 docker 容器将如何以及在哪里运行(在 Jenkins 运行的同一节点上?假设节点容量已经结束,那么它需要在不同节点上运行 docker 代理)
  • how does Jenkins will authenticate to run containers on k8s nodes? Jenkins 如何进行身份验证以在 k8s 节点上运行容器?
  • I saw the Kubernetes plugin/docker plugin.我看到了 Kubernetes 插件/docker 插件。 But those plugins create containers beforehand ( or at least we need to set up a template, which decides how containers will start, which image will be used and many more ) and connects Jenkins with help of JNLP / ssh.但是这些插件预先创建容器(或者至少我们需要设置一个模板,它决定容器将如何启动,将使用哪个图像等等)并在 JNLP / ssh 的帮助下连接 Jenkins。 I lose the flexibility to have an image as an agent in that case.在这种情况下,我失去了将形象作为代理人的灵活性。
  • going further, I also like to build custom images on the fly with help of Dockerfile shipped along with code.更进一步,我还喜欢在随代码一起提供的 Dockerfile 的帮助下即时构建自定义图像。 An example is available in the same link .同一链接中提供了一个示例。

I believe this documentation is answering all of your questions: https://devopscube.com/jenkins-build-agents-kubernetes/我相信这个文档可以回答你所有的问题: https://devopscube.com/jenkins-build-agents-kubernetes/

With this method, you are not loosing your flexibility because your Jenkins master going to create K8s pod on the fly.使用这种方法,您不会失去灵活性,因为您的 Jenkins master 将动态创建 K8s pod。 Yes, additionally you need JNLP authentication but you can think that as sidecar container.是的,另外您需要 JNLP 身份验证,但您可以将其视为边车容器。

About your first question: If you use exactly that way, your Jenkins jobs going to run under Jenkins master with the same Docker that your Jenkins Master is using.关于您的第一个问题:如果您使用这种方式,您的 Jenkins 作业将在 Jenkins 主控下运行,并且您的 Z2E3ADAE54334C0A3AACE25 使用相同的 Docker。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM