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

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

问题描述

我正在尝试使用 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 正在运行,然后状态更改为已完成,然后它就消失了.然后另一个具有相似名称的 pod 开始和完成,循环继续.这些 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

如果我检查 jenkins 日志,我会收到如下错误:

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.

来自詹金斯文档: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:

Random:随机选择 JNLP 端口以避免与 Jenkins master 发生冲突.随机 JNLP 端口的缺点是它们是在 Jenkins master 启动期间选择的,这使得管理允许 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 slaves 离线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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