0

I am running a Jenkins docker container, which I want to configure the Kubernetes plugin which requires passing kubeconfig file. How can I point the kubeconfig file in my local machine to the Jenkins running in the container? I am running the k3d Kubernetes cluster on my host machine.

DevOps_DS
  • 65
  • 3
  • 6

1 Answers1

1

You can mount the host directory to the container.

So your host directory will be accessible inside the Jenkins container and you can access the files also.

This way just mount your .kube folder to Jenkins container, which is storing the kubeconfig file. And you can use that path in jenkin config.

Create a home directory for Jenkins in the host.

 sudo mkdir /mykubeconfig

copy-paste the kubeconfig file inside above created directory

Run the latest Jenkins container using the following command.

 docker run  -d -p 8080:8080 -p 50000:50000 -v /mykubeconfig:/var/jenkins_home jenkins

Now you will be able to access jenkins on host port 8080.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102