Jenkins updating PODs on Kubernetes

9/20/2018

During a search on updating PODs in a Kubernetes cluster I found a Jenkis plugin called kubernetes-cd, however, I am in doubt about how to establish a secure connection with the plugin and Kubernetes and would like to know how to set up a user and password or register an ssh key in the cluster that allows this external connection?

I found in the Kubernetes documentation on Secrets(link), but I'm not sure if it serves only for internal cluster authentication or if it serves to set up accounts for plugin connections or other external media.

-- user2831852
jenkins-pipeline
jenkins-plugins
kubernetes

1 Answer

9/20/2018

Kubernetes-cd 3 options are supported:

  1. Authenticate with Kube config file - Get the kubeconfig file from the workspace path.
  2. Fetch cluster details through SSH connection to the master node - Get the ~/.kube/config file through an SSH connection to the master node.
  3. Fill credentials details directly - Fill the contents in kubeconfig file directly.

You need configure ~/.kube/config on you runner.

Example:

echo "$KUBE_CA_CERT" > /ca.pem
kubectl config set-cluster cluster --server=${KUBE_MASTER_URL} --certificate-authority=/ca.pem
kubectl config set-credentials user --token=${KUBE_TOKEN}
kubectl config set-context context --cluster=cluster --user=user
kubectl config use-context context
-- Arslanbekov
Source: StackOverflow