Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] kubectl-fzf-server --watch-namespaces does not exclude all other namespaces. #42

Open
bmbeverst opened this issue Oct 20, 2023 · 0 comments

Comments

@bmbeverst
Copy link

#TLDR:
--watch-namespaces does not exclude all other namespaces. It still watches all namespaces.

Details

Good day,

Thanks for such a useful tool for making Kubernetes administration faster!

Got tired of the slow auto complete in kubectl. Installed kubectl-fzfbut I use a private cluster that requires a VPN. The VPN is billed per data transferred so I did not want to monitor all namespaces and resources. I didn't deploy the kubectl-fzf-server server to the cluster, this is probably the best solution for my billing issues.

Issue

I started with: kubectl-fzf-server --watch-namespaces e2e-testing
But the output was unexpected, it was still watching all namespaces!

INFO[2023-10-20T12:06:04-04:00]resource_watcher.go:295 github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/resourcewatcher.(*ResourceWatcher).watchResource() Start watch for pods on all namespaces
INFO[2023-10-20T12:09:59-04:00]resource_watcher.go:295 github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/resourcewatcher.(*ResourceWatcher).watchResource() Start watch for configmaps on all namespaces
<etc.>

Workaround

I was able to work around this issue by using the --exclude-namespaces and a negative Perl regex, '/^(e2e-testing)/'

For example: kubectl-fzf-server --watch-namespaces 'e2e-testing' --exclude-namespaces '/^(e2e-testing)/'

Which results in the following output and works well:

INFO[2023-10-20T12:10:53-04:00]resource_watcher.go:195 github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/resourcewatcher.(*ResourceWatcher).FetchNamespaces() namespace ack-lambda-controller not in watched namespace, excluding
<SNIP>
INFO[2023-10-20T12:10:53-04:00]resource_watcher.go:290 github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/resourcewatcher.(*ResourceWatcher).watchResource() Start watch for pods on namespace [e2e-testing]
INFO[2023-10-20T12:10:53-04:00]resource_watcher.go:290 github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/resourcewatcher.(*ResourceWatcher).watchResource() Start watch for configmaps on namespace [e2e-testing]
<SNIP>

Documentation

At first, I thought I would have to recompile kubectl-fzf-server since there was no documentation of CLI arguments. But I did find them tracing though the code and was able to get more details with kubectl-fzf-server --help The --help documentation says that the CLI arguments are parsed with regex. The regex is Perl, so I had to swap my standard Linux regex for Perl.

Requests

These are just what I saw and don't need to be implemented since there is a workaround. Documenting them for completeness.

  • Update the --help documentation to call out it is Perl regex.
  • Please add the kubectl-fzf-server arguments to the documentation.
  • Change how --watch-namespaces works to exclude all other namespaces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant