-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PersistentPreRun to the root CLI cmd to set the kube client and c…
…luster details once for all commands (#1759) Add `PersistentPreRun` which will be inherited by all sub-commands of the root command. Perform a client initialzation in that function and set the cluster kind and k8s version as well - so they can be used by all commands. Both the kube client and the cluster details are set on the command context and can be used by all the commands. The helper function from k8sutils `GetKubernetesVersion` can't be used outside of the cluster by the CLI since it as using a rest client which states: > // InClusterConfig returns a config object which uses the service account // kubernetes gives to pods. It's intended for clients that expect to be // running inside a pod running on kubernetes. It will return ErrNotInCluster // if called from a process not running in a kubernetes environment. func InClusterConfig() (*Config, error) { Hence, removing the use of this function from the CLI, and using the k8s version which was calculated in the `PersistentPreRun` function. Before this change `odigos upgrade` resulted in errors such as: > Syncing customresourcedefinitionsDeleteOldOdigosSystemObjects failed to get k8s version, proceeding.. :unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined ✔ Syncing deploymentsDeleteOldOdigosSystemObjects failed to get k8s version, proceeding.. :unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined ✔ Syncing daemonsetsDeleteOldOdigosSystemObjects failed to get k8s version, proceeding.. :unable to load in-cluster
- Loading branch information
Showing
19 changed files
with
217 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.