kbridge
kbridge is a single, generic Kubernetes controller that manages objects in external HTTP APIs from custom resources. A YAML descriptor describes each resource kind: the CRD schema, the HTTP calls that read, create, update and delete the external object, and the projection of the API response back into the spec shape. Adding a provider or a resource kind needs no Go code.
kbridge detects drift: on every sync it compares the external object with the spec, then reapplies the spec, raises an alert, or ignores the difference, as the resource’s drift policy says.
Status: early development. The shipped descriptors (AWS S3 bucket, Cloudflare R2 bucket, Proxmox VE storage) pass the integration tests against API fakes; they have not run against the real APIs yet.
How it works
kbridge genturns the descriptors into CRDs and RBAC.kbridge runstarts one controller per enabled resource kind.- For each custom resource, the controller resolves its
ProviderConfigand credentials, reads the external object, creates it when absent, compares it withspec.forProvider, and calls the update operation for the fields that differ. - The result goes to
status: conditionsReadyandSynced, and the observed state instatus.atProvider. Drift also produces Kubernetes events, log lines and Prometheus metrics.
Quick start
Build and validate the shipped descriptors:
make build
./bin/kbridge validate --descriptors providers
Output:
aws/s3-bucket Bucket.s3.aws.kbridge.io/v1alpha1
cloudflare/r2-bucket Bucket.r2.cloudflare.kbridge.io/v1alpha1
proxmox/storage Storage.storage.proxmox.kbridge.io/v1alpha1
3 resource(s) valid
Build and push the image, which embeds the providers/ directory:
docker build -t <registry>/kbridge:0.1.0 .
docker push <registry>/kbridge:0.1.0
Set newName: <registry>/kbridge and newTag: 0.1.0 under images in deploy/kustomization.yaml, then install the namespace, CRDs, RBAC and controller:
kubectl apply -k deploy
Store the AWS credentials in the controller namespace, without putting them on the command line:
kubectl -n kbridge create secret generic aws-credentials \
--from-file=accessKeyId=./access-key-id \
--from-file=secretAccessKey=./secret-access-key
Create a ProviderConfig and a bucket:
kubectl apply -f docs/examples/providerconfig-aws.yaml
kubectl apply -f docs/examples/s3-bucket.yaml
kubectl -n web get buckets.s3.aws.kbridge.io
docs/examples/ also holds an IRSA ProviderConfig and the Cloudflare R2 and Proxmox VE equivalents. Proxmox VE is self-hosted: see Self-hosted APIs first. The test suite validates every example against the generated CRDs.
Commands
Exit codes: 0 on success, 1 for invalid descriptors, flags or runtime errors, 2 for a missing or unknown command.
kbridge validate
Loads and validates the descriptors, then lists the enabled resources.
| Flag | Required | Default | Description |
|---|---|---|---|
--descriptors | yes | Directory holding Provider and Resource descriptors. It is searched recursively. Hidden entries and testdata directories are skipped. | |
--resources | no | all | Comma-separated provider/resource list to enable. |
kbridge gen
Prints the CRDs, ClusterRole, Role and bindings the enabled resources need, as YAML documents on stdout. make manifests writes the output for the shipped providers to deploy/generated.yaml; a test fails when that file is stale.
| Flag | Required | Default | Description |
|---|---|---|---|
--descriptors | yes | As for validate. | |
--resources | no | all | As for validate. |
--namespace | no | kbridge | Namespace the controller runs in. The Role (Secrets, leases, events) is created there. |
--service-account | no | kbridge | Service account the controller runs as. |
./bin/kbridge gen --descriptors providers --resources aws/s3-bucket > s3.yaml
kbridge run
Runs the controllers until it receives SIGINT or SIGTERM. At startup it checks that the CRD of every enabled resource is installed and serves the expected version.
| Flag | Required | Default | Description |
|---|---|---|---|
--descriptors | yes | As for validate. The image ships the descriptors in /providers. | |
--resources | no | all | As for validate. |
--namespace | yes | Namespace of the credential Secrets and the leader election lease. The deployment passes the pod namespace. | |
--kubeconfig | no | in-cluster | Kubeconfig file. Without it, kbridge uses the pod service account and never reads ~/.kube/config. |
--metrics-addr | no | :8080 | Prometheus metrics address; 0 disables it. |
--health-addr | no | :8081 | Address of /healthz and /readyz; 0 disables it. |
--leader-elect | no | true | Elect a leader so that only one replica reconciles. |
--workers | no | 4 | Concurrent reconciles per resource kind. |
--log-level | no | info | debug, info, warn or error. Logs are JSON on stderr; debug adds one line per API request. |
Documentation
- Operating kbridge:
ProviderConfig, credentials, managed resource fields, status, drift, adoption, deletion, metrics. - Descriptor reference: every field of
ProviderandResourcedescriptors, and the expression variables. - Writing a provider: how to describe a new API, with the pitfalls to avoid.
Development
Requirements: Go 1.26 (the go command downloads it when GOTOOLCHAIN=auto). Lint and envtest tools run through go run at pinned versions.
make check # fmt, vet, lint, tests with the race detector, coverage >= 85 %
make test downloads the Kubernetes API server binaries for envtest and fails if it cannot. The integration tests run the shipped descriptors against fake S3, R2 and Proxmox VE APIs, and against a fake API that assigns identifiers on create. They need no cloud account and touch no cluster.