VMDistributed is the Custom Resource Definition for orchestrated updates of several VictoriaMetrics clusters or single-node instances. It allows you to define and manage components of a distributed VictoriaMetrics setup and apply changes to them sequentially, ensuring high availability and minimal disruption.
Note: VMDistributed is an experimental feature and may not be suitable for production environments. The API is not yet stable and may change in future releases.

For a high-level overview of VictoriaMetrics distributed cluster architecture, refer to the official VictoriaMetrics documentation .
Specification #
The VMDistributed resource allows you to configure various aspects of your VictoriaMetrics distributed cluster. The specification includes:
retain: If set totrue, the operator will keep managed components during VMDistributed CR removal.paused: If set totrue, the operator will not perform any actions on the underlying managed objects, except removing theVMDistributeditself. Useful for temporarily halting reconciliation.backendType: Specifies the backend type for all zones. EitherVMCluster(default) orVMSingle. All zones must use the same backend type.vmauth: Configuration for aVMAuthinstance that acts as a proxy/load-balancer for thevmselect(orVMSingle) andvmagentcomponents of the managed zones. It acts as a global read and write path entry point. Its name defaults to theVMDistributedname. Setvmauth.enabled: falseto skip creating it.zoneCommon: DefinesVMDistributedZoneCommoncommon zone configuration, which is default for each zone resource.zones: Defines the list ofVMDistributedZonethat form the distributed setup.license: Configures the license key for enterprise features. If provided, it is automatically passed to the managedVMAuth, allVMAgent,VMCluster, andVMSingleinstances, unless they set their ownlicense.
VMDistributedZoneCommon
#
Every field except readyTimeout and updatePause is a default for each zone and can use the %ZONE% placeholder. Values set in a zone are merged on top of it.
vmcluster: DefaultVMDistributedZoneClusterfor each zone. Must not be set whenspec.backendType: VMSingle.vmsingle: DefaultVMDistributedZoneSinglefor each zone. Must not be set whenspec.backendType: VMCluster.vmagent: DefaultVMDistributedZoneAgentfor each zone. Itsspecsupports a subset ofVMAgentSpecfields. Remote write targets are managed by the operator; useremoteWritebelow for their settings.remoteWrite: Default remote write settings that every zone’svmagentuses to write to the zone’s backend, for examplebasicAuth,tlsConfig,sendTimeoutandheaders. SeeVMDistributedZoneRemoteWriteSpecfor all fields. The URL is set by the operator.readyTimeout: The readiness timeout for each zone update. Default is5m.updatePause: Time the operator should wait between zone updates to ensure a smooth transition. Default is1m.
VMDistributedZone
#
Each entry in the zones array includes:
namedefines the zone name. It is used for default per-zone resource names and replaces the%ZONE%placeholder inzoneCommon.trafficModecontrols which trafficvmauthroutes to the zone:read-write(default when unset): the zone serves reads and writes.read-only: the zone is removed from thewritebackend. ForVMCluster,vminsertis scaled to 0, sovmagentbuffers the zone’s data until writes are enabled again.write-only: the zone is removed from thereadbackend.maintenance: the zone is removed from both backends, andvminsertis scaled to 0 like inread-only.
vmclusterdefinesVMDistributedZoneCluster, which either references an existingVMClusterresource or creates a new one. Must not be set whenspec.backendType: VMSingle.vmsingledefinesVMDistributedZoneSingle, which either references an existingVMSingleresource or creates a new one. Must not be set whenspec.backendType: VMCluster.vmagentdefinesVMDistributedZoneAgent, which either references an existingVMAgentresource or creates a new one. It receives write traffic fromvmauthand sends it to theVMClusterorVMSingleof every zone.remoteWriteoverrideszoneCommon.remoteWritefor writes to this zone’s backend, from every zone’svmagent.
VMDistributedZoneCluster
#
name: Optional name of an existingVMClusteror one to be created; when omitted it defaults tozoneCommon.vmcluster.name(where%ZONE%is used to template the zone name) or${cr.Name}-${zone.name}when unset.spec: Avmv1beta1.VMClusterSpecobject that defines the desired state of a new or referencedVMClustermanaged by this resource.
VMDistributedZoneSingle
#
name: Optional name of an existingVMSingleor one to be created; when omitted it defaults tozoneCommon.vmsingle.name(where%ZONE%is used to template the zone name) or${cr.Name}-${zone.name}when unset.spec: Avmv1beta1.VMSingleSpecobject that defines the desired state of a new or referencedVMSinglemanaged by this resource.
Example: Defining a VMDistributed resource with VMCluster backend:
apiVersion: operator.victoriametrics.com/v1alpha1
kind: VMDistributed
metadata:
name: my-distributed-cluster
spec:
vmauth:
name: my-distributed-vmauth
spec:
replicaCount: 1
unauthorizedUserAccessSpec:
targetRefs:
- name: read
- name: write
zoneCommon:
vmagent:
spec:
replicaCount: 1
vmcluster:
spec:
vmstorage:
replicaCount: 1
storage:
volumeClaimTemplate:
spec:
resources:
requests:
storage: 10Gi
vmselect:
replicaCount: 1
vminsert:
replicaCount: 1
zones:
- name: zone-a
- name: zone-b
vmcluster:
spec:
vmselect:
replicaCount: 2
Example: Defining a VMDistributed resource with VMSingle backend:
apiVersion: operator.victoriametrics.com/v1alpha1
kind: VMDistributed
metadata:
name: my-distributed-singles
spec:
backendType: VMSingle
vmauth:
name: my-distributed-vmauth
spec:
replicaCount: 1
unauthorizedUserAccessSpec:
targetRefs:
- name: read
- name: write
zoneCommon:
vmagent:
spec:
replicaCount: 1
vmsingle:
spec:
retentionPeriod: "30d"
zones:
- name: zone-a
- name: zone-b
vmsingle:
spec:
retentionPeriod: "14d"
Example: Defining a VMDistributed resource with Kubernetes nodeSelectors:
This example pins each zone’s vmagent and vmsingle to nodes with the matching
topology.kubernetes.io/zone
label.
Any node label works the same way, see Assign Pods to Nodes
.
For each zone, the operator replaces %ZONE% with that zone’s name.
In this example, zone-a and zone-b pods are scheduled only on nodes labeled topology.kubernetes.io/zone: zone-a and topology.kubernetes.io/zone: zone-b.
vmauth has no nodeSelector, so it can run on any node and keeps serving traffic if a zone goes down.
apiVersion: operator.victoriametrics.com/v1alpha1
kind: VMDistributed
metadata:
name: my-distributed-vmsingles
spec:
backendType: VMSingle
vmauth:
name: my-distributed-vmauth
spec:
replicaCount: 2
unauthorizedUserAccessSpec:
targetRefs:
- name: read
- name: write
zoneCommon:
vmagent:
spec:
replicaCount: 1
nodeSelector:
topology.kubernetes.io/zone: "%ZONE%"
vmsingle:
spec:
nodeSelector:
topology.kubernetes.io/zone: "%ZONE%"
retentionPeriod: "30d"
zones:
- name: zone-a
- name: zone-b
VMDistributed and distributed chart #
VMDistributed can be used alongside the resources created by the distributed chart. The distributed chart provides a convenient way to create multiple VMCluster objects and surrounding resources.
In order to update VMClusters in a coordinated manner, add VMCluster resources to the zones list:
spec:
vmauth:
spec:
replicaCount: 1
unauthorizedUserAccessSpec:
targetRefs:
- name: read
- name: write
zoneCommon:
vmagent:
name: vmagent-%ZONE%
spec:
replicaCount: 1
vmcluster:
name: vmcluster-%ZONE%
spec:
replicationFactor: 1
requestsLoadBalancer:
enabled: true
spec:
nodeSelector:
kubernetes.io/os: linux
replicaCount: 2
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
retentionPeriod: "14d"
vminsert:
nodeSelector:
kubernetes.io/os: linux
port: "8480"
replicaCount: 2
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
vmselect:
nodeSelector:
kubernetes.io/os: linux
port: "8481"
replicaCount: 2
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
vmstorage:
nodeSelector:
kubernetes.io/os: linux
replicaCount: 2
storageDataPath: /vm-data
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
zones:
- name: central
- name: east
- name: west
Note that VMDistributed will create a single VMAuth, which encapsulates rules for both read and write access to the zones, unlike the distributed chart which creates separate VMAuths for read and write paths. This provides a convenient way to migrate the traffic between VMDistributed and distributed helm chart implementations.
Ownership and references #
VMDistributed creates or becomes an owner of existing VMAuth, VMAgent, VMCluster and VMSingle resources and by default it removes all resources it owns on CR deletion. To remove VMDistributed but keep all owned resources set spec.retain: true before VMDistributed removal.
When a zone references an existing VMAgent, VMCluster or VMSingle by name, VMDistributed takes ownership of it and replaces its spec with the one built from zoneCommon and the zone. Fields that are set only on the existing object are lost.
Current shortcomings #
- Only one
VMAuthcan be managed perVMDistributed. - All objects must belong to the same namespace as the
VMDistributed. - Objects must be referred to by name; label selectors are not supported for
VMAuth,VMAgent,VMClusterorVMSingleselection. VMAgent,VMClusterandVMSinglenames must be unique across zones within oneVMDistributedresource.- All zones must use the same backend type (controlled by
spec.backendType); mixingVMClusterandVMSinglezones in oneVMDistributedis not supported.
Authorization #
By default, the VMAuth created by VMDistributed is not open: it rejects all read and write requests. This is on purpose. Opening it to everyone would let anyone who can reach it read and write data, and creating a default user would mean the operator picks a username, password and permissions for you. So you decide how clients get access.
The operator gives the VMAuth two named backends: read sends queries to the zones, and write sends data to the zones. To open access, list them in targetRefs in one of two ways:
- Anonymous access: no username or password. Simple, and fine for testing or a trusted network.
- Access with credentials: through
VMUserobjects. Each client needs a username and password, and can be given onlyreador onlywrite.
Anonymous access #
Reference both backends in spec.vmauth.spec.unauthorizedUserAccessSpec:
spec:
vmauth:
spec:
unauthorizedUserAccessSpec:
targetRefs:
- name: read
- name: write
Any client that can reach the VMAuth service can now read and write without credentials.
Access with credentials #
Leave unauthorizedUserAccessSpec unset and make the VMAuth select VMUser objects, either with selectAllByDefault: true or with
user selectors
:
spec:
vmauth:
spec:
selectAllByDefault: true
Then create a VMUser for each client and reference the backends it may use in targetRefs:
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMUser
metadata:
name: example
spec:
username: simple-user
password: simple-password
targetRefs:
- name: read
- name: write # omit for a read-only client