kafbat / helm-charts

Helm charts for kafbat projects
https://ui.charts.kafbat.io/
Apache License 2.0
6 stars 13 forks source link

Set environment variables from secretRef/configMap #17

Closed chrbrnracn closed 5 months ago

chrbrnracn commented 6 months ago

Current situation:

With the change it is possible to set a named environment variable to a specific key in a specific secret or config map.

Use case:
When running Kafka with Strimzi, each KafkaUser entity gets its own secret with the password and sasl.jaas.config. With the new feature it's possible to directly access this secret and use it for Kafka UI.

  secretMappings:
    KAFKA_CLUSTERS_0_PROPERTIES_SASL_JAAS_CONFIG:
      secretName: mySuperUser
      secretKey: sasl.jaas.config

There may be a lot more use cases for this feature. That's why I added the same for configMapKeyRef.

Side note:
I had to set all other kafka.clusters.* values as envs.config instead of using yamlApplicationConfig, but not auth.* or management.*. It looks like the application does not deep-merge values from config file and YAML configuration. I didn't find this in the docs.

Haarolean commented 5 months ago

@chrbrnracn thanks for your contribution!

fallen-up commented 2 months ago

@chrbrnracn did you check it? i receive error mapping values are not allowed in this context

chrbrnracn commented 2 months ago

@chrbrnracn did you check it? i receive error mapping values are not allowed in this context

Did I check what? It's working fine for me. In case you have problems, please create an issue and reference the PR. Please paste your configuration that led to the error and describe your steps to reproduce? When I get such errors it's mostly because I put in a list where it should be a dict or so.

fallen-up commented 2 months ago

values.yaml:

envs:
  config:
    KAFKA_CLUSTERS_0_NAME: "example1"
    KAFKA_CLUSTERS_0_READONLY: "false"
    KAFKA_CLUSTERS_0_SSL_VERIFYSSL: "false"
    KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "example:9092"
  configMappings:
    ENV1:
      name: configmap-name
      keyName: configmap-key
helm install kafbat-ui kafbat-ui/kafka-ui -f values.yaml --namespace xxx --dry-run --version 1.4.2
Error: INSTALLATION FAILED: YAML parse error on kafka-ui/templates/deployment.yaml: error converting YAML to JSON: yaml: line 72: mapping values are not allowed in this context
helm install kafbat-ui kafbat-ui/kafka-ui -f values.yaml --namespace xxx --dry-run --version 1.4.5
Error: INSTALLATION FAILED: YAML parse error on kafka-ui/templates/deployment.yaml: error converting YAML to JSON: yaml: line 73: mapping values are not allowed in this context

@chrbrnracn do you see the problem at first glance?