valkey-operator

by mk-raven

Helm chartv0.9.0App v0.9.0Verified publisher

A Helm chart for the Valkey Operator

About this chart

valkey-operator

A Helm chart for deploying the Valkey Operator on Kubernetes.

Note: This chart is under active development. Some features are not yet available and are marked as TODOs in values.yaml.

Note: This chart deploys the Valkey Operator, which manages ValkeyCluster resources. It is separate from the valkey chart, which deploys Valkey instances directly. You can use them independently

Prerequisites

  • Kubernetes 1.31+
  • Helm 3.5+

Upgrading

Helm does not upgrade CRDs automatically during helm upgrade. When upgrading between chart versions that include CRD changes, apply the CRDs manually first. See UPGRADE.md for version-specific instructions.

Installation

helm install valkey-operator valkey/valkey-operator \
  -n valkey-operator-system --create-namespace

This will deploy the operator into the valkey-operator-system namespace. By default the operator watches for ValkeyCluster resources across all namespaces. Set manager.watchNamespaces to restrict it to specific namespaces.

Creating a ValkeyCluster

Once the operator is running, create a ValkeyCluster:

apiVersion: valkey.io/v1alpha1
kind: ValkeyCluster
metadata:
  name: my-cluster
spec:
  shards: 3
  replicasPerShard: 1

Configuration

See values.yaml for the full list of configurable parameters.

Key parameters

ParameterDescriptionDefault
image.repositoryOperator image repositoryvalkey-io/valkey-operator
image.tagOperator image tag"" (uses .Chart.AppVersion)
replicaCountNumber of operator replicas1
serviceAccount.createCreate a ServiceAccounttrue
rbac.createCreate the operator ClusterRole/ClusterRoleBinding and the aggregated admin/editor/viewer ClusterRolestrue
manager.leaderElection.enabledEnable leader electiontrue
manager.watchNamespacesRestrict cache to these namespaces (cluster-wide if empty)[]
manager.defaultImages.valkeyValkey image for a ValkeyCluster that does not set spec.image (passes --default-valkey-image). Changing it rolls those clustersvalkey/valkey:9.0.0
manager.defaultImages.exporterExporter image for a ValkeyCluster that does not set spec.exporter.image (passes --default-exporter-image). Changing it rolls those clustersoliver006/redis_exporter:v1.88.0
podDisruptionBudget.enabledEnable PodDisruptionBudgetfalse
podDisruptionBudget.minAvailableMinimum pods available during disruptionsnull
podDisruptionBudget.maxUnavailableMaximum pods unavailable during disruptions1
podDisruptionBudget.unhealthyPodEvictionPolicyPolicy for evicting unhealthy pods""
topologySpreadConstraintsTopology spread constraints for the operator pods[]
priorityClassNamePriorityClass to assign to the operator pods""
metrics.enabledEnable the metrics endpointtrue
metrics.portMetrics endpoint port8443
metrics.secureServe metrics over HTTPS with authn/authz (passes --metrics-secure=true); renders the metrics RBAC. Requires rbac.create and metrics.enabledfalse
metrics.reader.binding.createBind a scraper ServiceAccount to the metrics-reader ClusterRole. Requires rbac.create, metrics.enabled, and metrics.securefalse
metrics.reader.binding.serviceAccountNameName of the scraper ServiceAccount to authorize. Supports templating; required when binding.create is true""
metrics.reader.binding.namespaceNamespace of the scraper ServiceAccount. Supports templating; defaults to the release namespace when empty""
metrics.serviceMonitor.enabledCreate a Prometheus ServiceMonitor for the metrics endpoint (requires the Prometheus Operator CRDs)false
metrics.serviceMonitor.namespaceNamespace for the ServiceMonitor"" (release namespace)
metrics.serviceMonitor.labelsAdditional labels for the ServiceMonitor{}
metrics.serviceMonitor.annotationsAnnotations for the ServiceMonitor{}
metrics.serviceMonitor.intervalScrape interval""
metrics.serviceMonitor.scrapeTimeoutScrape timeout""
metrics.serviceMonitor.schemeHTTP scheme used for scraping""
metrics.serviceMonitor.tlsConfigTLS configuration used when scraping{}
metrics.serviceMonitor.honorLabelsKeep labels from the scraped target on collisionfalse
metrics.serviceMonitor.relabelingsrelabelings applied before scraping[]
metrics.serviceMonitor.metricRelabelingsmetricRelabelings applied before ingestion[]
networkPolicy.enabledEnable creation of a NetworkPolicy for the operator podfalse
resources.limits.cpuCPU limit500m
resources.limits.memoryMemory limit128Mi
resources.requests.cpuCPU request10m
resources.requests.memoryMemory request64Mi

