spotahome / redis-operator

Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Apache License 2.0
1.5k stars 356 forks source link

Make sentinelExporterPort configurable #531

Closed dnugmanov closed 1 year ago

dnugmanov commented 1 year ago

Expected behaviour

I can through CRD change sentinelExporterPort (by default 9355) and operator will correct render env spec

Actual behaviour

If i use env LISTEN_ADDRESS in exporter container, operator incorrect add REDIS_EXPORTER_WEB_LISTEN_ADDRESS env, which is not respected in exporter configuration.

        - env:
            - name: LISTEN_ADDRESS
              value: ':9121'
            - name: REDIS_ALIAS
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: REDIS_EXPORTER_WEB_LISTEN_ADDRESS
              value: '0.0.0.0:9355'
            - name: REDIS_ADDR
              value: 'redis://localhost:26379'
...
     ports:
        - containerPort: 9355
          name: metrics
          protocol: TCP

Steps to reproduce the behaviour

apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
  name: test-redis
  namespace: redis-operator
spec:
  auth:
    secretPath: redis-auth
  sentinel:
    image:redis:7.0.5-alpine 
    replicas: 3
    exporter:
      enabled: true
      image: leominov/redis_sentinel_exporter:1.7.0
      env:
        - name: LISTEN_ADDRESS
          value: ":9121"

Environment

How are the pieces configured?

samof76 commented 1 year ago

Trying to understand...

You want non-default port to be exposed for metrics scraping? And need a provision for specifying that in the CRD?

dnugmanov commented 1 year ago

Correct, i suggest change this constant - https://github.com/spotahome/redis-operator/blob/40d155f3f6dd11f69c11b945497a9b9759f90f29/operator/redisfailover/service/constants.go#L6 and according fix hardcoding in this function https://github.com/spotahome/redis-operator/blob/716d0d60dd561ea1041e5ab9a71cf8e0b8952159/operator/redisfailover/service/generator.go#L617

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 45 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.