mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
util: added RunsOnKubernetes() function
Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
parent
9cec05f484
commit
93f2ed681f
@ -56,3 +56,11 @@ func NewK8sClient() (*kubernetes.Clientset, error) {
|
|||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunsOnKubernetes checks if the application is running within a Kubernetes cluster
|
||||||
|
// by inspecting the presence of the KUBERNETES_SERVICE_HOST environment variable.
|
||||||
|
func RunsOnKubernetes() bool {
|
||||||
|
kubernetesServiceHost := os.Getenv("KUBERNETES_SERVICE_HOST")
|
||||||
|
|
||||||
|
return kubernetesServiceHost != ""
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user