csharp icon indicating copy to clipboard operation
csharp copied to clipboard

InClusterConfig no more working on non-root workdir

Open svenso opened this issue 6 years ago • 7 comments

This change (06380095b46bc20463cf39d59e15fd5f69850a51) changes the path.

In Linux it looks now like: "var/run/secrets/kubernetes.io/serviceaccount/" before it was: "/var/run/secrets/kubernetes.io/serviceaccount/" --> Notice the missing forwarding slash at begin.

If an application is not running in the root directory, IsInCluser and InClusterConfig won't work anymore.

In addition, the path on windows is converted to: "var\run\secrets\kubernetes.io\serviceaccount/" which also doesn't look very pretty (and has the same issue)...

svenso avatar Dec 27 '19 08:12 svenso

Just tried to update my project to 1.6.8 and ran into this problem as well.

darobs avatar Dec 31 '19 16:12 darobs

Made a PR: #342

darobs avatar Dec 31 '19 18:12 darobs

+1 for this as an issue. I've reproduced this as well.

My app is running from /app and IsInCluster isn't behaving correctly.

I got the unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined error and investigated what IsInCluster does. My app is able to print the environment variables of interest and can read the token/ca.crt given hardcoded paths.

I confirmed that this is generating a non-rooted path:

var path = Path.Combine(new string[] {
                "var", "run", "secrets", "kubernetes.io", "serviceaccount/"
            });
            logger.LogInformation("Path: {PATH}", path); // logs Path: var/run/secrets/kubernetes.io/serviceaccount/

Downgrading to 1.6.6 resolves the issue.

rynowak avatar Jan 06 '20 01:01 rynowak

Ran into problem as well. Seems like issue with InClusterConfig. Downgrading to 1.6.6 resolves the issue.

NitinM3 avatar Jan 06 '20 06:01 NitinM3

This fix was merged into release 1.6.9 can someone validate if that indeed fixes what they were seeing?

Thanks!

brendandburns avatar Jan 07 '20 05:01 brendandburns

I updated to 1.6.10 and I am no longer seeing the error.

darobs avatar Jan 08 '20 00:01 darobs

Great to hear, closing this issue.

brendandburns avatar Jan 08 '20 17:01 brendandburns