CloudNativePG provides a plugin for kubectl to manage a cluster in Kubernetes.
Install
curl -sSfL \
https://github.com/cloudnative-pg/cloudnative-pg/raw/main/hack/install-cnpg-plugin.sh | \
sudo sh -s -- -b /usr/local/bin
Auto-completion
cat > kubectl_complete-cnpg <<EOF
#!/usr/bin/env sh
# Call the __complete command passing it all arguments
kubectl cnpg __complete "\$@"
EOF
chmod +x kubectl_complete-cnpg
# Important: the following command may require superuser permission
sudo mv kubectl_complete-cnpg /usr/local/bin
Use
kubectl cnpg COMMAND [ARGS...]