How ravindar55/gitops-operator works
Project type and purpose
• This is a Kubernetes Operator (written in Go) designed for OpenShift. It installs and manages a cluster-wide Argo CD (and associated GitOps components) via CustomResourceDefinitions (CRDs).
• It integrates with Operator Lifecycle Manager (OLM), provides OLM bundle/manifests, and supports OpenShift-specific features (Console plugin, Prometheus metrics, Redis HA for caching, Dex/RHSSO SSO, Argo Rollouts).
File structure
• Top-level:
• api/v1alpha1 – Go types for custom resources (GitOpsService, AnalysisRun, RolloutManager, etc.)
• controllers/ – Reconcile loops for each CRD: argocd, gitopsservice, notifications, rollout managers, metrics, consoleplugin
• config/ – Kustomize-based Kubernetes manifests (CRDs, RBAC, manager deployment, webhook, Prometheus, samples)
• bundle/ – OLM bundle Dockerfile and manifests (ClusterServiceVersion, CRD definitions, ServiceAccount, Roles, etc.)
• build/ – Templates and scripts to deploy Redis HA (config, liveness/readiness probes, HAProxy, Sentinel)
• main.go – Operator manager entrypoint (sets up manager, controllers, webhooks)
• hack/, scripts/ – helper scripts for development and CI (installing SDK, running tests)
• test/ – e2e and unit tests, KUTTL fixtures, sample app CRs and YAMLs
• Notice the MVC-style pattern:
• Model: api/v1alpha1 types
• Controller: reconcile logic in controllers/
• Views: resulting Kubernetes resources (Deployments, StatefulSets, Services, Routes, ConfigMaps, Secrets)
Key insights from README
• The operator:
• Installs CRDs and watches GitOpsService custom resources
• Deploys Argo CD cluster instance with default settings in namespace “openshift-gitops”
• Manages Redis HA cluster as backing store
• Integrates with OpenShift Console, Prometheus, OLM
• Supports progressive delivery via RolloutManager CRDs
a. Kubernetes cluster core
• API Server (CRDs registered)
• etcd
b. OLM / OperatorHub
• CatalogSource → Operatorsource → CSV
c. GitOps Operator (manager)
• Deployment “openshift-gitops-operator-controller-manager”
• Containers: manager (runs all controllers), webhook server
d. CRDs & Custom Resources
• GitOpsService (defines Argo CD installation)
• AnalysisRun/AnalysisTemplate, RolloutManager, NotificationsConfiguration
e. Controllers (inside manager)
• GitOpsServiceController → creates Argo CD resources + Redis cluster
• ArgoCDController → manages Argo CD cluster‐scoped instances
• ArgoCDMetricsController → configures ServiceMonitor for Prometheus
• NotificationsController → sets up NotificationConfig
• RolloutManagerController → deploys Argo Rollouts support
• ConsolePluginController → registers UI extension in OpenShift console
f. Operand components deployed by the operator
• Argo CD core: server, repo, dex, UI, metrics
• Redis HA cluster: StatefulSet, HAProxy, Sentinel, ConfigMaps
• Services, Routes, Ingress, ConfigMaps, Secrets
• Prometheus ServiceMonitor
g. External services
• Quay.io (pull operator + backend images)
• RHSSO / Dex identity providers
• Git repos (Argo CD sync targets)
Relationships & data flow
1. OLM installs the Operator (CSV → Deployment → ServiceAccount, Roles, RoleBindings).
2. Operator registers CRDs with API Server.
3. User or OLM creates GitOpsService CR in “openshift-gitops-operator” namespace.
4. GitOpsServiceController watches CR → reconcile loop triggers.
5. Operator creates:
• Namespace “openshift-gitops”
• Argo CD cluster instance (Deployment, StatefulSets, Services, Routes)
• Redis HA cluster (StatefulSet, HAProxy sidecar, Sentinel)
• ConfigMaps for Dex, RBAC, console plugin assets
• ServiceMonitor & Roles for Prometheus
• Additional CRDs (RolloutManager, NotificationConfiguration) if specified
6. Argo CD components serve HTTP/gRPC, sync Git repos, store state in Redis.
7. Dex/RHSSO handle authentication for Argo CD UI/API.
8. Prometheus scrapes metrics via ServiceMonitor.
9. Console Plugin adds UIs to OpenShift console.
Architectural patterns & design principles
• Kubernetes Operator pattern: Reconcile‐driven, declarative.
• MVC within operator: api/types (model), controllers (controller), YAML manifests / CRs (view).
• Separation of concerns: each controller handles a CRD.
• Use of Kustomize for multi‐environment overlays (config/default, manager, webhook, samples).
• OLM bundle design for packaging and distribution.
• Template‐based Redis HA build using Go‐text templates.
Essential elements
• Controller loops for each CRD (GitOpsServiceController, ArgoCDController, etc.)
• Operator manager container hosting controllers
• Resulting Kubernetes resources: Argo CD Deployment & StatefulSets, Redis HA cluster, ConfigMaps, Secrets, ServiceMonitors
• External dependencies: Quay.io (image registry), Git repos (Argo sync targets), Identity provider
• OLM objects: CatalogSource, CSV, Subscription