简体   繁体   English

在 Jenkins 上设置 Kubernetes 插件

[英]Setting up the Kubernetes Plugin on Jenkins

I've been struggling with setting up the Jenkins Kubernetes Plugin on the Google Container Engine.我一直在努力在 Google Container Engine 上设置 Jenkins Kubernetes 插件。

I have the plugin installed but I think all my builds are still running on master.我已经安装了插件,但我认为我的所有构建仍在 master 上运行。

I haven't found any good documentation or guides on configuring this.我还没有找到任何关于配置它的好的文档或指南。

UPDATE更新

I removed the master executor from my Jenkins image.我从我的 Jenkins 映像中删除了主执行程序。 So now my builds aren't running on master but now they have no executor so they don't run at all.所以现在我的构建不在 master 上运行,但现在它们没有执行器,所以它们根本不运行。 Just waits in the queue forever.只是永远在队列中等待。

You'll need to tell Jenkins how and where to run your builds by adding your Kubernetes cluster as a 'cloud' in the Jenkins configuration. 您需要通过在Jenkins配置中将Kubernetes集群添加为“云”来告诉Jenkins如何以及在何处运行构建。 Go to Manage Jenkins -> Configure System -> Cloud -> Add new cloud and select 'Kubernetes'. 转到Manage Jenkins -> Configure System -> Cloud -> Add new cloud并选择'Kubernetes'。 You'll find the server certificate key, user name and password in your local kubectl configuration (usually in ~/.kube/config ). 您可以在本地kubectl配置中找到服务器证书密钥,用户名和密码(通常在~/.kube/config )。 The values for 'Kubernetes URL' and 'Jenkins URL' depend on your cluster setup. “Kubernetes URL”和“Jenkins URL”的值取决于您的群集设置。

Next, you'll need to configure the docker images that should be used to run your builds by selecting 'Add Docker Template'. 接下来,您需要通过选择“添加Docker模板”来配置应该用于运行构建的docker镜像。 Use labels to define which tasks should be run with which image! 使用标签来定义应该使用哪个图像运行哪些任务!

Here 'sa good video tutorial and here you'll find a nice tutorial which explains everything in detail. 是一个很好的视频教程, 在这里你会找到一个很好的教程,详细解释一切。

The important bit after you've installed the plugin, set up access to your Kubernetes cluster, and set up your first Kubernetes Pod Template with a label like jnlp-slave , is that in your Jenkinsfile you need to begin with something like node('jnlp-slave') {} . 安装插件之后的重要一点,设置对Kubernetes集群的访问权限,并设置第一个带有jnlp-slave标签的Kubernetes Pod模板,就是在你的Jenkins文件中,你需要从node('jnlp-slave') {}开始node('jnlp-slave') {} Then the pod will be started when you trigger a build. 然后,当您触发构建时,将启动窗格。

There's also a helm chart for easy deployment if that helps :)如果有帮助,还有一个易于部署的舵图:)

This example might also help once you've set the plugin up too.一旦你设置了插件, 这个例子也可能会有所帮助。

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

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