<p>An operator I'm building needs to talk to other Kubernetes clusters, are there any best practices on how to do that from within the operator that runs on Kubernetes?</p>

<p>Using <code>k8s.io/client-go/tools/clientcmd</code> package I can call <code>BuildConfigFromFlags</code> method passing <code>masterURL</code> and kubeconfig location. This works fine from outside Kubernetes, but within Kubernetes, can any assumptions be made about kubeconfig location? Or should some other API be used?</p>

<p>As a side note: I'm using <code>controller-runtime</code>'s <code>Client</code> API for talking to Kubernetes.</p>

<p>A kubernetes operator is, in the end, a pod running inside of Kubernetes. Nicola Ben`s answer is the way to go if you want to access the current K8S cluster's API.</p>

<p>However, you're saying your operator "needs to talk to <strong>other</strong> Kubernetes clusters" (my emphasis), and that it works locally.</p>

<p>Then, one simple approach is to create a <code>ConfigMap</code> containing the <code>kubeconfig</code> file, and mount that to a known location in the operator pod. Then you can simply use that the same way you do it locally.</p>
