apiVersion: apps/v1
kind: Deployment
metadata:
  name: victoriametrics
spec:
  replicas: 1
  strategy: { type: Recreate }
  selector:
    matchLabels:
      app: victoriametrics
  template:
    metadata:
      labels:
        app: victoriametrics
      annotations: 
        prometheus.io/scrape: "true"
        prometheus.io/path: "/m/metrics"
        prometheus.io/port: "80"
    spec:
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: opt-victoriametrics
        - name: config
          configMap: {name: victoriametrics-config}
      serviceAccountName: victoriametrics
      containers:
        - name: victoriametrics
          # https://hub.docker.com/r/victoriametrics/victoria-metrics/tags also check vmalert.yaml
          image: docker.io/victoriametrics/victoria-metrics:v1.91.2
          args:
            - -http.pathPrefix=/m/
            - -loggerTimezone=America/Los_Angeles
            - -memory.allowedBytes=512MB
            - -promscrape.config=/local/config/scrape_main
            - -promscrape.configCheckInterval=5s
            - -retentionPeriod=10y
            - -sortLabels
            - -storageDataPath=/data
          ports:
            - containerPort: 8428
          volumeMounts:
            - { name: data, mountPath: /data }
            - { name: config, mountPath: "/local/config" }
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: "kubernetes.io/hostname"
                    operator: In
                    values: ["ditto"]
---
apiVersion: v1
kind: Service
metadata:
  name: victoriametrics
spec:
  ports:
    - port: 80
      targetPort: 8428
  selector:
    app: victoriametrics
