🤖 feat: implement Helm parity phases 1-2 for CoderControlPlane#77
🤖 feat: implement Helm parity phases 1-2 for CoderControlPlane#77
Conversation
|
@codex review Please review this PR for correctness and any edge cases. |
|
@codex review Addressed the docs-quality failure by removing inline-HTML-looking text from generated API docs comments and regenerated reference docs. Please re-review. |
|
@codex review Added |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 829718547c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed all three review items:
Also added/updated tests covering these cases. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4942b8f05a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the remaining service-port edge case:
Also added a regression test ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9ac36b626
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the default access URL port issue:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 624ccbe806
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the HTTPRoute drift concern by adding an explicit periodic requeue when gateway exposure is actively reconciled (while still avoiding requeue when Gateway CRDs are missing). Added regression assertion in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ebee5513a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the cross-namespace RBAC drift concern by adding periodic requeue when cross-namespace workspace RBAC is enabled (without relying on owner-ref watches). Added regression assertion in the workspace RBAC tests. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3489300488
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed secret-derived volume-name safety:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a1a538587
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Updated volume-name derivation to preserve uniqueness when sanitization changes secret names:
|
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
f2472a7 to
74a79e6
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74a79e659d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the latest feedback:
Also added regression coverage for both behaviors. |
|
@codex review Applied the final gofumpt formatting adjustment from local lint parity and pushed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d64bec3157
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the operator-SDK URL issue:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb402ac2dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed the TLS+servicePort=443 SDK URL issue:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4231453b8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc1405b1ee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
841128a to
0a5f061
Compare
|
@codex review Rebased this branch onto the latest origin/main. Please re-review. |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
This PR implements Phase 1 and Phase 2 Helm-chart parity for
CoderControlPlane, including production-hardening controls, workspace RBAC/ServiceAccount reconciliation, TLS/probe/scheduling passthroughs, and optional external exposure via either Ingress or Gateway API.Background
The operator previously reconciled only a basic Deployment/Service/token flow. The plan for this branch adds the higher-leverage chart capabilities needed for production readiness and operability while preserving fail-fast behavior and backward compatibility.
Implementation
CoderControlPlaneSpecwith parity fields for:spec.expose.ingressorspec.expose.gatewaysigs.k8s.io/gateway-api/apis/v1).NoMatchhandling when Gateway CRDs are absentValidation
make verify-vendormake buildmake testmake manifestsmake codegenmake docs-referenceRisks
📋 Implementation Plan
Plan: Phase 1–2 parity with
coder/coderHelm chart (+ optional Gateway API)Context / Why
We want the
CoderControlPlanecontroller in this repo to reach closer feature parity with the upstreamcoder/coderHelm chart. Today, our operator mainly reconciles:Deploymentrunning the Coder control plane,Service, andSecret(plus license/entitlements logic).The Helm chart additionally provides production-hardening and operability knobs: ServiceAccount + namespace RBAC for workspaces, resource limits, security contexts, TLS enablement, probes, HA env injection, Ingress exposure, scheduling controls, and volume/envFrom passthroughs.
This plan implements Phase 1 (production readiness) and Phase 2 (operability + HA) items, and adds an opt-in exposure API allowing operators to choose Ingress or Gateway API.
Goals (Phases 1 & 2)
networking.k8s.io/v1Ingress, ORgateway.networking.k8s.io/v1Gateway API (HTTPRoute), without requiring Gateway API CRDs to exist unless configured.Non-goals (explicitly deferred)
Evidence / Sources consulted
./tmpfork/coder/helm/coder/templates/_coder.tpl./tmpfork/coder/helm/libcoder/templates/_helpers.tpl./tmpfork/coder/helm/libcoder/templates/_rbac.yamlapi/v1alpha1/codercontrolplane_types.goapi/v1alpha1/types_shared.gointernal/controller/codercontrolplane_controller.gointernal/app/sharedscheme/sharedscheme.goImplementation plan
0) Create a parity tracking document (optional but recommended)
Add a short markdown doc (e.g.,
docs/design/helm-parity.md) listing each Helm chart knob and whichCoderControlPlaneSpecfield covers it. This keeps future parity work honest.Phase 1 — Production readiness
1) Extend the CRD:
CoderControlPlaneSpec(API additions)Files
api/v1alpha1/codercontrolplane_types.goapi/v1alpha1/types_shared.goAdd spec fields (Phase 1 scope)
spec.serviceAccount(new struct)spec.rbac(new struct)spec.resources(*corev1.ResourceRequirements)spec.securityContext(*corev1.SecurityContext)spec.podSecurityContext(*corev1.PodSecurityContext)spec.tls.secretNames([]string) — enable internal TLS when non-emptyspec.readinessProbeandspec.livenessProbe(chart-style config withenabled+ timing knobs)spec.envUseClusterAccessURL(*bool, defaulttrue) — if enabled and user didn’t provideCODER_ACCESS_URLexplicitly viaextraEnv, the operator injects a default in-cluster URL.Proposed Go shapes (illustrative)
Notes
types_shared.gofor structs that may be reused by future CRDs.2) Reconcile ServiceAccount + namespace RBAC for workspaces
Files
internal/controller/codercontrolplane_controller.goWhere
Reconcile()beforereconcileDeployment()so the Deployment can reference the SA.What to add
reconcileServiceAccount(ctx, cp)spec.serviceAccount.disableCreate=true: ensure previously-owned SA is deleted (cleanup).corev1.ServiceAccountnamedspec.serviceAccount.name(default tocp.Name).controlPlaneLabels(cp.Name)plus user-provided SA labels/annotations.reconcileWorkspaceRBAC(ctx, cp)spec.rbac.workspacePerms=false: delete previously-owned Roles/RoleBindings (cleanup).rbacv1.Roleandrbacv1.RoleBindingin:cp.Namespace, andspec.rbac.workspaceNamespaces.Match Helm chart semantics (from
libcoder.rbac.rules.basic/deployments):workspacePerms=true.workspacePerms=true && enableDeployments=true.extraRulesonly whenworkspacePerms=true.Role/RoleBinding naming
<serviceAccountName>-workspace-perms<serviceAccountName>(matches chart)Cleanup strategy
OwnerReferencechecks to delete only operator-owned RBAC objects.cleanupDisabledOperatorAccess.3) Align the Deployment with Helm defaults (ports, probes, env)
Files
internal/controller/codercontrolplane_controller.goChanges
controlPlaneTargetPortfrom3000→8080.--http-address=0.0.0.0:3000→--http-address=0.0.0.0:8080.KUBE_POD_IPfromfieldRef: status.podIPCODER_DERP_SERVER_RELAY_URL=http://$(KUBE_POD_IP):8080CODER_ACCESS_URLinjectionspec.envUseClusterAccessURLis true andextraEnvdoes not setCODER_ACCESS_URL, inject:http://<service>.<namespace>.svc.cluster.localwhen internal TLS disabledhttps://<service>.<namespace>.svc.cluster.localwhen internal TLS enabledspec.readinessProbe.enabled: set readiness probeGET /healthzon named porthttp.spec.livenessProbe.enabled: set liveness probe similarly.corev1.Probefields.spec.resources→container.resources.spec.securityContext→container.securityContext.spec.podSecurityContext→pod.securityContext.pod.spec.serviceAccountNameto the resolved SA name.4) Implement internal TLS (Coder built-in TLS) like Helm
Files
api/v1alpha1/*(spec field already added)internal/controller/codercontrolplane_controller.goBehavior (match Helm chart’s
coder.tlsEnv+ mounts)If
spec.tls.secretNamesis non-empty:CODER_TLS_ENABLE=trueCODER_TLS_ADDRESS=0.0.0.0:8443CODER_TLS_CERT_FILE= comma-separated list of/etc/ssl/certs/coder/<secret>/tls.crtCODER_TLS_KEY_FILE= comma-separated list of/etc/ssl/certs/coder/<secret>/tls.key/etc/ssl/certs/coder/<secret>(read-only)https:8443Service impact
ServicePortnamedhttpsat 443 → targetPort 8443 when TLS is enabled.Status impact
desiredStatus().URLscheme tohttpswhen TLS is enabled.Phase 2 — Operability + HA
5) Add pass-through config knobs: envFrom, volumes, cert bundles, scheduling
API changes
Add these optional fields to
CoderControlPlaneSpec:envFrom []corev1.EnvFromSourcevolumes []corev1.VolumevolumeMounts []corev1.VolumeMountcerts.secrets []SecretKeySelector(name+key) to mount CA certs at/etc/ssl/certs/<name>.crtwithsubPath: keynodeSelector map[string]stringtolerations []corev1.Tolerationaffinity *corev1.AffinitytopologySpreadConstraints []corev1.TopologySpreadConstraintController changes
envFromto container.volumesandvolumeMountsto the pod.6) Exposure API: choose between Ingress or Gateway API
Goal: Let operators choose one of:
networking.k8s.io/v1 Ingress, orgateway.networking.k8s.io/v1 HTTPRoute(Gateway API)6.1 CRD changes: add
spec.exposeAdd a new
ExposeSpecwith mutually exclusiveingressvsgatewayconfig.6.2 Controller changes: reconcile + cleanup
Files
internal/controller/codercontrolplane_controller.goWhere
Reconcile(), reconcile exposure resources afterreconcileService().Ingress reconciliation
networkingv1.Ingressnamedcp.Name(orcp.Name + "-ingress"if name collisions are a concern).host(required)wildcardHostcp.Namespec.service.porttls.secretNameset: addIngressTLS{SecretName, Hosts:[host]}tls.wildcardSecretNameset: addIngressTLS{SecretName, Hosts:[wildcardHost]}Gateway API reconciliation (minimal viable)
gatewayv1.HTTPRoutenamedcp.Name.spec.parentRefs: fromspec.expose.gateway.parentRefs.spec.hostnames: includehostandwildcardHostwhen set./to backend servicecp.Nameat portspec.service.port.Critical compatibility requirement
Owns(&gatewayv1.HTTPRoute{})watches inSetupWithManager, andmeta.IsNoMatchError(err)(or equivalent) during reconcile:6.3 Scheme & deps
sigs.k8s.io/gateway-apitogo.modandvendor/.internal/app/sharedscheme/sharedscheme.go(e.g.,gatewayv1.AddToScheme(scheme)).Cross-cutting work
7) Update operator RBAC markers and generated manifests
Files
internal/controller/codercontrolplane_controller.gokubebuilder RBAC commentsAdd operator permissions to manage new resources:
serviceaccountsroles,rolebindingsingresseshttproutes,gateways(Gateway API)Then regenerate:
make manifests8) Testing plan
Unit/envtest
internal/controller/codercontrolplane_controller_test.go):cp.Namespaceand extra namespacesspec.expose.ingressis set; deleted when unsetIntegration / make targets
make testmake test-integration(if it exercises controller-runtime manager behavior)9) Generated artifacts & docs
make codegenmake manifestsconfig/samples/to include:Validation checklist (when implementing)
make testmake test-integrationmake buildmake lintconfig/) updated and committed.Generated with
mux• Model:openai:gpt-5.3-codex• Thinking:xhigh• Cost:$8.55