-
Notifications
You must be signed in to change notification settings - Fork 245
Keptn CLI multiple contexts like KUBECONFIG #2300
Comments
|
Related to #1863 |
|
I had a couple of ideas too. Would be glad to discuss them and work towards this feature. |
|
Hi!
This, as mentioned in the issue itself, we can store the hash of the current kubecontext in a file in
|
…ce as … (#2559) * Resolving merge conflicts * Added multi-context support for linux * Mocking kubeconfig checks for current context * Moved kube context checks out of init function with additional mock flag for kubeconfig file * Addressed the comments
|
@bacherfl Please reopen the issue |
Often users need to switch their kube context (e.g.,
kubectl config use-context my-cluster-name, orgcloud container clusters get-credentials ...orexport KUBECONFIG=/etc/rancher/k3s/k3s.yaml), but they end up still being connected to previous Keptn installation.To overcome this, users need to manually authenticate the Keptn CLI with the correct Kubernetes cluster, as detailed here: https://keptn.sh/docs/0.7.x/reference/cli/#authenticate-keptn-cli
This could be as easy as
keptn auth --endpoint=$KEPTN_ENDPOINT --api-token=$KEPTN_API_TOKENon Linux (where asKEPTN_ENDPOINTandKEPTN_API_TOKENcan be retrieved viakubectlcommands), but requires some manual work.Another use-case that appears is that users wants to share their Keptn credentials (endpoint and api-token) with another user, without having to share access to the Kubernetes cluster. Therefore the user might want to be able to export the credentials, as well as re-use the credentials via an environment variable, e.g.,
Goal
Implementation of this issue should accomplish the following:
Definition of Done
~/.keptn/.keptncontains on Linux, but I'd prefer a format in JSON or YAMLkeptn auth --export)KEPTNCONFIGis set, and uses the config file provided in this environment variableKEPTNCONFIGis not set, the CLI should fall back to the existing mechanism (using credentialmanager for linux/darwin/windows)keptn authwithout any parameters and withoutKEPTNCONFIG, the CLI should try to do its best to try to authenticate with the Kubernetes cluster thatkubectlis currently using.keptn authcommand to select one (e.g.,keptn auth --namespace=keptn-demo)Discussion
One missing link right now is that
keptnCLI is not automatically connected to the currenct kube-context. This would requirekeptn authto be executed for every time akeptnCLI command is executed. We could do that, but this sounds like it is calling for trouble: just imagine we try to fetch the keptn secret etc... every time we send an event to the Keptn API.To prevent this, we could store a hash or an ID of the current kubecontext, and warn the user if we have detected a change.
The text was updated successfully, but these errors were encountered: