memgraph-operator

by Memgraph

Helm chartv1.2.0App 1.2.0Verified publisher

Kubernetes operator for Memgraph high-availability clusters

About this chart

memgraph-operator

Installs the Memgraph Kubernetes operator: the MemgraphDBCluster CustomResourceDefinition, a least-privilege RBAC set, and the controller Deployment. Declaring a cluster is then a single resource — see the repository README.

The chart lives in the operator repository next to the generated manifests: the CRD under templates/crds/ and the manager's RBAC rules under rbac/ are generated from the Go types and the +kubebuilder:rbac markers (make chart-sync), and CI fails if they drift from the controller they ship with.

Install

helm repo add memgraph https://memgraph.github.io/helm-charts
helm repo update
helm install memgraph-operator memgraph/memgraph-operator \
  --namespace memgraph-operator-system --create-namespace --wait

The operator watches every namespace, so one release per cluster is enough.

The chart is maintained in memgraph/kubernetes-operator and published to that index. helm search repo memgraph/memgraph-operator --versions lists what is available, and the chart's appVersion is the operator version an install runs by default. The two version numbers move independently.

Installing from a checkout works the same way:

helm install memgraph-operator ./charts/memgraph-operator \
  --namespace memgraph-operator-system --create-namespace --wait

Uninstall

helm uninstall memgraph-operator --namespace memgraph-operator-system

The chart annotates the MemgraphDBCluster CRD with helm.sh/resource-policy: keep, so it — and with it your clusters and their PersistentVolumeClaims — survives the uninstall. Remove it explicitly when no cluster needs it any more:

kubectl delete crd memgraphdbclusters.memgraph.com

Permissions

The manager's ClusterRole is generated from the controller's own RBAC markers, so it grants exactly what the reconciler issues: read MemgraphDBClusters, patch their status, and create and patch (server-side apply) the StatefulSets, Services, Gateways, TCPRoutes, ServiceMonitors, ConfigMaps and the vmagent Deployment it provisions. It deletes three kinds of thing: Pods, one at a time, to roll a changed pod template through the cluster; StatefulSets, with their pods and claims orphaned, to recreate them with grown claim templates on a storage resize; and the objects a removed spec block leaves behind — the external Services, Gateways and TCPRoutes of a removed externalAccess block or a retired data instance, and the ServiceMonitor, ConfigMaps and vmagent Deployment of a removed monitoring block. The ConfigMap and Deployment rules reach every object of those kinds, but the operator's cache holds only the ones it labelled as its own. It never deletes a headless Service or a PersistentVolumeClaim — deleting a MemgraphDBCluster removes the workloads through garbage collection of the owner references, and claims follow the StatefulSets' retention policy. The Gateway API and monitoring.coreos.com rules are granted whether or not the cluster serves those groups; a cluster without them simply never exercises the rules. Leader election adds a Lease and Events in the operator's own namespace, and the metrics endpoint adds the TokenReview/SubjectAccessReview permissions it authorizes scrapes with. Secrets are read for the license and the AWS credentials: list/watch feed a metadata-only informer that notices a changed license or AWS credentials Secret, and get reads that one Secret uncached, so a renewal or rotation reaches running pods with SET DATABASE SETTING. No Secret data is cached. The only Secrets written are each cluster's two for the memgraph_internal system user the operator logs in as: create for its generated password, which only the operator reads, and patch for the bcrypt hash the pods mount, kept apart so the password never reaches a Memgraph pod. A Secret you name is never written.

Values

KeyDefaultDescription
image.repositorydocker.io/memgraph/kubernetes-operatorOperator image repository
image.tag""Operator image tag; defaults to the chart's appVersion
image.pullPolicyIfNotPresentOperator image pull policy
crds.enabledtrueInstall and upgrade the MemgraphDBCluster CRD with the release (kept on uninstall)
imagePullSecrets[]Secrets used to pull the operator image
replicaCount1Controller replicas
leaderElection.enabledtrueElect a leader, so a second replica can stand by
resources10m/2Gi requests, 500m/2Gi limitsController container resources
metrics.enabledtrueServe the controller-runtime metrics endpoint and create its Service
metrics.port8443Port the metrics endpoint binds to
metrics.securetrueServe metrics over HTTPS with authenticated, authorized scrapes
rbac.createtrueCreate the operator's Roles and bindings
serviceAccount.createtrueCreate the operator's ServiceAccount
serviceAccount.name""ServiceAccount name; required when create is false
serviceAccount.annotations{}Annotations for the ServiceAccount
namespaceOverride""Install the namespaced objects outside the release namespace
nameOverride / fullnameOverride""Override the generated object names
podAnnotations / podLabels{}Extra metadata on the controller pod
nodeSelector / tolerations / affinity{} / [] / {}Scheduling of the controller pod
priorityClassName""PriorityClass of the controller pod
terminationGracePeriodSeconds10Grace period of the controller pod
podSecurityContextnon-root uid/gid 65532, seccomp RuntimeDefaultPod security context
securityContextno privilege escalation, read-only root, all capabilities droppedContainer security context
extraArgs[]Additional controller command-line arguments
extraEnv[]Additional controller environment variables

Deploy memgraph-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has memgraph-operator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmemgraph-operator is pinned at v1.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply