Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set environment variables from secretRef/configMap #17

Merged
merged 4 commits into from
Jun 27, 2024

Conversation

chrbrnracn
Copy link
Contributor

Current situation:

  • existing secrets or configMaps can be added via .Values.existingSecret or .Values.existingConfigMap
  • only one of each is possible at a time
  • it is not possible to set a custom environment variable where the value is set

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.

@chrbrnracn chrbrnracn requested a review from a team as a code owner June 3, 2024 16:27
@Haarolean Haarolean requested a review from azatsafin June 3, 2024 23:17
Copy link
Member

@azatsafin azatsafin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your effort

@Haarolean Haarolean merged commit c61305f into kafbat:main Jun 27, 2024
1 check passed
@Haarolean
Copy link
Member

@chrbrnracn thanks for your contribution!

@fallen-up
Copy link

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

@chrbrnracn
Copy link
Contributor Author

@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
Copy link

fallen-up commented Sep 26, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants