Running minikube cluster as jenkins agent

I have a container instance: jenkins, and kubernetes cluster: minikube both running on my local machine. I can’t figure out a way to integrate minikube in jenkins. Below is how i set things up.

Setup Minikube
    - minikube start
    - replace cert and key values in .kube/config with hardcoded data

Setup Jenkins 
    - docker run --name jenkins -v jenkins_home:/var/jenkins_home -d -p 8080:8080 -p 50000:50000 --network minikube jenkins/jenkins:lts

Integrate Kubernetes in Jenkins 
    - install kubernetes plugin 
    - configure cloud -> add a new cloud -> kubernetes -> kubernetes cloud details  
        - create credential: secret file, use the file with .kube/config
        - click test connection -> Error testing connection : java.net.ConnectException: Failed to connect to /127.0.0.1:{port}

I’ve been stuck with this problem for a few good days and it’s driving me insane. My jenkins instance is already running in the same network with the minikube.

each container will have its own ip, and its own localhost, so 127.0.0.1 means the jenkins container, not the k8s controller. You’ll probably want to use the external ip.

I don’t know if there’s a dynamic way of getting it. I’ve always had a static ip for my k8s controller.

127.0.0.1 is actually the ip im getting from ‘‘kubectl cluster-info’’ that’s why i’m certain it’s from k8s

yea, normally 127.0.0.1 means localhost, as in “this computer”
inside a docker container though, 127.0.0.1 means this container
So unless you are running kubernetes inside of the jenkins container (or not using a jenkins container), 127.0.0.1 isn’t right.

The error message is clearly saying it can’t connect to 127.0.0.1 port 58711