VictoriaMetrics / operator

Kubernetes operator for Victoria Metrics
Apache License 2.0
426 stars 142 forks source link

PVC autoscaling. #867

Closed 0megam closed 6 months ago

0megam commented 8 months ago

Is it feasible to concurrently utilize operators such as https://github.com/DevOps-Nirvana/Kubernetes-Volume-Autoscaler alongside the VM operator? My understanding is that the Kubernetes volume autoscaler will adjust PVC resources to scale up PV, but I presume the VM operator may revert these changes.

f41gh7 commented 8 months ago

Hello,

I think, it's possible to use PVC autoscaling with operator. Operator checks the actual size of pvc and compares it with claimTemplate defined at statefulset. It it's bigger, operator logs and error and do nothing with this pvc. It's a case for vmstorage, vmselect, vmagent and vmalertmanager.

For vmsingle, it's possible to use external pvc and operator will ignore it's size.

I think, we could add special annotation for claim template, that we'll delegate PVC resize to the external controller such as volume-auto-scaler.

cc @Haleygo

f41gh7 commented 6 months ago

Since v0.42.0 release, it's possible to add special annotation operator.victoriametrics.com/pvc-allow-volume-expansion: "false". It prevents operator from scaling persistent volumes and delegates control over it to external tool.

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMCluster
metadata:
  name: example-vmcluster-persistent
spec:
  retentionPeriod: "4"
  replicationFactor: 2
  vmstorage:
    replicaCount: 2
    storageDataPath: "/vm-data"
    storage:
      volumeClaimTemplate:
        metadata:
         annotations:
          operator.victoriametrics.com/pvc-allow-volume-expansion: "false"
        spec:
          storageClassName: sc-immutable
          resources:
            requests:
              storage: 10Gi
  vmselect:
    replicaCount: 2
    cacheMountPath: "/select-cache"
    storage:
      volumeClaimTemplate:
        metadata:
         annotations:
          operator.victoriametrics.com/pvc-allow-volume-expansion: "false"
        spec:
          storageClassName: sc-mutable
          resources:
            requests:
              storage: 2Gi
  vminsert:
    replicaCount: 2