loft-sh / vcluster-dd-extension

This provides an extension integration with Docker Desktop to allow managing vclusters quickly and easily through the Docker Desktop interface.
5 stars 0 forks source link

Support working with any kubernetes cluster from Docker #22

Open jorgemoralespou opened 1 year ago

jorgemoralespou commented 1 year ago

Is your feature request related to a problem? I have a cluster running in Docker Desktop through the Tanzu Community Edition extension, and I can't use the vcluster extension as the cluster won't be detected. It seems only built in Kubernetes cluster by Docker Desktop are supported (https://github.com/loft-sh/vcluster-dd-extension#enable-kubernetes-and-docker-extensions), which limits a lot the ability to use the extension.

Which solution do you suggest? Support detection of your kube context and if there's a cluster try to use it (prompt the user that it might not work if not the default/expected type of cluster)

Which alternative solutions exist? None

Additional context Vclusters are awesome but Docker Desktop users not always use Docker Desktop's provided Kubernetes cluster.

/kind feature

jorgemoralespou commented 1 year ago

Some more info:

Looking at the sources, it seems that the kubecontext name that it selects is docker-desktop so, changing my cluster's context name to that it should connect. Nevertheless, as the connection happens from within the extension's container, and my cluster's IP/port is 127.0.0.1:59783 this port doesn't not seem to be accessible from within the extension's container (it is though accessible from within the tanzu-community-edition extension's container). My guess is that the extension might require a compose file to define that it can run on host networking (e.g. https://github.com/vmware-tanzu/community-edition/blob/main/extensions/docker-desktop/docker-compose.yaml#L5). With this change it should work.

Will try to build the extension myself with this change to see if the assumption is correct.

jorgemoralespou commented 1 year ago

Can't make it work, so probably you will need to get some more info from Docker team.

jorgemoralespou commented 1 year ago

Inspecting both extension containers, vcluster and tce, vcluster has a dedicated network and tce uses host, hence it can access any cluster.

vcluster extension container

           ...
            "Networks": {
                "loftsh_vcluster-dd-extension-desktop-extension_default": {
            ...

tce extension container

        ...
        "Networks": {
                "host": {
        ...
FabianKramm commented 1 year ago

@jorgemoralespou thanks for creating this issue! Yes we could add a selector to select the kube context to manage your vclusters.

FabianKramm commented 1 year ago

Right now the problem is that we cannot automatically identify the tanzu cluster to be running on docker-desktop and on which port we can access it. For docker-desktop this only works because we know that a node-port service is automatically also exposed on the host and we don't require any separate port-forwarding for it. For other clusters this assumption is usually not true. We have a hardcoded list of clusters currently supported (kind, k3d, minikube) and those clusters require a separate docker container that acts as a proxy between the host and the vcluster. We can work on a more generic way to do this within vcluster, but until then the connect button in the docker extension would be very limited.

mahendrabagul commented 1 year ago

This issue has been fixed in https://github.com/loft-sh/vcluster-dd-extension/pull/25 The requested functionality will be available in v0.0.8