Skip to content

Add support to detect Kubernetes platform in CloudPlatform #15537

Closed
@markpollack

Description

@markpollack

In Spring Cloud Data Flow we would like to detect when an application is running in Kuberenetes.

One approach maybe to check for an environment variable such as KUBERNETES_SERVICE_HOST since k8s sets a property of this form - see https://github.com/kubernetes/kubernetes/blob/v1.11.0/pkg/kubelet/envvars/envvars.go#L45 .

I haven't yet seen a (service.Name) value different than KUBERNETES but I guess it is possible.

https://github.com/spring-cloud/spring-cloud-kubernetes/blob/master/spring-cloud-kubernetes-core/src/main/java/org/springframework/cloud/kubernetes/StandardPodUtils.java

provides a isInsideKubernetes method but it requires a KubernetesClient to be created and I actually don't think it isn't answering the question if the code is running inside of a kubernetes pod.

Given that Kubernetes is quite a popular platform adding some support for detecting this would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions