csharp
csharp copied to clipboard
KubernetesClientConfiguration.IsInCluster() not working when automountServiceAccountToken=false
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.