docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.5k stars 471 forks source link

Support for in cluster kubernetes client #256

Open andrewrynhard opened 4 years ago

andrewrynhard commented 4 years ago

It seems like buildx explicitly uses the ~/.kube/config. I'd like to run buildx in a CI pipeline that runs in kubernetes. Until #216 is implemented, users are forced to run docker buildx create and need the proper permissions to create deployments. To make doing this easier in a pipeline I'd like to be able to use the permissions of the service account attached to the pod I am running the above command from.

jbarrick-mesosphere commented 4 years ago

https://github.com/docker/cli/pull/2540 should resolve this once we update the dependencies here.

roy-ht commented 4 years ago

Same issue and waiting for above PR will be merged, thx!

FYI, I patched like below as a dirty fix (i know it's a vendored code) and worked for me, but i don't understand well why it works.

diff --git a/vendor/github.com/docker/compose-on-kubernetes/api/config.go b/vendor/github.com/docker/compose-on-kubernetes/api/config.go
index 8e091bd..700169a 100644
--- a/vendor/github.com/docker/compose-on-kubernetes/api/config.go
+++ b/vendor/github.com/docker/compose-on-kubernetes/api/config.go
@@ -20,7 +20,8 @@ func NewKubernetesConfig(configPath string) clientcmd.ClientConfig {
                }
        }

+       precedence := []string{kubeConfig}
        return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
-               &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeConfig},
+               &clientcmd.ClientConfigLoadingRules{Precedence: precedence},
                &clientcmd.ConfigOverrides{})
 }
Raboo commented 3 years ago

A tiny bit of topic here @andrewrynhard I'm looking at achieving same thing but with GitHub actions. So I guess first step would be to have a container with kubectl, helm, tilt and docker+buildx. So instead of reinventing the wheel I ask if you don't happen to have such an image maintained and publicly available?

andrewrynhard commented 3 years ago

A tiny bit of topic here

@andrewrynhard I'm looking at achieving same thing but with GitHub actions. So I guess first step would be to have a container with kubectl, helm, tilt and docker+buildx. So instead of reinventing the wheel I ask if you don't happen to have such an image maintained and publicly available?

We do not. Sorry.