How ansible/galaxy-operator works
Project Type & Purpose
• This is a Kubernetes Operator project (“Galaxy-Operator”) built with the Ansible Operator SDK.
• It provides three Custom Resource Definitions (CRDs) – Galaxy, GalaxyBackup, GalaxyRestore – and uses Ansible roles/playbooks to reconcile cluster state when those CRs are created or modified.
• It manages the full lifecycle of a Galaxy service deployment (Galaxy API, Web UI, Worker, Content services), plus backing up and restoring data (Postgres, Redis, object storage, etc.).
Top-Level Structure & Architectural Patterns
• .ci & .github: CI/CD pipelines and scripts that build/push Operator and related images.
• config/: Kubernetes manifests (CRDs, RBAC, Kustomize overlays) that define what the operator installs.
• watches.yaml: Tells the operator which CRDs to watch and which Ansible playbooks to run.
• roles/ & playbooks/: Ansible roles and playbooks implementing reconciliation logic for Galaxy, backup, restore, plus common utility roles (Postgres, Redis, object storage).
• molecule/: Integration tests that validate the operator in a Kind cluster.
Architectural Pattern:
• Kubernetes Controller pattern (watch → reconcile → actuate).
• CRDs → Operator → Ansible engine → Kubernetes API.
Main Components
• Kubernetes Cluster (API Server, etcd)
• CRDs (Galaxy, GalaxyBackup, GalaxyRestore)
• Galaxy-Operator Pod
• Ansible Operator SDK (controller manager)
• Ansible engine + Watcher (from watches.yaml)
• Ansible Roles/Playbooks
• galaxy-api, galaxy-web, galaxy-worker, galaxy-content
• postgres, redis, backup, restore, common
• Managed Kubernetes Resources
• Deployments/StatefulSets (Galaxy API, Web, Worker, Postgres, Redis)
• Services, Ingress/Routes, PVCs, ConfigMaps, Secrets
• Jobs (backup/restore)
• External Dependencies
• Object storage (AWS S3, Azure Blob)
• Container registries (quay.io for images)
Relationships & Data Flows
• CRD event → Operator’s Controller Manager → Ansible engine
• Ansible playbooks perform tasks via Kubernetes API (create/update Deployments, Services, Secrets, PVCs, Jobs)
• Galaxy pods connect to Postgres and Redis services
• Backup jobs push data to object storage; Restore jobs pull data back into Postgres/PVCs
• Operator status is updated on the CR status sub-resource
Essential Elements
• Clear component labels (e.g., “Galaxy-Operator Pod”, “Postgres StatefulSet”).
• Callouts for key technologies: Ansible Operator SDK, Kubernetes API server, CRDs, Kustomize, Molecule tests.