1 min read | by Jordi Prats
If we allow a pod to interact with the cluster's API, as long as we have kubectl installed on the container, we don't really need to worry about the kubeconfig file. Although some applications might complain is they don't find it, so we might need to create a fake kubeconfig just to make them happy
Just creating a empty file might do the trick for some applications that just check the presence of the file, but if they check it's contents we can use kubectl config view on the container so we can get an empty kubeconfig:
$ kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []
So we can just redirect it to ~/.kube/config to make them happy:
kubectl config view > ~/.kube/config
Posted on 20/10/2021