Network policy

In clusters that default-deny traffic, you can attach a NetworkPolicy to the operator pod by setting networkPolicy.enabled: true. It is disabled by default, so the default behavior is unchanged. This naming mirrors the valkey chart (enabled, extraIngress, extraEgress) for a consistent experience across both charts.

Once enabled, the chart automatically adds the egress the operator needs to function — DNS, the Kubernetes API server, and the managed Valkey pods on the Valkey port (6379) — so locking down egress doesn't break reconciliation. The Valkey egress rule targets the namespaces in manager.watchNamespaces; when that list is empty (watch all namespaces) it allows the Valkey port to every namespace. The policyTypes field is derived automatically from the rules in effect, and optional labels and annotations are added to the resource.

You can tune or disable this behavior:

FieldDefaultDescription
networkPolicy.enabledfalseEnable creation of a NetworkPolicy for the operator pod.
networkPolicy.defaultEgressRulestrueInject the operator's required egress. Set false to manage all egress yourself.
networkPolicy.valkeyPort6379Port the operator uses to reach Valkey pods.
networkPolicy.apiServerPort6443Kubernetes API server port.
networkPolicy.dnsNamespacekube-systemNamespace running kube-dns / CoreDNS.
networkPolicy.extraIngress[]Additional ingress rules appended verbatim to the policy (templated with tpl).
networkPolicy.extraEgress[]Additional egress rules merged with the default operator egress (templated with tpl).
networkPolicy.labels{}Extra labels to add to the NetworkPolicy.
networkPolicy.annotations{}Extra annotations to add to the NetworkPolicy.

The operator pod exposes the metrics port (8443 when metrics.enabled) and a health probe port (8081). The example below allows Prometheus to scrape metrics from a monitoring namespace; the operator egress rules are added for you:

networkPolicy:
  enabled: true
  labels: {}
  annotations: {}
  extraIngress:
    - from:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: monitoring
      ports:
        - protocol: TCP
          port: 8443
  # Any extra egress here is merged with the default operator egress rules.
  extraEgress: []

Aggregated ClusterRoles

When rbac.create is enabled (the default), the chart also ships three aggregated ClusterRoles for the valkeyclusters and valkeynodes custom resources, following the kubebuilder convention:

RoleAggregation labelAccess
*-valkey-adminrbac.authorization.k8s.io/aggregate-to-adminFull management of the CRs (read-only on status)
*-valkey-editorrbac.authorization.k8s.io/aggregate-to-editCreate/update/delete the CRs (read-only on status)
*-valkey-viewerrbac.authorization.k8s.io/aggregate-to-viewRead-only access to the CRs and status

These roll up into the built-in admin, edit, and view ClusterRoles, so cluster admins can grant tenants access to the Valkey CRDs without handing out the operator's own controller permissions.

Metrics and RBAC

By default the operator serves its controller-runtime metrics over plain HTTP. Set metrics.secure: true to serve them over HTTPS with authentication and authorization, following the kubebuilder secure-metrics convention. When secure serving is enabled (and rbac.create is true), the chart renders:

  • a *-metrics-auth ClusterRole + ClusterRoleBinding granting the operator ServiceAccount create on tokenreviews.authentication.k8s.io and subjectaccessreviews.authorization.k8s.io, so it can authenticate and authorize incoming scrape requests; and
  • a *-metrics-reader ClusterRole granting get on the /metrics non-resource URL.

A scraper must present a token whose ServiceAccount is bound to metrics-reader. You can bind it yourself, or let the chart do it by opting in:

metrics:
  secure: true
  reader:
    binding:
      create: true
      # Supports templating, e.g. "{{ .Release.Name }}-prometheus"
      serviceAccountName: prometheus
      # Defaults to the release namespace when empty
      namespace: monitoring

serviceAccountName is required when binding.create is true; rendering fails otherwise. Both metrics.secure and metrics.reader.binding.create default to false, so existing installs keep serving metrics over insecure HTTP unless you opt in.

Source Code

Deploy valkey-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has valkey-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 chartvalkey-operator is pinned at v0.9.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