buildkit

by hoobiboobi

Helm chartv1.0.0-alpha.1App v0.34.2Apache-2.0Verified publisher

Persistent BuildKit daemons as a shared build service for CI, with probe and garbage-collection defaults derived from a production setup.

About this chart

buildkit

Persistent BuildKit daemons as a shared build service for CI, with probe and garbage-collection defaults derived from a production setup.

Part of ci-accelerator; this chart is the daemons alone, for a cluster that already has a runner. It runs BuildKit v0.34.2 (the official moby/buildkit image, pinned by digest) as a privileged DaemonSet on the build nodes, with the probe, termination and garbage-collection defaults of a production setup: the garbage-collection policies are rendered in full by the chart (see config.gc). mTLS between jobs and daemons is mandatory: cert-manager issues the daemons' certificate and a client certificate (Secret <fullname>-client) into each of tls.client.namespaces, or you provide them (tls.source=existingSecret, made by scripts/buildkit-certs.sh).

helm install buildkit oci://ghcr.io/hoobiboobi/charts/buildkit --version 1.0.0-alpha.1 \
  -n ci-accelerator --set 'tls.client.namespaces={ci-jobs}'

CI jobs reach the daemons through the Service <fullname> on port 1234. By default each job talks to the daemon on its own node (service.routing: PreferSameNode), so a project's cache stays warm on the nodes its jobs run on; the headless Service <fullname>-headless lists every daemon for other components.

The box (charts/ci-accelerator) installs this chart with a gitlab-runner and the control plane (charts/control-plane), whose build router sends each job to the node where its project built before. With global.router.enabled and global.router.service (the box sets both), the daemons' certificate names the router's Service and their NetworkPolicy admits the router's pods instead of the clients' namespaces; the jobs keep their client certificates, which the daemons check through the router. The box also turns on diskProbe (a sidecar reporting the cache disk's size and free space and the node's and the daemon's CPU and memory to the console; it mounts the host's /sys/fs/cgroup read-only) and networkPolicy.

How to use the daemons from a job, where the cache should live and what to watch: the documentation, architecture and troubleshooting. This chart upgrades in place from the previous release (upgrading); the upgrade notes in the changelog say when an upgrade restarts the daemons (an emptyDir cache then starts empty).

Requirements

Kubernetes: >=1.34.0-0

Values

