Repository navigation
feat(k8s): bridge any workload kind as a Deployment - #15
Merged
Merged
Conversation
A CronJob can now be a bridge's source. It's bridged as a single-replica Deployment running the CronJob's pod template, so the bridge gets the job's service account, env and volumes, but not its schedule; run the job in the devcontainer with `bridge exec`. restartPolicy becomes Always and activeDeadlineSeconds is dropped, since a Deployment's pods allow neither. - --source manifests with no Deployment bridge their CronJob (the first by name, if there are several). It isn't also saved as a CronJob. Manifests that have a Deployment are unchanged. - `bridge create <name>` falls back to a CronJob of that name when there's no Deployment. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Replaces the CronJob-specific conversion with one that works for every workload kind: take the workload's pod template (spec.template, or spec.jobTemplate.spec.template for a CronJob) and its metadata, and build a single-replica Deployment from them. The rest of the pipeline only ever sees that Deployment. - --source manifests: every document with a pod template becomes a Deployment, ordered by kind (Deployment, StatefulSet, DaemonSet, ReplicaSet, Job, CronJob), so a Deployment is the source whenever the manifests have one. A converted workload isn't also saved as itself. - `bridge create <name>` looks the name up with the dynamic client across those kinds, in that order, and returns WorkloadNotFoundError (NotFound over gRPC) when none has it. - Drops the CronJob example from `bridge create --help`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
WorkloadKind is an interface with GVK() and PodTemplatePath(), implemented once per supported kind (Deployment, StatefulSet, DaemonSet, ReplicaSet, Job, CronJob). DeploymentFromWorkload takes the kind and reads the template at its path, instead of trying every path on any object; a supported kind with no template there is an error. Only those kinds are bridged as a Deployment. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets a bridge be created from any workload kind, not just a Deployment. Today
bridge create --sourcewith, say, a CronJob's manifests fails withno deployment found in bundle, so a cron service can't be developed or tested against staging the way a Deployment can.How
One conversion for every kind,
DeploymentFromWorkload(kind, obj): take the workload's pod template and its metadata, and build a single-replica Deployment from the two. Everything after sourcing is unchanged: the transforms, save, the proxy and the devcontainer only ever see that Deployment.WorkloadKindis an interface withGVK()andPodTemplatePath(), implemented once per supported kind:spec.templatespec.jobTemplate.spec.templateThe template is read at the kind's own path. A supported kind with no template there is an error, and other kinds aren't bridged.
Metadata: name, namespace, labels, annotations.
restartPolicybecomesAlwaysandactiveDeadlineSecondsis dropped, since a Deployment's pods allow neither. A template with no labels getsapp: <name>for its selector, whichTransformSelectorsthen replaces anyway.A bridge made from a Job or CronJob runs its pod, not its schedule or completion. You run the job in the devcontainer with
bridge exec.Where
--sourcemanifests: every document of a supported kind becomes a Deployment; everything else is handled as before. They're ordered by kind (Deployment, StatefulSet, DaemonSet, ReplicaSet, Job, CronJob), so a Deployment is the source whenever the manifests have one.bdg-*CronJob, which ran on its schedule in the cluster.InjectProxyImagealready forced one replica, and nothing reads the other spec fields (strategy, etc.).bridge create <name>: looks the name up through the dynamic client across those kinds, in that order, so a Deployment still wins a name clash. None found →WorkloadNotFoundError, mapped to gRPCNotFoundlikeDeploymentNotFoundError.This is administrator-side (
pkg/k8s/resources), so it takes effect once the administrator runs a build with it.Testing
workload_test.go:WorkloadKindconverts, keeping name, namespace, labels, annotations, service account and env, with one replica,Alwaysrestart and no deadlinedynamic/fake: finds a CronJob, prefers a same-named Deployment, and not-foundgo test ./...withoute2e, 12 packages),go vetis clean, andbridge create --helpis unchanged frommain.bridge administratorand--admin-addr 127.0.0.1:19090:bridge create cron-managed-drives-prunerwith no--sourcefound venus's real CronJob by name. Its bridge pod came up with the CronJob's service account (oidc-cron-managed-drives-pruner).--sourcemanifests:bridge execran the job to completion as that role.api-managed-drivesfrom Deployment manifests came up with its own service account.🤖 Generated with Claude Code