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

Issue with configMappings #25

Open
chrbrnracn opened this issue Sep 26, 2024 · 8 comments
Open

Issue with configMappings #25

chrbrnracn opened this issue Sep 26, 2024 · 8 comments

Comments

@chrbrnracn
Copy link
Contributor

chrbrnracn commented Sep 26, 2024

Let me open that issue for you. this is a more suitable place to discuss issues.
The issue refers to PR #17, which introduces configMappings and secretMappings.

Original quote from PR-discussion

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?

Originally posted by @fallen-up in #17 (comment)

@chrbrnracn
Copy link
Contributor Author

@fallen-up:

  • Does the config map exist (in the same namespace)? Does the key in the config map exist? Please post the structure of the config map.
  • What is the result of helm template --debug? Find the configMapKeyRef section in the deployment and paste what you got there.

@chrbrnracn
Copy link
Contributor Author

I tested your snippet in one of my configurations and cannot reproduce the issue. We need the output of helm template --debug to check what the issue could be.
Unfortunately helm isn't very reliable when it comes to error messages and line numbers as it refers to the output, not the template. It could be somewhere above or below line 73 in the template.

@fallen-up
Copy link

fallen-up commented Sep 26, 2024

  1. problem actual and for secretMapping
  2. of course configmap exist in the same namespace. key exist too
apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-name
  namespace: xxx
data:
  configmap-key: test
helm template kafka-ui kafbat-ui/kafka-ui --namespace xxx --debug --version 1.4.5  -f values.yaml

install.go:200: [debug] Original chart version: "1.4.5"
install.go:217: [debug] CHART PATH: /home/xxx/.cache/helm/repository/kafka-ui-1.4.5.tgz
Error: 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
helm.go:84: [debug] error converting YAML to JSON: yaml: line 73: mapping values are not allowed in this context
YAML parse error on kafka-ui/templates/deployment.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
        helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:146
helm.sh/helm/v3/pkg/releaseutil.SortManifests
        helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:106
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
        helm.sh/helm/v3/pkg/action/action.go:170
helm.sh/helm/v3/pkg/action.(*Install).RunWithContext
        helm.sh/helm/v3/pkg/action/install.go:289
main.runInstall
        helm.sh/helm/v3/cmd/helm/install.go:287
main.newTemplateCmd.func2
        helm.sh/helm/v3/cmd/helm/template.go:88
github.com/spf13/cobra.(*Command).execute
        github.com/spf13/[email protected]/command.go:916
github.com/spf13/cobra.(*Command).ExecuteC
        github.com/spf13/[email protected]/command.go:1044
github.com/spf13/cobra.(*Command).Execute
        github.com/spf13/[email protected]/command.go:968
main.main
        helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
        runtime/proc.go:250
runtime.goexit
        runtime/asm_amd64.s:1598
***
      containers:
        - name: kafka-ui
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 2001
          image: custom-image:yyy
          imagePullPolicy: Always
            - name: ENV1
              valueFrom:
                configMapKeyRef:
                  name: configmap-name
                  key: configmap-key
          envFrom:
            - configMapRef:
                name: kafka-ui
***

looks like this section doesn't work:

          {{- if or .Values.env  .Values.yamlApplicationConfig .Values.yamlApplicationConfigConfigMap .Values.yamlApplicationConfigSecret }}
          env:

i think you have one of them in your config

@fallen-up
Copy link

if add "env" to values:

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
env:
  - name: GAP_ENV
    value: gap-value

it works. result:

          env:
            - name: GAP_ENV
              value: gap-value
            - name: ENV1
              valueFrom:
                configMapKeyRef:
                  name: configmap-name
                  key: configmap-key
          envFrom:
            - configMapRef:
                name: kafka-ui

@fallen-up
Copy link

fallen-up commented Sep 26, 2024

so it makes more sense to do that in the example:

envs:
  secret: {}
  config: {}

env:
  secretMappings: {}
    #ENV_NAME:
    #  name: kubernetes-secret-name
    #  keyName: kubernetes-secret-key
  configMappings: {}
    #ENV_NAME:
    #  name: kubernetes-configmap-name
    #  keyName: kubernetes-configmap-key

and change deployment.yaml

@chrbrnracn
Copy link
Contributor Author

Possibly. I placed it in the envs block because of the similar configuration options for config. But moving the configuration would be a breaking change for everyone who uses this.
Would be better to extend the condition in line 54 and moving the {{- end }} from L69 to L83. This fix is easy and will not break any existing configuration.

@fallen-up
Copy link

@chrbrnracn thanks so much for the "ping pong". You've really helped.

@chrbrnracn
Copy link
Contributor Author

Should be fixed with #26

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

No branches or pull requests

2 participants