Kubernetes automation by build servers.
Automation can be done using the Kubernetes CLI, the kubectl. See the official documentation.
It is crucial to be independent between the jobs / builds.
The default location for the kubectl configuration is $HOME/.kube/
When all jobs are executed with the same user, this will possibly effect other jobs.
Logging into a Kubernetes cluster can modify that configuration.
Define the kubectl configuration location to be inside the workspace.
The environment variable name is KUBECONFIG.
Environment example:
export KUBECONFIG=$(pwd)/.kube
Jenkins pipeline example:
pipeline {
environment {
KUBECONFIG="${pwd()}/.kube"
}
...
}