Environment: Add provider-neutral Kubernetes environment with pod-native Compose and BuildKit #2819
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #2819"
general
weight: 0.35
KunWuLuan
Summary
This PR adds a provider-neutral Kubernetes execution stack to Harbor:
- extracts shared Kubernetes primitives from the existing GKE environment
- adds a generic
kubernetesenvironment for any cluster reachable through kubeconfig or an in-cluster service account- supports Docker Compose through either DinD or native Kubernetes sidecars
- adds optional Docker and BuildKit image-builder backends
- supports pull-through and prepopulated OCI mirrors for prebuilt images
- preserves existing GKE behavior while sharing its hardened Kubernetes implementation
## Motivation
Harbor's existing Kubernetes implementation is coupled to GKE even though most
pod lifecycle, execution, transfer, cleanup, and Compose behavior is not
Google-specific.
The generic environment makes this functionality available to RKE2, k3s,
kubeadm, EKS, AKS, ACK, GKE, kind, minikube, and other conformant Kubernetes
clusters without requiring a cloud-specific CLI.
## Configuration
A complete configuration can look like this:
Authentication is resolved from
KUBECONFIG,~/.kube/config, or an in-clusterservice account.
## Kubernetes environment
The new environment supports:
- namespace and kubeconfig context selection
- node selectors, tolerations, labels, and service accounts
- configurable resource requests and limits
- image pull policies and pull secrets
- prebuilt images and Dockerfile-based tasks
- insecure or authenticated registries
- Kubernetes-safe pod names and labels
- command execution, file transfer, artifact collection, and cleanup
Shared Kubernetes behavior now lives in
BaseKubernetesEnvironment. GKE retains only its Google-specificauthentication, image-building, and accelerator behavior.
The shared implementation also preserves exec-stream keepalives, missing-status
detection, collision-resistant resource names, and service-account token
isolation.
## Compose strategies
The generic Kubernetes environment supports two Compose strategies.
###
dinddindis the default and runs Docker Compose inside a privilegedDocker-in-Docker pod. It provides the widest Compose compatibility and supports
network isolation.
###
podspodstranslates supported Compose services into native sidecars in a singleordinary Kubernetes pod.
It preserves:
-
service_startedandservice_healthydependency ordering- executable health checks through startup probes
- shared Compose volumes
- service-specific execution and file transfer
- prebuilt and locally built service images
- sidecar artifact collection
- deterministic startup and cleanup
Native sidecars require Kubernetes 1.29 or newer; Kubernetes 1.33 or newer is
recommended.
Because all containers share one pod network namespace, pod-native mode cannot
enforce
no-network. One-shot services and unsupported Compose features such asprivileged,ports,devices, andnetwork_modeare rejected before imagesare built. DinD remains available for those workloads.
## Image builders
Host-side image construction supports four modes:
-
auto: use explicitly configured BuildKit, otherwise a working Docker daemon-
buildkit: require BuildKit without falling back-
docker: require Docker-
none: permit prebuilt-only tasks and reject requested buildsBuildKit is operator-provided. Harbor does not install or launch it;
buildctland a reachable daemon must already be available through
buildkit_addressorBUILDKIT_HOST.Pod-native Compose rendering still requires the Docker CLI and Compose plugin
for
docker compose config, but it does not require a Docker daemon when usingBuildKit or only prebuilt services.
### Build registry requirement
image_registryis required whenever Docker or BuildKit builds an image. Itmust be an OCI-compatible registry implementing the Docker Registry HTTP API V2.
The registry must be reachable from:
- the Harbor host or BuildKit daemon, which pushes the built image
- the Kubernetes nodes, whose kubelets pull the image into the workload pod
A BuildKit daemon performs the build but cannot make its local result visible
to Kubernetes. Harbor exports the result with
type=image,...,push=trueandplaces the resulting registry reference in the pod specification.
Prebuilt-only single-container tasks and prebuilt-only pod-native Compose graphs
require neither an image builder nor
image_registry.For private registries, builder pushes use the host's
DOCKER_CONFIG, whilekubelet pulls use
image_pull_secret.registry_insecure: trueis required onlyfor plain HTTP or untrusted TLS.
## Prebuilt image mirrors
prebuilt_image_mirrorsmaps source registries to path-preserving pull-throughor prepopulated OCI registries.
For example:
Harbor probes the mirrored manifest to trigger pull-through population and uses
the mirrored reference when it becomes available. Resolution applies to both
single-container tasks and prebuilt pod-native Compose services, independently
of
image_mode.Mirror failure behavior is configurable:
-
fallback: warn and use the original source image-
error: fail before creating the workload podHarbor does not configure the mirror itself. Authenticated manifest probes use
the host's
DOCKER_CONFIG; Kubernetes runtime pulls continue to useimage_pull_secret. Mirror can be pull-through cache like Zot's sync feature,or just simple prepopulated registry.
This feature is really useful because it can be used to move images closer to the
harbor runner while also avoiding online registries rate limiting.
## Validation
### Automated checks
- 461 focused Kubernetes and environment tests passed
- Ruff linting passed
- Ruff formatting passed
- type checking passed for every modified environment module
- all 36 patches are equivalent to the reviewed fork stack
### Runtime environment validation
Runtime validation used the Oracle agent on an RKE2 Kubernetes v1.36.1 cluster.
| Dataset | Configuration | Result |
| --- | --- | --- |
| terminal-bench 2.1 | Generic Kubernetes before BuildKit | 87/89 reward-1, no environment exceptions |
| tau3-bench | DinD Compose | 375/375, zero exceptions |
| tau3-bench | Pod-native Compose | 375/375, zero exceptions |
| tau3-bench | BuildKit, pod-native Compose, and pull-through mirror | 375/375, zero exceptions |
| terminal-bench 2.1 | BuildKit and pull-through mirror | 87/89 |
Two terminal-bench zero-reward tasks are known task defects also reproducible
with Docker.
Exact commands and additional validation details are included in the incremental
fork PRs below.
## Review guide
This PR is a linear five-part stack. These fork PRs provide smaller incremental
diffs for review:
1. Extract shared Kubernetes primitives from GKE
2. Add the provider-neutral Kubernetes environment
3. Add pod-native Compose support
4. Add the optional BuildKit backend
5. Add prebuilt image mirror support
Please leave review comments and approvals on this upstream PR. The linked fork
PRs are intended as smaller, incremental diff views.
Closes #1896
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/harbor-framework/harbor/pull/2819" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review">
</picture>
</a>
<!-- devin-review-badge-end -->