csharp icon indicating copy to clipboard operation
csharp copied to clipboard

KubernetesClientConfiguration.IsInCluster() not working when automountServiceAccountToken=false

Open zhiweiv opened this issue 6 months ago • 4 comments

In KubernetesClientConfiguration.IsInCluster, it uses service account token file as one check condition.

 var tokenPath = Path.Combine(ServiceAccountPath, ServiceAccountTokenKeyFileName);
 if (!FileSystem.Current.Exists(tokenPath))
 {
     return false;
 }

When set automountServiceAccountToken false(https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#opt-out-of-api-credential-automounting), there is no token file injected to container, KubernetesClientConfiguration.IsInCluster doesn't work correctly.

zhiweiv avatar Aug 19 '24 06:08 zhiweiv