Implementation of CD with Jenkins for on premise kubernetes cluster?

2/1/2019

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.

  1. Kubernetes Continuous Deploy Plugin
  2. Kubernetes plugin

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

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.

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

-- Sarang Rana
continuous-deployment
jenkins
jenkins-plugins
kubernetes

1 Answer

2/1/2019

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

  1. 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
-- P Ekambaram
Source: StackOverflow