As we know, fabric can connect Kubernetes via ~/.kube/config file. I am wondering how to use farbric8 connects to connect to the Kubernetes API within a Pod? Is there any fabric8 API/library support it?
I'm from Fabric8 team. Fabric8 Kubernetes Client automatically detects whether it's inside a Pod or outside.
When inside the cluster, Fabric8 Kubernetes Client reads Kubernetes API token and ceritificates from ServiceAccount mounted inside the Pod(/var/run/secrets/kubernetes.io/serviceaccount/
). Api server URL is determined by reading KUBERNETES_SERVICE_HOST
environment variable.
When outside the cluster, it just reads .kube/config
as usual.
To end user, the process should be transparent. Just make sure your Pod's ServiceAccount has correct roles assigned to access some api group.
I had tested this some time ago on a demo project with minikube and it was working okay for me. You can try it out and see if it helps your use case: https://github.com/rohanKanojia/kubernetes-client-inside-pod