VictoriaMetrics / operator

Kubernetes operator for Victoria Metrics
Apache License 2.0
410 stars 141 forks source link

support set vmselect service type when it's backed by statefulset #922

Closed chenlujjj closed 3 months ago

chenlujjj commented 3 months ago

Currently we can only set vmselect service type when it is deployment, but not for statefulset

Haleygo commented 3 months ago

Hello! It should be a vm operator question and yes, we use headless service by default when workload is statefulset, since it provides stable network ID to use. It can be changed by using AdditionalServiceSpec with UseAsDefault enabled after operator v0.43.0(not released yet), see this commit for details.

f41gh7 commented 3 months ago

Must be fixed at v0.43.0 release.

Operator allows to modify exist service with serviceSpec if useAsDefault option is set to true

---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMCluster
metadata:
  name: example-service-change
spec:
  retentionPeriod: "4"
  replicationFactor: 2
  vmstorage:
    replicaCount: 2
    containers:
    - name: my-side-car
      ports:
      - name: extra-port
        containerPort: 8055
    serviceSpec:
      # expose additional port with default service
      userAsDefault: true
      spec:
         ports:
         - name: extra-port
           port: 8055
    storageDataPath: "/vm-data"
    storage:
      volumeClaimTemplate:
        spec:
          resources:
            requests:
              storage: 10Gi
  vmselect:
    replicaCount: 2
    cacheMountPath: "/select-cache"
  vminsert:
    replicaCount: 2
    serviceSpec:
      metadata:
        annotations:
          my-cloud-provide-annotation: value
      userAsDefault: true
      spec:
       type: LoadBalancer