How aerospike/aerospike-kubernetes-operator works
Project type and purpose
• This is a Kubernetes Operator (written in Go) for managing Aerospike Enterprise clusters.
• It extends the Kubernetes API via CRDs (aerospikeclusters, aerospikebackups, aerospikebackupservices, aerospikerestores), and implements a controller-reconciler loop plus webhooks to automate lifecycle tasks: deploy, scale, upgrade, backup/restore, monitoring, security, rack/zonal placement.
File structure
• Top-level code:
• cmd/main.go – entry point for the operator (controller-manager).
• api/v1 & api/v1beta1 – Go types defining CRD schemas.
• internal/controller – reconcilers for cluster, backup, restore, backup-service.
• internal/webhook – mutating & validating webhooks for CR validation and defaulting.
• config/… – kustomize manifests: CRDs, RBAC, cluster-service-version, sample CRs, webhook, cert-manager, monitoring, network policies.
• helm-charts/… – Helm charts for operator and CRs.
• test/… – end-to-end and unit tests, test scripts.
• Dockerfile, Jenkinsfile, GitHub workflows – CI/CD pipelines for build, lint, security scans, release.
README for additional insights
• Operator deploys as a Kubernetes StatefulSet (headless service) to maintain stable network identities.
• Layered orchestration: Operator manages Kubernetes primitives (StatefulSets, Services, ConfigMaps, PVCs, PodDisruptionBudgets) to drive Aerospike pods.
• Integrates with cert-manager for webhook certificates, OLM for installation, Prometheus/Grafana/Alertmanager for monitoring, and Helm for packaging.
Main components and their interactions
a. Kubernetes Cluster
• API Server + etcd – stores CRDs and CR instances.
• cert-manager – issues TLS certs for webhooks.
• Monitoring stack – Prometheus scrapes metrics, Grafana dashboards, Alertmanager.
b. Operator (Controller Manager)
• StatefulSet headless service exposing metrics endpoint & webhook server.
• Controllers (Reconciliation loops)
– Cluster controller: manages aerospikecluster CRs → creates/updates StatefulSets, Services, ConfigMaps, PVCs, PodDisruptionBudgets, Secrets.
– Backup/Restore controllers: manage backup and restore CRs → trigger jobs, manage storage, coordinate with Aerospike.
– Backup-Service controller: manages backup-service CR for on-demand backups via HTTP API.
• Webhooks
– Mutating webhook: defaults missing fields, injects sidecars or annotations.
– Validating webhook: enforces schema, cross-field validation, rack/zone placement rules.
• CRDs – definitions under config/crd/bases; installed by Kustomize or Helm.
c. Aerospike Cluster (Pods)
• StatefulSet of N pods running Aerospike server.
• Mounted PVCs for persistent storage (SSD, PMEM, file).
• Optionally sidecar containers for backup or metrics.
d. Helm and OLM
• Helm charts for operator and CRs.
• OLM bundle for catalog and subscription management.
e. CI/CD & Testing
• Docker image build, multi-arch builds via buildx.
• GitHub Actions + Jenkins pipelines for linting, security (Snyk, CodeQL), release.
• Automated tests that spin up test clusters, deploy operator and sample CRs.
Architectural patterns and design principles
• Controller pattern / reconciliation loop – desired vs. actual state.
• Kubernetes operator best practices – CustomResourceDefinitions, RBAC, leader election, metrics.
• Layered orchestration: separate concerns for cluster management vs. backup vs. restore.
• Webhook-driven validation/defaulting.
• Declarative config via Kustomize and Helm.
• Extensibility via Go interfaces, pkg/utils, pkg/merge, pkg/validation.