projectcalico / calico

Cloud native networking and network security
https://docs.tigera.io/calico/latest/about/
Apache License 2.0
6.01k stars 1.34k forks source link

please implement calicoctl version --client #9244

Closed den-is closed 1 month ago

den-is commented 1 month ago

Expected Behavior

calicoctl version --client should not query Cluster API and return calicoctl version only.

I have ansible roles that install tools and check their versions to determine on action (install/update or skip). Helm, kubectl, cilium - allows to query cli binary version only (offline) without communicating to the cluster.

Current Behavior

calicoctl version | head -1 | grep -E -o "v[0-9]+\.[0-9]+\.[0-9]+" This command always tries to communicate to the server and returns exit code 1 when server is not available.
And cluster is not available in many cases, either I try to install calicoctl before cluster setup, or installing calicoctl on some remote workstation without immediate access to the cluster.

Possible Solution

helm version --template='{{ '{{' }}.Version{{ '}}' }}' kubectl version --client -o json | grep -i gitversion | grep -E -o "v[0-9]+\.[0-9]+\.[0-9]+" (no jq) cilium version --client | head -1 | grep -E -o "v[0-9]+\.[0-9]+\.[0-9]+"

caseydavenport commented 1 month ago

Looks like it will return exit code 0 if not configured to talk to a server, but if configured (e.g., with a kubeconfig) it will return an error.

Seems like a reasonable enhancement request to make that configurable though.

cyclinder commented 1 month ago

I want to work on this, please assign it to me. thanks.