busy-ram-14533
07/07/2025, 10:06 PMdocker_image
target, I'm having trouble getting the pants package
step to work with buildx when trying to use a (native) *kubernetes *build driver (instead of a local docker daemon/driver).
This seems related to #15199 Support for use `docker buildx` / BuildKit features. For the feature requests in that issue
> 1. --cache-from
and --cache-to
support
> 2. Custom builder
instances using the kubernetes
driver
I can tell #1 was addressed and is a feature, but I don't see anything in the issue or pantsbuild docs about request #2.
On buildx version v0.19.2 I get
> ERROR: no valid drivers found: cannot determine Kubernetes namespace, specify manually: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
And on the older buildx v0.11.1 I get
> ERROR: no valid drivers found: cannot determine Kubernetes namespace, specify manually: stat /root/.kube/config: no such file or directory
As best I can tell – and I don't really know about this topic – the issue is that some key buildx kubernetes driver config files are not accessible from the pants environment.
More info about my environment in 🧵busy-ram-14533
07/07/2025, 10:08 PM[docker]
use_buildx = true
build_verbose = true
env_vars = [
"DOCKER_CONFIG=%(homedir)s/.docker",
"DOCKER_HOST",
"BUILDX_BUILDER=ci",
"BUILDKIT_NAMESPACE=buildkit-platform",
"PATH",
]
...
When I run docker buildx ls
, I get an output very similar to this:
docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
ci* kubernetes
\_ buildkit-platform-amd64 \_ kubernetes:///ci?deployment=buildkit-platform-amd64&kubeconfig= running v0.21.1 linux/amd64 (+4), linux/386
\_ buildkit-platform-arm64 \_ kubernetes:///ci?deployment=buildkit-platform-arm64&kubeconfig= running v0.21.1 linux/arm64, linux/arm (+2)
default error
I'm trying to use that "ci" buildx driver, hence the BUILDX_BUILDER=ci
busy-ram-14533
07/07/2025, 10:19 PM-ldebug
output, pants is running
/usr/bin/docker buildx build \
--platform=linux/amd64 \
--label target=prod \
--output=type=docker \
--pull=False \
--tag <http://registry.ddbuild.io/ci/dd-analytics/run_squares:v1016161113-848c0969|registry.ddbuild.io/ci/dd-analytics/run_squares:v1016161113-848c0969> \
--build-arg CI_COMMIT_REF_SLUG \
--build-arg CI_COMMIT_SHORT_SHA \
--build-arg CI_JOB_ID \
--file subprojects/example/src/python/example/app/ray_job/Dockerfile.run_squares \
.
busy-ram-14533
07/08/2025, 1:07 PM~/.docker/buildx/instances/ci
file is present and has this content
{
"Name": "ci",
"Driver": "kubernetes",
"Nodes": [
{
"Name": "buildkit-platform-amd64",
"Endpoint": "kubernetes:///ci?deployment=buildkit-platform-amd64&kubeconfig=",
"Platforms": [],
"DriverOpts": {
"namespace": "buildkit-platform"
},
"Flags": [
"--allow-insecure-entitlement=network.host"
],
"Files": null
},
{
"Name": "buildkit-platform-arm64",
"Endpoint": "kubernetes:///ci?deployment=buildkit-platform-arm64&kubeconfig=",
"Platforms": null,
"DriverOpts": {
"namespace": "buildkit-platform"
},
"Flags": [
"--allow-insecure-entitlement=network.host"
],
"Files": null
}
],
"Dynamic": false
}
I assumed because we have "DOCKER_CONFIG=%(homedir)s/.docker"
set in pants.toml that docker/buildx would 'see' this configbusy-ram-14533
07/08/2025, 8:03 PMnutritious-hair-72580
07/09/2025, 8:50 AM--builder=kube
I think from a brief look at the docs. There is an open issue for supporting arbitrary extra build args which I think would help with this. I might have some time to look at this in the next week or so but can't promise anything at this point.busy-ram-14533
07/09/2025, 2:25 PMpants
yet), so I'm not quite sure what changes need to be made
I'll at least get some paperwork out of the way by writing up an issue in Github.busy-ram-14533
07/09/2025, 5:42 PM--builder=kube
alone will be enough to get this working. I set BUILDX_BUILDER=ci
, and BUILDX_BUILDER
is supposed to do the same thing as the --builder
argument (see https://docs.docker.com/reference/cli/docker/buildx/#builder)happy-kitchen-89482
07/09/2025, 11:24 PMBUILDX_BUILDER
isn’t plumbed through to the processhappy-kitchen-89482
07/09/2025, 11:24 PMnutritious-hair-72580
07/10/2025, 5:18 AMbusy-ram-14533
07/10/2025, 2:24 PMbusy-ram-14533
07/14/2025, 9:28 PMpants package
to build a docker_image
target with buildx using a kubernetes driver type:
• I set BUILDX_BUILDER=<my buildx driver name>
in [docker].envvars to configure the buildx driver ➡️ I wrote up a feature request to make this configuration more natural for pantsbuild https://github.com/pantsbuild/pants/issues/22487
• Also in [docker].envvars, I had to configure pants to be aware of KUBERNETES_SERVICE_[HOST|PORT|PORT_HTTPS]
environment variables. Because pants is running "in-cluster," buildx needs those env vars to correctly instantiate the config client that will pull config from the kubernetes cluster it's in
• Because I'm using a kuberenetes buildx driver and I don't have a docker daemon running, I had to set the output of my docker_image
target to type=registry
. This also means I had to stop doing pants publish
... the pants package
step does the publishing thanks to this output type.
What's awesome is that there was a way to this pants package of a docker image to work with pants as it is (I'm using pants v2.27.0). At a minimum, some documentation about this case would be helpful to add to the pants docs.happy-kitchen-89482
07/14/2025, 10:10 PMbusy-ram-14533
07/14/2025, 10:15 PMhappy-kitchen-89482
07/15/2025, 12:20 AM