<p>Is there a way to detect infrastructure provider (e.g., GKE, AKS, On-Prem) in a Kubernetes custom controller? I need to check and configure things differently as different environments have different constraints.</p>

Dagang
<p>Recently I have been also interested in the same task. So far, I've deserved K8s provider detection through catching particular <code>ProviderID</code> field, promoted by a specific cloud provider's <a href="https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/" rel="nofollow noreferrer"><em>Controller Manager</em></a>, on each k8s target node.</p>

<pre><code>kubectl get no | awk '{print $1}'| sed '1d'| while read -r node; do echo "$node=$(kubectl get no $node -o jsonpath='{.spec.providerID}')"; done
</code></pre>

<p>Sharing your experience and further progress with more efficient solution will be highly appreciated.</p>

<p>Hope that this can be useful also for any other community contributors research.</p>
