<p>I have my on premise kubernetes cluster.
I want to setup CD with jenkins.
I have tried two plugins which are available for kubernetes deployment.</p>

<ol>
<li>Kubernetes Continuous Deploy Plugin</li>
<li>Kubernetes plugin</li>
</ol>

<blockquote>
  <p>The question here is, jenkins master will require the .kube/config
  file to connect to the kubernetes cluster for doing deployments.</p>
</blockquote>

<p>Is this the best practice to copy the .kube/config file of your kubernetes master to jenkins master to provide full acesss of your kubernetes cluster for deployment purpose.</p>

<p>Please do let me know if you have any other suggestions for my <strong>ON-PREM kubernetes cluster CD</strong>.</p>

Sarang Rana
<p>you have two options
1. put all kubeconfig files in a separate git repo, say, kubeVault .git, and name the files using cluster name. Accept cluster as build paramter in jenkins. Lookup the respective kubeconfig from kubeVault repo and use it as target platform and deploy the container. We have used this approach in one of the project. you need to build some logic in the pipeline groovy code</p>

<ol start="2">
<li>define build parameters and set them using the fields from kubeconfig file. post build generate actual kubeconfig file from build params and keep it in /tmp directory. pass the kubeconfig location to kubectl to deploy the k8s obejects/pod</li>
</ol>
