cnpg
completion is designed to work when running like this:
. <( kubectl cnpg completion bash )
however, when running on a k3s node, the proper way to run kubectl is either:
k3s kubectl ...
or, make the /etc/rancher/k3s/k3s.yaml
readable (or copy to the user ~/.kube/config
), and export KUBECONFIG with the path.
When I try either, followed by one of the following options, it runs, but doesn't do anything when hitting tabtab.
Following coment from Grisha Levit (thanks!)
I noticed there is a kubectl-cnpg
command on the path, but running the following end up with an error:
$ . <( kubectl-cnpg completion bash ) Error: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
After loading cnpg-completion with:
. <( kubectl cnpg completion bash )
# or
. <( kubectl-cnpg completoin bash )
Only kubectl-cnpg
tabtab works, (only with commands and params, not with cluster names - although I don't know if it ever worked that way).
It does not work with kubectl cnpg
tabtab
Any idea if this the extent of the completion?
The auto-completion of clusters name it's not something implemented on the plugin yet, if you like to have that feature please open a feature request on the GitHub Issue here https://github.com/cloudnative-pg/cloudnative-pg/issues
Ok the autocomplete is there and has always been there, the only thing that you need is to add the following script named kubectl_complete-cnpg
:
#!/usr/bin/env sh
# Call the __complete command passing it all arguments
kubectl cnpg __complete "$@"
In your PATH and make it executable, that was added here https://github.com/kubernetes/kubernetes/pull/105867
So that's the first part of the right answer, the second part will be answered by this PR https://github.com/cloudnative-pg/cloudnative-pg/pull/3875
Hopefully that will help you