Jenkins Failed to connect to http://xxx:8080/tcpSlaveAgentListener/: Connection refused (Connection refused)

介绍


K8s集群上运行的Jenkins报这个错SEVERE: Failed to connect to http://172.25.42.235:8081/tcpSlaveAgentListener/: Connection refused (Connection refused)
构建时创建Pod失败,后一直循环创建Jenkins-slave
在这里插入图片描述

排查错误


查看Jenkins服务日志

[root@k8s-master01 jenkins]# kubectl get pod -n devops|grep jenkins
jenkins-app-7b4ff4c854-zpcd2         1/1     Running   5          105d
[root@k8s-master01 jenkins]# kubectl logs -f jenkins-app-7b4ff4c854-zpcd2 -n devops

发现如下报错

Jan 10, 2022 2:24:13 AM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: Failed to connect to http://172.25.42.235:8081/tcpSlaveAgentListener/: Connection refused (Connection refused)
java.io.IOException: Failed to connect to http://172.25.42.235:8081/tcpSlaveAgentListener/: Connection refused (Connection refused)
	at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:217)
	at hudson.remoting.Engine.innerRun(Engine.java:693)
	at hudson.remoting.Engine.run(Engine.java:518)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:607)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
	at sun.net.www.http.HttpClient.New(HttpClient.java:339)
	at sun.net.www.http.HttpClient.New(HttpClient.java:357)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1226)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:990)
	at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:214)

报错原因


由于把Jenkins的访问方式由 nodeport 改也了 clusterip + ingress-nginx 方式,之前的IP地址 变也了域名,所以Jenkins 报错

SEVERE: Failed to connect to http://172.25.42.235:8081/tcpSlaveAgentListener/: Connection refused (Connection refused)
java.io.IOException: Failed to connect to http://172.25.42.235:8081/tcpSlaveAgentListener/: Connection refused (Connection refused)

修改K8s访问Jenkins 地址


1. 系统管理-节点管理

在这里插入图片描述

2. 节点管理-Configure Clouds

在这里插入图片描述

3. Configure Clouds-Kubernetes Cloud details

在这里插入图片描述

4. Kubernetes Cloud details-Jenkins 地址

在这里插入图片描述

总结


Jenkins访问地址改了,Kubernetes Cloud details上访问

版权声明:本文为作者原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原创文章,作者:老C,如若转载,请注明出处:https://www.code404.icu/1557.html

发表评论

登录后才能评论