KeyTypeDefaultDescription
affinityobject{}
commonLabelsobject{}Labels added to every resource the chart creates (including the pods: changing them restarts the daemons). They cannot override the chart's own labels.
config.cdiobject{"enabled":false}Container Device Interface (GPUs and other devices for RUN steps). Off by default: CI builds need no devices. Requires buildkit >= v0.33.1: older versions panic when a build requests a device while CDI is disabled (GHSA-r456-g3gm-cvxf).
config.extraConfigstring""Raw TOML inserted after the top-level keys and before the chart's tables: use it for top-level keys (e.g. insecure-entitlements) and new tables (e.g. [registry."docker.io"]). Never repeat [grpc], [worker.oci], [worker.containerd], [history], [system] or [cdi]; the chart validates the result and fails the render otherwise. Do not reach into those tables with dotted keys either (worker.oci.max-parallelism = 5): the chart's check accepts them, buildkitd's parser does not, and the daemon fails to start. Use the typed values or config.workerOCI.
config.gc.cacheMounts.keepDurationstring"336h"
config.gc.cacheMounts.maxUsedSpacestring""With a size here, cache mounts unused for keepDuration expire only while the WHOLE cache is above it (buildkit compares policy caps with the total usage, not with the filtered records), so it keeps them longer, not shorter. To expire them by size alone, least recently used first, set keepDuration "0" with it. Empty: every mount unused for keepDuration expires.
config.gc.maxUsedSpacestring"75%"Reclaim when the cache grows above this.
config.gc.minFreeSpacestring"30%"Reclaim when free space on the state-dir filesystem drops below this. It is compared with free blocks including the filesystem's root reserve (ext4: 5%), while kubelet evicts on available blocks at 10-15%. With the cache on the node's root disk (emptyDir, or hostPath not on its own disk) keep it at 30% or more; on a dedicated disk use an absolute size (production: 400GB on a 3 TB NVMe).
config.gc.reservedSpacestring"10GB"The capped policies never reclaim below this much cache. Age-based policies (cache mounts, local context) still expire by age.
config.gcPolicylist[]Replace the chart's GC policies entirely. Each item: filters, all, keepDuration, reservedSpace, maxUsedSpace, minFreeSpace. Filters use buildkit's prune syntax, e.g. "type==exec.cachemount".
config.historyobject{"maxAge":"48h","maxEntries":1000}Build history, which the controller reads (it copies each record when it completes, and reads the history again after a restart). Keys: maxAge (duration) and maxEntries (int). Set both, or neither: a key that is not set becomes 0, not the buildkit default (48h / 50); maxEntries 0 stops recording new history, and maxAge alone drops the 50-entry floor. 1000 records cover about an hour of a busy farm; buildkit's own 50 last minutes there.
config.log.formatstring""json or text; empty: text.
config.log.levelstring""error, warn, info or debug; empty: info.
config.maxParallelismint0Max concurrently running build operations per daemon: RUN, COPY/ADD and source operations (image pulls, git, local context). 0 = unlimited, which is buildkit's default (not the CPU count). Production ran 28 on a 48-CPU daemon.
config.maxRegistryConcurrencyint0Max concurrent connections per registry; 0 keeps the buildkit default (4). Pushes that get stuck hold their slot and can hang every build on the daemon (moby/buildkit#7275); the probes do not detect that.
config.workerOCIobject{}Extra keys for the [worker.oci] table, e.g. {snapshotter: native}. Values: strings, numbers, booleans or lists. The keys the chart sets (enabled, gc, max-parallelism, gcpolicy) are rejected, and so are the worker-level GC caps (reservedSpace, maxUsedSpace, minFreeSpace, gckeepstorage), which buildkitd ignores next to the chart's policies: use config.gc.
diskProbe.enabledboolfalseRun the probe. Off here (no controller to read it); the box turns it on.
diskProbe.image.digeststring""When set, the image is pulled by digest (tag is kept for readability; the release notes list the probe's). Under the default tag, the digest of another release is refused.
diskProbe.image.pullPolicystring"IfNotPresent"
diskProbe.image.repositorystring"ghcr.io/hoobiboobi/ci-accelerator"The ci-accelerator image: mirror it together with the control plane's.
diskProbe.image.tagstring""Default: v0.3.3, the release that last changed the probe program or its image; pinned, so a chart release alone does not restart every daemon.
diskProbe.logLevelstring""Its log level (debug adds a line per reading); empty: info. Set, it restarts every daemon once.
diskProbe.portint9180Its port (GET /disk, /load, /healthz); the daemons tell it to the control plane as a worker label.
diskProbe.resourcesobject{"limits":{"memory":"32Mi"},"requests":{"cpu":"5m","memory":"16Mi"}}The probe's resources (it reads a few kernel files every 10 s and keeps an hour of readings in memory).
extraEnvlist[]Extra environment variables for the daemon container. An entry named like one the chart sets (CI_ACCELERATOR_POD_NAME, CI_ACCELERATOR_NODE_NAME, OTEL_RESOURCE_ATTRIBUTES and the otel.* endpoint variables) replaces it.
fullnameOverridestring""Override the full resource name (- by default). Install-time only, like nameOverride.
global.buildNodes.enabledbooltruefalse: ignore selector/tolerations below and run on any Linux node. (A switch, because Helm merges selector: {} with the default instead of clearing it.)
global.buildNodes.selector."ci-accelerator.io/node-role"string"build"
global.buildNodes.tolerations[0].effectstring"NoSchedule"
global.buildNodes.tolerations[0].keystring"ci-accelerator.io/node-role"
global.buildNodes.tolerations[0].operatorstring"Equal"
global.buildNodes.tolerations[0].valuestring"build"
global.router.enabledboolfalse
global.router.servicestring""The router's Service in this namespace. Rendered with tpl.
global.tls.issuerRefobject{"group":"cert-manager.io","kind":"ClusterIssuer","name":""}cert-manager issuer for the daemons' and the clients' certificates (tls.source=certManager). Empty name: the chart creates a CA dedicated to this release (see tls.certManager). Your own issuer must be dedicated to these daemons too (any certificate it signs gets in) and must put ca.crt into the Secrets it fills (CA or Vault issuers do, ACME does not). Client certificates in other namespaces need a ClusterIssuer.
image.digeststring"sha256:c5f8862f52499773af85bc07695b2379ef08e8002352b0df2c4864c91d78dabe"Image index digest. The runtime pulls by digest when it is set, so change or clear it together with tag (another tag with this default digest is refused). Default: the digest of the appVersion tag (multi-arch index).
image.pullPolicystring"IfNotPresent"
image.repositorystring"moby/buildkit"
image.tagstring""Defaults to the chart appVersion.
imagePullSecretslist[]Image pull secrets for private mirrors of the buildkit image.
minReadySecondsint10A new daemon must stay ready this long before the rollout moves on to the next node.
nameOverridestring""Override the chart name used in resource names. Install-time only: changing it later renames every object and conflicts with the immutable DaemonSet selector.
networkPolicy.egress.blockedCIDRslist["169.254.169.254/32","168.63.129.16/32","100.100.100.200/32","fd00:ec2::254/128","fd20:ce::254/128"]Never reachable: cloud instance metadata (node credentials). The defaults cover the metadata address of AWS, GCP, Azure, Oracle and most others (169.254.169.254), Azure's WireServer (168.63.129.16), Alibaba Cloud (100.100.100.200), and over IPv6 AWS (fd00:ec2::254) and GCP (fd20:ce::254). Add your provider's if it uses another address; a list set here replaces the defaults.
networkPolicy.egress.clusterCIDRslist[]The cluster's pod and Service CIDRs. Listed here, the daemons and every build lose access to in-cluster services (allow what they need in extraRules, e.g. an in-cluster registry or the OTLP backends). The API offers no way to discover them. Traffic to the node itself is always allowed by Kubernetes, and whether the API server can be blocked depends on the CNI. Empty, the policy also admits every pod of the cluster by a namespace selector, because some CNIs (Cilium by default) do not apply ipBlock rules to pod addresses. This limits RUN steps only: CI job scripts follow jobsNamespace.networkPolicy of the ci-accelerator chart, which keeps in-cluster services open.
networkPolicy.egress.dnslist[{"namespaceSelector":{"matchLabels":{"kubernetes.io/metadata.name":"kube-system"}},"podSelector":{"matchLabels":{"k8s-app":"kube-dns"}}}]Peers that serve DNS on port 53.
networkPolicy.egress.extraRuleslist[]More NetworkPolicyEgressRule entries (rendered with tpl).
networkPolicy.enabledboolfalseRender a NetworkPolicy for the daemon pods.
networkPolicy.ingress.controllerboolfalseAdmit the ci-accelerator controller (pods labelled ci-accelerator.io/component: controller in this namespace), which reads the daemons' build history. The ci-accelerator chart sets it.
networkPolicy.ingress.extraFromlist[]More NetworkPolicyPeer entries for port 1234 (e.g. an ipBlock for NodePort clients outside the cluster).
networkPolicy.ingress.namespaceslist[]Namespaces whose pods may connect to port 1234, in addition to tls.client.namespaces.
nodeSelectorobject{}Merged over global.buildNodes.selector (and kubernetes.io/os: linux).
openFilesLimitint1048576The open-files limit (soft and hard) of buildkitd and so of every RUN step. A node whose containerd runs with LimitNOFILE=infinity hands pods 2^30 or more, and old tools loop over every possible descriptor: yum on CentOS 7 ran for an hour instead of three minutes (a lab run, 2026-11-11). Docker gives containers 1024 by default. 0 keeps what the node gives. It must not exceed the node's fs.nr_open (1048576 on a stock kernel): buildkitd does not start otherwise ("ulimit: error setting limit").
otel.metricsEndpointstring""Full OTLP URL for metrics (with the path, e.g. `http://otel-collector:4

Deploy buildkit with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has buildkit on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartbuildkit is pinned at v1.0.0-alpha.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply