Kubernetes-Jenkins奴隶离线 [英] Kubernetes - Jenkins slaves are offline

查看:203
本文介绍了Kubernetes-Jenkins奴隶离线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用kubernetes运行jenkins.我能够使用jenkins kubernetes插件成功连接到kubernetes.现在,我正在运行一个管道示例,但是在运行时,我总是会收到一条错误消息:

I am trying to run jenkins with kubernetes. I am able to make a successful connection to kubernetes using jenkins kubernetes plugin. Now, I am running a pipeline example, but while running, I always get an error saying:

Still waiting to schedule task
‘default-amd64-cm2rx’ is offline

它挂在那里.如果使用kubectl get pods检查Pod,则发现Pod default-amd64-cm2rx正在运行,然后状态更改为Completed,然后消失了.然后,另一个具有相同名称的Pod开始并结束,并且循环继续进行.这些吊舱的最后状态如下:

And it hangs there. If I check pods using kubectl get pods, I see that the pod default-amd64-cm2rx was running, then state changed to completed and then it was gone. Then another pod with similar name, started and finished and the cycle continues. The last state of these pods come as:

Normal  Created    10s   kubelet, xx.xx.xx.xx  Created container
Normal  Started    10s   kubelet, xx.xx.xx.xx  Started container

如果我查看詹金斯日志,则会收到错误消息:

If I check the jenkins logs, I get an error as:

Mar 09, 2019 8:47:42 AM org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher launch
WARNING: Error in provisioning; agent=KubernetesSlave name: default-amd64-g5bgh, template=PodTemplate{inheritFrom='', name='default-amd64', namespace='', label='jenkins-latest-jenkins-slave-amd64', nodeSelector='beta.kubernetes.io/arch=amd64', nodeUsageMode=NORMAL, workspaceVolume=EmptyDirWorkspaceVolume [memory=false], volumes=[HostPathVolume [mountPath=/var/run/docker.sock, hostPath=/var/run/docker.sock]], containers=[ContainerTemplate{name='jnlp', image='myregistry;8500/jenkins-slave:latest', workingDir='/home/jenkins', command='/bin/sh -c', args='cat', resourceRequestCpu='200m', resourceRequestMemory='256Mi', resourceLimitCpu='200m', resourceLimitMemory='256Mi', livenessProbe=org.csanchez.jenkins.plugins.kubernetes.ContainerLivenessProbe@1e7ac0a6}], yaml=}
java.lang.IllegalStateException: Pod has terminated containers: default/default-amd64-g5bgh (jnlp)
    at org.csanchez.jenkins.plugins.kubernetes.AllContainersRunningPodWatcher.periodicAwait(AllContainersRunningPodWatcher.java:149)
    at org.csanchez.jenkins.plugins.kubernetes.AllContainersRunningPodWatcher.periodicAwait(AllContainersRunningPodWatcher.java:170)
    at org.csanchez.jenkins.plugins.kubernetes.AllContainersRunningPodWatcher.await(AllContainersRunningPodWatcher.java:122)
    at org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher.launch(KubernetesLauncher.java:121)
    at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:293)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

这是我的kuebrnetes插件配置:

Here is my kuebrnetes plugin config:

因此,您可以看到连接成功,并且Pod正在生成.

As, you can see the connection is successful, and the pod is spawning.

有人知道为什么它保持离线状态吗? TIA.

Any idea why it stays offline? TIA.

推荐答案

jnlp可能试图对奴隶和Kubernetes使用相同的端口,因为看起来您的pod正在终止,并且您正在奴隶上运行此作业.将jnlp设置为使用随机端口,这样就可以保证不发生冲突.

jnlp might be trying to use the same port for slave and Kubernetes, since it looks like your pod is terminating and you’re running this job on a slave. Set jnlp to use random port so that you can guarantee no collisions.

在Jenkins中,它位于配置安全性"下.

In Jenkins, it’s under Configure Security.

来自Jenkins文档: https://jenkins.io/doc/book/managing/security/

From Jenkins Documentation: https://jenkins.io/doc/book/managing/security/

JNLP TCP端口

JNLP TCP Port

Jenkins使用TCP端口与通过JNLP协议启动的代理(例如基于Windows的代理)进行通信.从Jenkins 2.0开始,默认情况下此端口为禁用状态.

Jenkins uses a TCP port to communicate with agents launched via the JNLP protocol, such as Windows-based agents. As of Jenkins 2.0, by default this port is disabled.

对于希望使用基于JNLP的代理的管理员,两个端口选项是:

For administrators wishing to use JNLP-based agents, the two port options are:

随机:JNLP端口是随机选择的,以避免在Jenkins主服务器上发生冲突.随机JNLP端口的不利之处在于,它们是在Jenkins主服务器启动时选择的,因此很难管理允许JNLP流量的防火墙规则.

Random: The JNLP port is chosen random to avoid collisions on the Jenkins master. The downside to randomized JNLP ports is that they’re chosen during the boot of the Jenkins master, making it difficult to manage firewall rules allowing JNLP traffic.

已修复:JNLP端口由Jenkins管理员选择,并且在Jenkins主服务器重新启动后保持一致.这样可以更轻松地管理防火墙规则,从而允许基于JNLP的代理连接到主服务器.

Fixed: The JNLP port is chosen by the Jenkins administrator and is consistent across reboots of the Jenkins master. This makes it easier to manage firewall rules allowing JNLP-based agents to connect to the master.

这篇关于Kubernetes-Jenkins奴隶离线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