I want to deploy Jenkins on a local Kubernetes cluster (no cloud). I will create 2 services above Jenkins. One service of type NodePort for port 8080
(be mapped on random port and I can access it outside the cluster. I can also access it inside the cluster by using ClusterIP:8080
). All fine.
My second service is so my Jenkins slaves can connect. I choose for a ClusterIP (default) as type of my service:
I read about the 3 types of services:
Exposes the service on a cluster-internal IP. Choosing this value makes the service only reachable from within the cluster.
Here is my .yml
to create the services:
kind: Service
apiVersion: v1
metadata:
name: jenkins-ui
namespace: ci
spec:
type: NodePort
selector:
app: master
ports:
- protocol: TCP
port: 8080
targetPort: 8080
name: master
---
kind: Service
apiVersion: v1
metadata:
name: jenkins-discovery
namespace: ci
spec:
#type: ClusterIP
selector:
app: jenkins
ports:
- protocol: TCP
port: 50000
targetPort: 50000
name: slaves
The problem is that my slaves can not connect to port 50000. I tried to telnet the ClusterIP:port
of the service jenkins-discovery and I got a connection refused. I can telnet to ClusterIP:port
of the jenkins-ui service. What am I doing wrong or is there a part I don't understand?
It's solved. The mistake was the selector which is a part which wasn't that clear for me. I was using different nodeselectors what seemed to cause this issue. This worked:
kind: Service
apiVersion: v1
metadata:
name: jenkins-ui
namespace: ci
spec:
type: NodePort
selector:
app: master
ports:
- protocol: TCP
port: 8080
targetPort: 8080
name: master
---
kind: Service
apiVersion: v1
metadata:
name: jenkins-discovery
namespace: ci
spec:
#type: ClusterIP
selector:
app: master
ports:
- protocol: TCP
port: 50000
targetPort: 50000
name: slaves