geodesic icon indicating copy to clipboard operation
geodesic copied to clipboard

Geodesic shell wrongly treats $KUBECONFIG as a file

Open raehik opened this issue 5 years ago • 4 comments

what

  • geodesic.kube-ps1.sh turns kube-ps1 on and off automatically depending on kubecfg existence
  • but $KUBECONFIG isn't a file, it's a $PATH-like envvar (see K8s docs)

why

  • Geodesic shouldn't turn kube-ps1 off if $KUBECONFIG or the cached envvar isn't an existing file

Not sure exactly how to fix this - should probably use kubectl config instead though, that parses $KUBECONFIG and merges configs and such.

This came up because I was extending the $KUBECONFIG var to enable aws-iam-authenticator integration - writing to a file in /dev while building the container doesn't work because it's temporary.

raehik avatar Apr 26 '19 10:04 raehik

@raehik looks like you're correct about KUBECONFIG being a path-like env var, which should get fixed. However, we do already support aws-iam-authenticator and do not have this problem, so I think you're taking an alternative approach.

osterman avatar Apr 26 '19 16:04 osterman

@Nuru any insights?

osterman avatar Apr 26 '19 16:04 osterman

The only robust way I see of handling this is, as @raehik suggests, calling kubectl config current-context and seeing if it returns an error, but that can take as much as half a second which is too long for a command that runs as a prompt hook.

Currently Geodesic simply checks [ -f "${KUBECONFIG}" ], which is a reasonable shorthand, as demonstrated by how long this was operative before a conflicting use case surfaced. The easiest improvement would be to test [ -f "${KUBECONFIG##*[:;]}" ] which sees if the last file in the list exists.

I'm not sure how much that will help @raehik

Nuru avatar May 09 '19 00:05 Nuru

@raehik I would like to close this issue, but want to make sure you are supported. Please let us know:

  • Have you made peace with the existing behavior?
  • Would changing the kube-ps1 test to check if the last file in the KUBECONFIG list exists, as explained above, solve your issue?
  • Have you got a better solution?

Nuru avatar Aug 29 '19 17:08 Nuru