feat(operator-chart): package the migration operator - #347
Siddhant-K-code wants to merge 25 commits into
Conversation
Replace Helm hook-based migrations with a lightweight Kubernetes operator that watches OpenFGA Deployments, detects version changes, and runs migrations as regular Jobs. - Go operator using controller-runtime (no CRDs) - Helm subchart with opt-in via operator.enabled (default false) - Dedicated migration ServiceAccount (separate from runtime) - Auto-recovery on database failure (delete/retry cycle) - GitHub Actions workflow for multi-arch image builds - Integration test values for local Kubernetes clusters Resolves #211, #107, #120, #100, #126
- Harden pod security (runAsNonRoot, seccompProfile, drop ALL caps) - Find container by name instead of index to handle sidecars - Skip migration for memory datastore - Persist retry-after annotation before Job deletion to survive re-enqueue - Clear MigrationFailed condition on success - Propagate imagePullSecrets and securityContext to migration Jobs - Remove unused RBAC rules (secrets, serviceaccounts) - Add POD_NAMESPACE downward API for namespace-scoped watch default - Remove no-op migration values (timeout, backoffLimit, resources) - Fix migration SA helper to require name when create=false - Guard operator logic on both operator.enabled and migration.enabled - Build and load operator image into kind for chart-testing CI - Add path filters to operator workflow - Fix ADR inaccuracies (retry strategy, default-enabled wording) - Pin Dockerfile base image to golang:1.26.2
- Render extraInitContainers in operator mode (previously skipped) - Add version label to migration Jobs and delete stale Jobs on image change - Use namespaced Role/RoleBinding when watchAllNamespaces is false - Replace Status().Update with Status().Patch to avoid write conflicts - Fix logger.Error(nil, ...) to logger.Info for expected failure state - Wire desiredVersion param into buildMigrationJob for version tracking - Update RBAC: deployments/status verb from update to patch - Don't force replicas: 0 for memory engine in operator mode - Guard migration SA creation on migration.enabled - Document both required labels and mutable tag limitation in README
- Add opt-in annotation (openfga.dev/migration-enabled) so the operator only manages migrations for explicitly opted-in Deployments - Propagate volumes, volumeMounts, and envFrom from the Deployment to migration Jobs for TLS certs and file-based credentials - Remove watchAllNamespaces option; operator is now always namespace-scoped - Update ADR-004 dependency example to match actual file:// reference - Add test for migration-not-enabled skip behavior
- Wrap deployment annotations in conditional to avoid emitting empty annotations: field which produces an invalid manifest - Store full version in annotation (openfga.dev/desired-version) and truncate label to 63 chars to support digest-pinned images - Align operator image default to ghcr.io/openfga/openfga-operator to match CI publishing target
Prevents the operator from being evicted during node drains, which could leave the OpenFGA Deployment stuck at 0 replicas with no controller to scale it back up. Disabled by default; supports both minAvailable and maxUnavailable modes.
The README documented these flags as configurable via the subchart values.yaml, but only --leader-elect and --watch-namespace were actually wired. Add migrationJob.backoffLimit, activeDeadlineSeconds, and ttlSecondsAfterFinished values with matching args in the operator Deployment template.
The _helpers.tpl namespace template already supported namespaceOverride but the value was undeclared in values.yaml, making it undiscoverable.
Falling back to the "default" ServiceAccount would silently grant operator RBAC permissions (Deployment patch, Job create/delete) to a shared SA. Require an explicit name so the user makes a deliberate choice.
Address review findings: add allowPrivilegeEscalation: false for restricted PSS compliance, set default resource requests/limits, add values.schema.json validation, use stable selectorLabels on pod template to prevent spurious rollouts, add .helmignore, and improve Chart.yaml metadata and NOTES.txt with migration commands.
- charts/openfga-operator/ci and charts/openfga/ci values files so chart-testing exercises both the standalone operator subchart and the parent chart with operator.enabled=true. - .github/ci/operator-postgres-values.yaml plus a dedicated workflow step that installs at v1.9.5 and upgrades to v1.14.1 (crossing the v1.10.0 !!REQUIRES MIGRATION!! boundary), asserting the migration ConfigMap and ready rollout at each step.
Both the operator subchart and the parent chart's operator/migration blocks were missing additionalProperties: false, so typos like `migrationjob:` (lowercase), `enbaled: true`, or misplaced fields were silently ignored at install time. Add the guard to all well-defined object blocks — free-form blocks (podAnnotations, resources, securityContext, etc.) stay permissive since they pass through to pod spec.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new standalone openfga-operator Helm chart for installing and configuring the OpenFGA migration operator, plus CI updates to build/load the operator image into the chart-testing kind cluster before ct install.
Changes:
- Introduces the
openfga-operatorchart (Deployment, ServiceAccount, namespaced RBAC, optional PodDisruptionBudget, NOTES, helpers). - Adds strict values validation via
values.schema.jsonand chart-testing install defaults underci/. - Updates the main test workflow to build the operator image and load it into the kind cluster prior to chart installation tests.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| charts/openfga-operator/Chart.yaml | Defines the new chart metadata (name/version/appVersion, Artifact Hub annotations). |
| charts/openfga-operator/values.yaml | Adds default configurable values for image, securityContext, migration job tuning, and PDB. |
| charts/openfga-operator/values.schema.json | Enforces strict values validation and rejects unknown keys. |
| charts/openfga-operator/ci/default-values.yaml | Provides CI-oriented defaults for chart-testing installs. |
| charts/openfga-operator/.helmignore | Adds Helm packaging ignore patterns for the new chart. |
| charts/openfga-operator/templates/_helpers.tpl | Adds chart naming/labeling helpers and serviceAccountName logic. |
| charts/openfga-operator/templates/deployment.yaml | Defines the operator Deployment and wires flags/env/probes/resources. |
| charts/openfga-operator/templates/serviceaccount.yaml | Creates the ServiceAccount (when enabled) with optional annotations. |
| charts/openfga-operator/templates/role.yaml | Grants namespaced RBAC for Deployments/Jobs/ConfigMaps/Leases/Events. |
| charts/openfga-operator/templates/rolebinding.yaml | Binds the Role to the operator ServiceAccount in the operator namespace. |
| charts/openfga-operator/templates/pdb.yaml | Adds optional PDB templating that preserves explicit zero values. |
| charts/openfga-operator/templates/NOTES.txt | Adds post-install notes for checking operator status/logs/migrations. |
| charts/openfga-operator/tests/pdb_test.yaml | Adds Helm unit tests covering PDB defaulting and explicit zero values. |
| charts/openfga-operator/crds/README.md | Reserves the CRD directory for later stages (no CRDs in stage 1). |
| .github/workflows/test.yml | Builds/loads the operator image into kind before running ct install. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ant-k-code-authored-operator-chart
…ant-k-code-authored-operator-chart
…ant-k-code-authored-operator-chart
…ant-k-code-authored-operator-chart
…ant-k-code-authored-operator-chart
…ant-k-code-authored-operator-chart
Summary
Adds the standalone Helm chart used to install and configure the OpenFGA migration operator.
0and documents RBAC requirements for cross-namespace watching.ct install, allowing this intermediate layer to pass installation tests independently.Stack
Native stack 351. Open #345 to view the GitHub stack map. Review bottom to top:
mainReplaces closed #338 and carries the operator chart portion of source #331. OpenFGA chart integration and upgrade E2E remain in later layers.
Attribution
The 14 original chart commits are replayed with Ed Milic (@emilic) as their actual Git author, preserving their original author dates, messages, and commit boundaries. GitHub links the replayed commits to
@emilic.Validation
ct lintgit diff --check