When I installed kubectl on "client" Ubuntu VM, I was logged into default (ubuntu) account; therefore I placed the config file under the home directory of that (ubuntu) account:
/home/ubuntu/.kube/config
kubectl connects to a k8s cluster running on a remote VM (different VPC). I can access the cluster via kubectl while logged into the above ubuntu account fine.
Now I need to run kubectl commands as part of a Jenkins pipeline, where the user acccount would be jenkins. I'm currently getting this error when trying to deploy an application via Helm:
Error: Kubernetes cluster unreachable: the server could not find the requested resource
I looked it up and it seems to be because the user account here is different to where the config file is. There is NO config file under jenkins user home (within /var/lib/jenkins/.kube/).
That got me thinking as to the recommended way of configuring kubectl so that it could be used to connect to same cluster while logged into different user accounts (not just as part of running a pipeline - by jenkins user)
Is there any standard/best practice here? Or do I need to copy the same config file under each user's home directory (e.g. /var/lib/jenkins/.kube/)?