Kubernetes Jenkins connectivity Issue

12/20/2018

I set up the kubernetes on EC2 instances over ubuntu platform, everything working fine. But now I have deployed a Jenkins pod, after that, I am able to access the Jenkins in the browser. Now my question is how can I connect Jenkins with my machine.

My Jenkins pod IP:- 10.43.0.8

My Kubernetes Master private IP:- 192.168.105.229

I am able to ping with each other. But how I can access my master machine using Jenkins, so I can create the pods through Jenkins.

IMG1](https://i.stack.imgur.com/k7nEY.png) IMG2](https://i.stack.imgur.com/30q8j.png)

-- Mohit Thakur
azure-kubernetes
jenkins
jenkins-pipeline
jenkins-plugins
kubernetes

2 Answers

1/2/2019

If you want to access a pod running in Kubernetes you need to expose it as a service and possibly an ingress resource https://kubernetes.io/docs/concepts/services-networking/service/

-- csanchez
Source: StackOverflow

12/21/2018

There are a few ways to do this. A couple that I can think of:

  • Use the Jenkins Kubernetes Plugin. If you install this on your Jenkins master (which is also running on a pod) and also if you configure it to talk to the same Kubernetes cluster (meaning the kube-apiserver) then you can create/remove pods using the plugin. More on how to configure authentication and RBAC in Kubernetes

  • Manually configure Jenkins slaves running as 'user'. Then on the 'user's some directory create a ~/.kube/config that has the configuration to talk to your Kubernetes cluster. From there you can just issue kubectl commands to create/remove pods. You would still need to configure authentication/RBAC.

-- Rico
Source: StackOverflow