BuildKit can be used as a build service in Kubernetes
BuildKit understands the schema kube-pod://
Load balancing works
buildx
comes with options to deploy BuildKit based pods
Create cluster:
kind create cluster
Run BuildKit daemon:
kubectl apply -f pod.rootless.yaml
Wait for pod to deploy:
watch kubectl get pods
Run build:
export BUILDKIT_HOST=kube-pod://buildkitd
buildctl build \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=.
buildx
110_ecosystem/buildkit/k8s
Configure buildx to use Kubernetes:
docker buildx create \
--name k8s \
--driver kubernetes \
--driver-opt replicas=2 \
--driver-opt rootless=true \
--driver-opt loadbalance=random \
--use
Deploy builder instances in Kubernetes:
docker buildx inspect k8s --bootstrap
Build using Kubernetes:
docker buildx build .
buildx
the default builderdocker buildx install
uninstall
to revert
Must push during build:
docker build --tag X --push .
docker push
and docker tag
do not work
Similar but not identical DX