kubetail
kubetail copied to clipboard
Now you need to explicitly pass --namespace with --context if namespace is different from the current-context one
Hi there,
Not sure, if that's the intended behaviour but presently if I pass --context
and that context has a namespace attached to it in my kube config file, I won't be able to tail anything as it won't get the specific namespace of that context, it will set the namespace of the current-context
no matter what.
My configuration is something like that:
- context:
cluster: cluster-1.com
namespace: dev
user: user-cluster-1.com
name: dev
- context:
cluster: cluster-2.com
namespace: prod
user: user-cluster-2.com
name: prod
current-context: dev
When running the following with kubetail version 1.6.10
$ kubetail oauth --context prod
returns
No pod exists that matches oauth
However, running
kubetail oauth --context prod -n prod
returns all the logs expected.
I've looked into the script and while I'm not an expert in bash I think it's due to the method calculate_default_namespace()
which doesn't get passed the --context
option if one is given to the kubetail
command, thus, grabbing the namespace of the current-context
every time that function is ran.
Happy to help if needed.
made an attempt at it here https://github.com/johanhaleby/kubetail/pull/110
This bothers me too. I simply cleard out namespace_arg on line 55
namespace_arg=""
That way the namespace from the context is used.
The default namespace that is being calculated is also dependent on the namespace for the current context from the config, and there is no guarantee that it will have a namespace attached to it.