joeferner / redis-commander

Redis management tool written in node.js
http://joeferner.github.io/redis-commander/
MIT License
3.56k stars 460 forks source link

[helm chart][k8s] Connections from `connections.local_production_json` are ignored #565

Open JuroOravec opened 4 months ago

JuroOravec commented 4 months ago

Problem:

I'm not able to configure Redis connection through helm chart via connections.local_production_json. I wanted to use connections.local_production_json so I can configure multiple connections with passwords.

Context:

  1. I used the helm chart v0.6.0 to deploy Redis Commander.

  2. I set the values.yaml file based on the example like so:

    Click to toggle values.yaml ```yaml replicaCount: 1 serviceAccount: create: true connections: local_production_json: noSave: false noLogData: false # ui: # foldingChar: "|" redis: readOnly: true # server: # clientMaxBodySize: "500kb" # httpAuth: # username: "the-user" # password: "is-secret" connections: - label: "redis" host: "redis-master.redis.svc.cluster.local" port: "6379" password: 'MY_PASSWORD' dbIndex: 0 ```
  3. I confirmed that the configmap resource was successfully created

  4. I confirmed that the configmap was successfully mounted

    Screenshot 2024-03-25 at 10 31 08
  5. At this point, the UI was showing only connection local (localhost:6739:0). This is NOT the connection I defined in local_production_json.

    Screenshot 2024-03-25 at 10 39 09
  6. I verified that the connection in my values.yaml file was correct by manually adding it:

    Screenshot 2024-03-25 at 10 40 24
  7. After I manually added the connection, it was added to the local-production.json

    Screenshot 2024-03-25 at 10 48 10

    And here's example what the logs look like at the point where I manually added the connection. All the connection errors are coming from trying to conenect to localhost:6739:0, which I did NOT configure:

    Screenshot 2024-03-25 at 10 48 56
JuroOravec commented 4 months ago

Ok, I found that the config file is loaded depending on the NODE_ENV env var, and that currently NODE_ENV env var is NOT used for anything else in this project. So I was able to fix this by explicitly setting NODE_ENV=production-docker, so that the config file generated by helm chart is used.

So my updated values.yaml file looks like so:

replicaCount: 1

serviceAccount:
  create: true

# THIS WAS ADDED!
env:
  - name: NODE_ENV
    value: "production-docker"

connections:
  local_production_json:
    noSave: false
    noLogData: false
    # ui:
    #   foldingChar: "|"
    redis:
      readOnly: true
    # server:
    #   clientMaxBodySize: "500kb"
    #   httpAuth:
    #     username: "the-user"
    #     password: "is-secret"
    connections:
      - label: "redis"
        host: "redis-master.redis.svc.cluster.local"
        port: "6379"
        password: 'MY_PASSWORD'
        dbIndex: 0

So, now that there's a solution, how can we fix this?

Could we at minimum add this information to the Helm chart README?

Or better yet, update the chart to configure the NODE_ENV env var automatically?

Let me know your thoughts and I can make the changes if it's simple changes.