-
Notifications
You must be signed in to change notification settings - Fork 75
feat: operator migration #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emilic
wants to merge
42
commits into
main
Choose a base branch
from
feat/operator-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
2908fa1
docs: add ADRs for OpenFGA operator proposal
emilic c6a645a
feat: add operator for migration orchestration (Stage 1)
emilic 4108b2a
fix: address PR #309 review feedback from Copilot and CodeRabbit
emilic 40ca6ca
fix: address additional Copilot review feedback on PR #309
emilic 7e33bf7
fix: address remaining PR #309 review feedback
emilic ff2b39a
fix: remove EnvFrom from migration Job to preserve least-privilege
emilic 722f3e7
fix: address Copilot review round 3 on PR #309
emilic b2c0061
fix: desired version to replace problematic ":" with "_" for label va…
emilic c84d751
fix: address Copilot review comments
emilic 0f0c736
fix: validate flags to prevent negative or out-of-range values (i.e. …
emilic c415e56
fix: gate legacy migration initContainers on operator.enabled
emilic d642358
fix: use single quotes for Helm annotations with nested template expr…
emilic 3740978
fix: address Copilot review round 6 on PR #309
emilic a71fbe6
fix: remove env var filtering, fix tests, updated README.md to clarif…
emilic 767d6eb
fix: update includes OwnerReferences
emilic 65be2d7
feat: add PodDisruptionBudget to operator subchart
emilic aaddab3
fix: use Job conditions instead of status counters for failure detection
emilic 6d25647
test: add helm-unittest tests for operator mode
emilic 3d88092
fix: inherit resource limits in operator migration Job
emilic f864451
test: add missing controller unit tests for edge cases
emilic f70c58f
fix: wire migration Job flags (backoff/deadline/TTL) through Helm values
emilic 1be6309
fix: document namespaceOverride in operator subchart values.yaml
emilic 96edaf9
fix: rename misleading ScaleToZero test to match actual behavior
emilic 329f05e
fix: require explicit serviceAccount.name when create=false
emilic ec643f9
docs: update chart structure
emilic bd534ca
fix: handle AlreadyExists on migration Job creation gracefully
emilic 467b1ea
fix: harden openfga-operator chart security and quality defaults
emilic dfe3180
fix: replace scale-to-zero with lookup-based zero-downtime upgrades
emilic 4d46e90
refactor(operator): resolve container via annotation and tidy deploym…
emilic 022a8f4
chore: remove ADRs not relevant to this PR
emilic 0bea6c4
fix: clear retry-after annotation after Job creation
emilic 06d8130
fix: a migration Job without a version annotation or matching label i…
emilic 4700037
fix(chart): restore full label set on pod template metadata
emilic 9763e5e
ci: add operator-mode coverage and v1.9.5 → v1.14.1 upgrade E2E
emilic 160f1e9
docs: update docs to reflect operator deployment changes
emilic a7bffbe
fix(operator): react to JobFailureTarget for fast failure detection
emilic 2cb102d
chore(schema): reject unknown keys in operator and migration values
emilic 98e2b8b
ci(operator): build multi-arch on PRs, add immutable tag on main
emilic 729b0ec
docs(chart): explain 0-replica install in NOTES when operator is enabled
emilic d106292
fix: add missing global block to fix helm unit tests
emilic ff6de22
fix(operator): use multi-arch base image digests + Go cross-compile
emilic 4bdead4
docs(operator-chart): clarify watchNamespace default
emilic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # E2E values consumed by the "operator + postgres E2E" step in test.yml. | ||
| # Not under charts/openfga/ci/ on purpose — chart-testing's helm-test runs | ||
| # a gRPC probe immediately after install, which would race the operator's | ||
| # scale-up. The dedicated workflow step waits for the migration ConfigMap | ||
| # and the scale-up explicitly, then verifies readiness. | ||
| replicaCount: 1 | ||
|
|
||
| operator: | ||
| enabled: true | ||
|
|
||
| migration: | ||
| enabled: true | ||
|
|
||
| datastore: | ||
| engine: postgres | ||
| uriSecret: openfga-e2e-postgres-credentials | ||
|
|
||
| openfga-operator: | ||
| image: | ||
| pullPolicy: Never | ||
|
|
||
| extraObjects: | ||
| - apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: openfga-e2e-postgres-credentials | ||
| stringData: | ||
| uri: "postgres://openfga:changeme@openfga-e2e-postgres:5432/openfga?sslmode=disable" | ||
| - apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: openfga-e2e-postgres | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: openfga-e2e-postgres | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: openfga-e2e-postgres | ||
| spec: | ||
| containers: | ||
| - name: postgres | ||
| image: postgres:17 | ||
| ports: | ||
| - containerPort: 5432 | ||
| env: | ||
| - name: POSTGRES_USER | ||
| value: openfga | ||
| - name: POSTGRES_PASSWORD | ||
| value: changeme | ||
| - name: POSTGRES_DB | ||
| value: openfga | ||
| - name: PGDATA | ||
| value: /var/lib/postgresql/data/pgdata | ||
| volumeMounts: | ||
| - name: data | ||
| mountPath: /var/lib/postgresql/data | ||
| readinessProbe: | ||
| exec: | ||
| command: ["pg_isready", "-U", "openfga", "-d", "openfga"] | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 5 | ||
| volumes: | ||
| - name: data | ||
| emptyDir: {} | ||
| - apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: openfga-e2e-postgres | ||
| spec: | ||
| selector: | ||
| app: openfga-e2e-postgres | ||
| ports: | ||
| - port: 5432 | ||
| targetPort: 5432 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| name: Operator | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "operator/**" | ||
| - "charts/openfga-operator/**" | ||
| - ".github/workflows/operator.yml" | ||
| pull_request: | ||
| paths: | ||
| - "operator/**" | ||
| - "charts/openfga-operator/**" | ||
| - ".github/workflows/operator.yml" | ||
| workflow_dispatch: | ||
| inputs: | ||
| push_image: | ||
| description: "Push the operator image to GHCR" | ||
| type: boolean | ||
| default: true | ||
|
|
||
| env: | ||
| IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/openfga-operator | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: operator/go.mod | ||
| cache-dependency-path: operator/go.sum | ||
|
|
||
| - name: Run tests | ||
| working-directory: operator | ||
| run: go test ./... -v | ||
|
|
||
| - name: Run vet | ||
| working-directory: operator | ||
| run: go vet ./... | ||
|
|
||
| build-and-push: | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Extract version from Chart.yaml | ||
| id: version | ||
| run: | | ||
| version=$(grep '^appVersion:' charts/openfga-operator/Chart.yaml | awk '{print $2}' | tr -d '"') | ||
| echo "version=${version}" >> "$GITHUB_OUTPUT" | ||
| short_sha="${GITHUB_SHA::7}" | ||
| echo "short_sha=${short_sha}" >> "$GITHUB_OUTPUT" | ||
| echo "Operator version: ${version} (sha: ${short_sha})" | ||
|
|
||
| - name: Determine image tags and push policy | ||
| id: tags | ||
| run: | | ||
| if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then | ||
| # Main push: publish floating :<version> and :latest plus an | ||
| # immutable :<version>-<sha> so consumers pinning a specific | ||
| # commit have a stable reference. | ||
| echo "tags=${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }},${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}-${{ steps.version.outputs.short_sha }}" >> "$GITHUB_OUTPUT" | ||
| echo "push=true" >> "$GITHUB_OUTPUT" | ||
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.push_image }}" == "true" ]]; then | ||
| echo "tags=${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}-${{ steps.version.outputs.short_sha }}" >> "$GITHUB_OUTPUT" | ||
| echo "push=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| # Pull request (or workflow_dispatch with push_image=false): | ||
| # build both platforms but don't publish — catches arm64-incompatible | ||
| # changes (build tags, syscalls, CGO) before they merge. | ||
| echo "tags=${{ env.IMAGE_NAME }}:pr-${{ steps.version.outputs.short_sha }}" >> "$GITHUB_OUTPUT" | ||
| echo "push=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Login to GHCR | ||
| if: steps.tags.outputs.push == 'true' | ||
| uses: docker/login-action@v4.1.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build and (conditionally) push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: operator | ||
| push: ${{ steps.tags.outputs.push }} | ||
| platforms: linux/amd64,linux/arm64 | ||
| tags: ${{ steps.tags.outputs.tags }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| labels: | | ||
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
| org.opencontainers.image.version=${{ steps.version.outputs.version }} | ||
| org.opencontainers.image.revision=${{ github.sha }} | ||
| org.opencontainers.image.title=openfga-operator | ||
| org.opencontainers.image.description=OpenFGA Kubernetes operator for migration orchestration | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Patterns to ignore when building packages. | ||
| .DS_Store | ||
| .git | ||
| .gitignore | ||
| .bzr | ||
| .bzrignore | ||
| .hg | ||
| .hgignore | ||
| .svn | ||
| *.swp | ||
| *.bak | ||
| *.tmp | ||
| *.orig | ||
| *~ | ||
| .project | ||
| .idea | ||
| *.tmproj | ||
| .vscode |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| apiVersion: v2 | ||
| name: openfga-operator | ||
| description: Helm chart for the OpenFGA Kubernetes operator. | ||
|
|
||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "0.1.0" | ||
|
|
||
| home: "https://openfga.github.io/helm-charts" | ||
| icon: https://github.com/openfga/community/raw/main/brand-assets/icon/color/openfga-icon-color.svg | ||
|
|
||
| maintainers: | ||
| - name: OpenFGA Authors | ||
| url: https://github.com/openfga | ||
| sources: | ||
| - https://github.com/openfga/helm-charts | ||
|
|
||
| annotations: | ||
| artifacthub.io/license: Apache-2.0 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Standalone install exercise for chart-testing. | ||
| # kind has the operator image preloaded, so skip the registry pull. | ||
| image: | ||
| pullPolicy: Never |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # CRDs | ||
|
|
||
| This directory is reserved for Custom Resource Definitions added in later stages. | ||
| No CRDs are installed in Stage 1 (migration orchestration). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| The openfga-operator has been deployed. | ||
|
|
||
| NOTE: Ensure the operator image ({{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}) is available in your registry. | ||
| If unavailable, the operator pod may remain in ImagePullBackOff until the image is pushed. | ||
|
|
||
| To check operator status: | ||
| kubectl get deployment --namespace {{ include "openfga-operator.namespace" . }} {{ include "openfga-operator.fullname" . }} | ||
|
|
||
| To view operator logs: | ||
| kubectl logs --namespace {{ include "openfga-operator.namespace" . }} -l "app.kubernetes.io/name={{ include "openfga-operator.name" . }}" | ||
|
|
||
| To check migration status: | ||
| kubectl get configmap -n {{ include "openfga-operator.namespace" . }} -l app.kubernetes.io/managed-by=openfga-operator | ||
|
|
||
| To inspect migration jobs: | ||
| kubectl get jobs -n {{ include "openfga-operator.namespace" . }} -l app.kubernetes.io/part-of=openfga,app.kubernetes.io/component=migration |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.