Kubernetes pod is unable to connect or ping the host ip it's running on. Works fine when pinging other machines on the same network as the host

1.1k views Asked by At

I am unable to connect to my Jenkins master (running outside the cluster) from a pod running on the same machine as the Jenkins master instance.

When the pods run from another host machine, ping/connection works fines.

I'm using flannel. The only thing I can see is the this host IP address is in the cni.conf file configured in the exception list for OutBoundNAT endpoint Policy.

How can I run a Jenkins Agent pod on the same host as the Jenkins master if I cannot connect the IP of the host from the pod it's running on?

Thanks,

1

There are 1 answers

1
Sam On

You need to assign the pods to that specific node.

There are so many ways to do that but you can test by using NodeSelector.

Example:

spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    key1: value1
    key2: value2

Which your node should have similar key and value in the labels.

To check nodes labels you can use:

kubectl get nodes --show-labels

To add a label to node:

kubectl label nodes <your-node-name> <label>

Example:

kubectl label nodes worker-2.example.com color=blue

for full and different examples you can check this link.

https://gist.github.com/devops-school/3da18faede22b18ac7013c404bc10740

Goodluck!