Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more than one kubeconfig file, including generated from provisioners #3385

Closed
afbjorklund opened this issue Aug 1, 2023 · 6 comments
Closed

Comments

@afbjorklund
Copy link
Contributor

Is your enhancement related to a problem? Please describe

Currently the interface is hardcoded to a single KUBECONFIG, defaulting to ~/.kube/config

But it is possible to have more than one, that will be merged before presenting contexts...

Describe the solution you'd like

The "kind" and "minikube" clusters are editing the user config, while k3s and k8s do not.

So for those clusters, running in Lima, they generate a file that can be passed like a socket.

Describe alternatives you've considered

The workaround is to copy and paste the path location, which "hides" the other contexts

So while overriding the kubeconfig, it is not possible to use any other cluster in the config

Additional context

https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

@afbjorklund afbjorklund added the kind/enhancement ✨ Issue for requesting an improvement label Aug 1, 2023
@afbjorklund
Copy link
Contributor Author

afbjorklund commented Aug 1, 2023

Example of kubeConfig field, for the Lima provisioner:

commit b54bb4b

--- a/packages/extension-api/src/extension-api.d.ts
+++ b/packages/extension-api/src/extension-api.d.ts
@@ -223,6 +223,7 @@ declare module '@podman-desktop/api' {
   }
   export interface KubernetesProviderConnection {
     name: string;
+    kubeConfig?: string;
     endpoint: KubernetesProviderConnectionEndpoint;
     lifecycle?: ProviderConnectionLifecycle;
     status(): ProviderConnectionStatus;

It contains the path of the file, to be appended to KUBECONFIG.

@benoitf
Copy link
Collaborator

benoitf commented Aug 4, 2023

your suggestion in API looks like a good move.
Just wondering if we provide the string or the JSON object and how kubernetes-client handle that (as it should fit with that lib)

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Aug 5, 2023

A missing value (null), means that the context is only in the default (~/.kube/config) and that no config is needed...

A string value, means that the path of the file is merged with the existing $KUBECONFIG using the path separator.

https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#append-home-kube-config-to-your-kubeconfig-environment-variable
There were some examples in the Lima provisioner, but it does not handle JSON objects at all - only kubeconfig files:

KUBECONFIG=~/.kube/config:~/.lima/k3s/copied-from-guest/kubeconfig.yaml:~/.lima/k8s/copied-from-guest/kubeconfig.yaml

It is similar to modifying the PATH variable, instead of having to copy files to the global (or user) default paths ?

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Aug 5, 2023

It seems that the javascript library does not fully handle kubeconfig configuration files yet, unfortunately:

https://github.com/kubernetes-client/javascript#known-issues
"Multiple kubeconfigs are not completely supported. Credentials are cached based on the kubeconfig username and these can collide across configs. Here is the related kubernetes-client/javascript#592."

The current user names for the local clusters are quite random, but they don't seem to be colliding:

CURRENT   NAME                          CLUSTER             AUTHINFO            NAMESPACE
*         default                       default             default             
          kind-kind-cluster             kind-kind-cluster   kind-kind-cluster   
          kubernetes-admin@kubernetes   kubernetes          kubernetes-admin    
          minikube                      minikube            minikube            default

Copy link
Contributor

This issue has been automatically marked as stale because it has not had activity in the last 6 months. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

Copy link
Contributor

This issue has been automatically closed because it has not had any further activity in the last 30 days. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants