apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: vmcluster-storage
provisioner: ebs.csi.aws.com
parameters:
  fsType: ext4
  type: gp3
  iops: "3000"
  throughput: "125"
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
---
apiVersion: v1
kind: ServiceAccount
metadata:
  annotations:
    eks.amazonaws.com/role-arn: TMPL_VMCLUSTER_ROLE
  name: vmcluster-vmcluster
  namespace: observability
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMCluster
metadata:
  name: vmcluster
  namespace: observability
spec:
  replicationFactor: 2
  retentionPeriod: "1"
  vminsert:
    extraArgs:
      maxLabelsPerTimeseries: "100"
      maxConcurrentInserts: "8"
    affinity:
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                  - key: app.kubernetes.io/name
                    operator: In
                    values:
                      - vminsert
              topologyKey: kubernetes.io/hostname
            weight: 100
    image:
      repository: TMPL_IMAGE_REGISTRY/victoriametrics/vminsert
      tag: v1.122.2-cluster-hotfix-20260305
    podMetadata:
      labels:
        owner: infra
    replicaCount: 2
    resources:
      limits:
        cpu: 625m
        memory: 640Mi
      requests:
        cpu: 500m
        memory: 512Mi
    nodeSelector:
      node_type: worker
    hpa:
      minReplicas: 2
      maxReplicas: 4
      metrics:
      - type: Resource
        resource:
          name: cpu
          target:
            type: Utilization
            averageUtilization: 80
      - type: Resource
        resource:
          name: memory
          target:
            type: Utilization
            averageUtilization: 90
      behaviour:
        scaleUp:
          # we already have an oversale limit to accommodate temporary spikes, so we define a window here.
          stabilizationWindowSeconds: 60
        scaleDown:
          stabilizationWindowSeconds: 600
          # scale down at the rate of 1 pod per 5 minutes.
          policies:
          - type: Pods
            value: 1
            periodSeconds: 300
  vmselect:
    persistentVolumeClaimRetentionPolicy:
      whenDeleted: Delete
      whenScaled: Delete
    affinity:
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                  - key: app.kubernetes.io/name
                    operator: In
                    values:
                      - vmselect
              topologyKey: kubernetes.io/hostname
            weight: 100
    cacheMountPath: /select-cache
    extraArgs:
      search.maxConcurrentRequests: "10"
    image:
      repository: TMPL_IMAGE_REGISTRY/victoriametrics/vmselect
      tag: v1.122.2-cluster-hotfix-20260305
    podMetadata:
      labels:
        owner: infra
    replicaCount: 2
    resources:
      limits:
        cpu: 750m
        memory: 1.5Gi
      requests:
        cpu: 500m
        memory: 1Gi
    storage:
      volumeClaimTemplate:
        metadata: {}
        spec:
          resources:
            requests:
              storage: 10Gi
        status: {}
    hpa:
      minReplicas: 2
      maxReplicas: 4
      metrics:
      - type: Resource
        resource:
          name: cpu
          target:
            type: Utilization
            averageUtilization: 90
      - type: Resource
        resource:
          name: memory
          target:
            type: Utilization
            averageUtilization: 90
      behaviour:
        scaleUp:
          # we already have an oversale limit to accommodate temporary spikes, so we define a window here.
          stabilizationWindowSeconds: 60
        scaleDown:
          stabilizationWindowSeconds: 600
          # scale down at the rate of 1 pod per 5 minutes.
          policies:
          - type: Pods
            value: 1
            periodSeconds: 300
    nodeSelector:
      node_type: worker
  vmstorage:
    topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: kubernetes.io/hostname
      whenUnsatisfiable: ScheduleAnyway
      labelSelector:
        matchLabels:
          app.kubernetes.io/name: vmstorage
    affinity:
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                  - key: app.kubernetes.io/name
                    operator: In
                    values:
                      - vmstorage
              topologyKey: kubernetes.io/hostname
            weight: 50
    image:
      repository: TMPL_IMAGE_REGISTRY/victoriametrics/vmstorage
      tag: v1.122.2-cluster-hotfix-20260305
    podMetadata:
      labels:
        owner: infra
    replicaCount: 3
    resources:
      limits:
        cpu: 500m
        memory: 4Gi
      requests:
        cpu: 200m
        memory: 1Gi
    storage:
      volumeClaimTemplate:
        metadata: {}
        spec:
          storageClassName: vmcluster-storage
          resources:
            requests:
              storage: 50Gi
        status: {}
    storageDataPath: /vm-data
    nodeSelector:
      node_type: worker
    containers:
      - name: vmbackuper
        imagePullPolicy: Always
        serviceAccount: vmcluster-vmcluster
        serviceAccountName: vmcluster-vmcluster
        volumeMounts:
          - mountPath: /vm-data
            name: vmstorage-db
        resources:
          requests:
            cpu: "0.05"
            memory: 20Mi
          limits:
            cpu: "0.5"
            memory: 512Mi
        image: TMPL_IMAGE_REGISTRY/observability/vmbackupmanager:f82e69ce98fb871f5996a1f9ea92e4480943b68c
        args:
          - -vendor=TMPL_VENDOR
          - -region=TMPL_REGION
          - -storageDataPath=/vm-data
          - -snapshot.createURL=http://localhost:8482/snapshot/create
          - -dst=s3://TMPL_VMCLUSTER_BUCKET_NAME/TMPL_VMCLUSTER_BUCKET_NAME/1/vmcluster/$(MY_POD_NAME)
          - -vmRetentionPeriod=3
          - -backupRetention=1y
          - -maxBytesPerSecond=262144000
        env:
          - name: MY_POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name

---

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAlert
metadata:
  name: vmalert-shared
  namespace: observability
spec:
  containers:
    - name: config-reloader
      resources:
        limits:
          cpu: 10m
          memory: 32Mi
        requests:
          cpu: 10m
          memory: 32Mi
  datasource:
    url: http://vmselect-vmcluster.observability.svc.cluster.local:8481/select/multitenant/prometheus
  image:
    repository: TMPL_IMAGE_REGISTRY/victoriametrics/vmalert
    tag: v1.122.2-cluster-hotfix-20260305
  livenessProbe:
    initialDelaySeconds: 30
  notifiers:
    - url: http://alertmanager-alert-regional-0.alertmanager-operated.default.svc.cluster.local:9093
    - url: http://alertmanager-alert-regional-1.alertmanager-operated.default.svc.cluster.local:9093
  readinessProbe:
    initialDelaySeconds: 30
  remoteRead:
    url: http://vmselect-vmcluster.observability.svc.cluster.local:8481/select/multitenant/prometheus
  remoteWrite:
    url: http://vminsert-vmcluster.observability.svc.cluster.local:8480/insert/multitenant/prometheus
    maxBatchSize: 5000
  resources:
    limits:
      cpu: 300m
      memory: 300Mi
    requests:
      cpu: 10m
      memory: 50Mi
  nodeSelector:
    node_type: worker
  ruleNamespaceSelector:
    matchLabels:
      observability.pingcap.com/rule-multi-tenancy: "true"
  ruleSelector:
    matchExpressions:
    - key: observability.pingcap.com/rule-multi-tenancy
      operator: In
      values:
      - "true"
    - key: observability.pingcap.com/cluster-paused
      operator: NotIn
      values:
      - "true"
    - key: observability.pingcap.com/applicationID
      operator: NotIn
      values:
      - base
      - seed
