How jakub-k-slys/n8n-operator works
Project type and purpose
• This is a Kubernetes operator—specifically, the “n8n-operator”—written in Go using Kubebuilder/controller-runtime.
• Its purpose is to watch custom N8n CRs (Custom Resources), and on each reconciliation, automatically create/manage the underlying Kubernetes resources (Deployments, Services, Ingress or Gateway‐API HTTPRoutes, PVCs) and configure external PostgreSQL connections for n8n workflow instances.
File structure
• Top-level directories:
• api/v1alpha1: Go types for the N8n CRD (groupVersionInfo, type definitions, deepcopy).
• cmd/main.go: the operator’s entrypoint, sets up manager and controllers.
• internal/controller: the Reconciler logic (n8n_controller.go), tests.
• config/: Kustomize manifests for CRDs, RBAC, manager Deployment, network policies, Prometheus monitors, sample CRs, scorecard tests.
• bundle/: an OLM (Operator Lifecycle Manager) bundle (CSV, RBAC, CRDs) for packaging and distribution.
• hack/, test/: helper scripts and E2E/unit tests.
• Build & deployment configuration:
• Dockerfile & bundle.Dockerfile for images; Makefile targets for build/push, install/deploy/uninstall, scorecard; .golangci.yml for linting.
README for additional insights
• Describes two traffic-routing options (Ingress vs. Gateway API HTTPRoute).
• Explains PostgreSQL parameters, persistent storage, TLS, and secure non-root execution.
• Provides sample CR YAMLs, deployment steps (make docker-build/push, make install/deploy).
Elements
• Clear labels: e.g., “N8n CRD,” “Operator Manager,” “Reconciler,” “n8n Deployment,” “Ingress,” “HTTPRoute,” “PVC,” “PostgreSQL.”
• Cluster built-in components (e.g., grey)
• CRD & custom resources (e.g., green)
• External services (e.g., orange)
Detail and essential architectural elements
• Break out the Manager into subparts: metrics server, leader election, controller registration.
• RBAC roles/bindings granting the Operator permissions.
• Call out Kustomize overlays for CRDs vs. manager deployment vs. defaults.
• OLM CSV metadata and bundle/metadata folder as the packaging layer.