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

As an user, I want to provide a values.yaml when the Helm Chart is generated #2111

Open
jmesnil opened this issue Mar 29, 2023 · 5 comments
Open
Labels
component/helm ⎈ enhancement New feature or request

Comments

@jmesnil
Copy link

jmesnil commented Mar 29, 2023

Component

Kubernetes Maven Plugin

Is your enhancement related to a problem? Please describe

When I use JKube to generate the values.yaml for the Helm Chart, the only way (afaik) to specify these values are using <parameter> in the plug-in configuration.

However this mechanism has bugs and limitations. In my case, I want to pass boolean and integers (which is not working) as well as arrays (with a convoluted syntax).

Describe the solution you'd like

Instead, I would like to add the values.yaml file directly in my project and use it instead of the <parameters>.

For example, I would like to add a src/helm/values.yaml file with the content:

wildfly:
  image:
    name: ghcr.io/wildfly-up-and-running/wuar-demo
  build:
    enabled: false
  deploy:
    replicas: 3
    route:
      enabled: false
    env:
      - name: DEMO_DEFAULT_TEXT
        value: Hello from Kubernetes!

and tell JKube to use it with something like

<configuration>
  <helm>
    <dependencies>
      <dependency>
        <name>wildfly</name>
        <version>1.3.0</version>
        <repository>https://docs.wildfly.org/wildfly-charts/wildfly</repository>
      </dependency>
    </dependencies>
    <valuesFile>src/helm/values.yaml</valuesFile>
  </helm>
</configuration>

This <valuesFile> would be an alternative to the <parameters> configuration.

Describe alternatives you've considered

No response

Additional context

No response

@jmesnil jmesnil added the enhancement New feature or request label Mar 29, 2023
@manusa
Copy link
Member

manusa commented Mar 29, 2023

This can be done in a similar way, see the following demo project git-snapshot: https://github.com/marcnuri-demo/jkube-helm/tree/4dbcae55b51608a1aef5fd7ae6d0ba8ce8c580cb

Although not exactly what you require, a Template can be provided to set some parameters: https://github.com/marcnuri-demo/jkube-helm/blob/4dbcae55b51608a1aef5fd7ae6d0ba8ce8c580cb/src/main/jkube/helm-variables-template.yml

I'm unsure that this will actually satisfy the In my case, I want to pass boolean and integers (which is not working) as well as arrays (with a convoluted syntax). requirement though. In any case, boolean values or at the very least integers should be working already (even complex GoLang expressions), see the same demo project but at the current state.

The other problem that we face is that we need to try to comply with the inner-loop k8s:resource generation goal too. Which is why the parameter declaration is some how complex and cumbersome. It would be good to have an example of the source fragments (including the values.yaml, and whatever resources/templates you need), and the expected output chart.

@jmesnil
Copy link
Author

jmesnil commented Mar 29, 2023

@manusa Thanks. I tried to use your demo to find a workaround by I've not been able to achieve it.

This is the output of the values.yaml I want to achieve:

build:
  uri: https://github.com/wildfly-up-and-running/wuar-demo
deploy:
  env:
  - name: DEMO_CUSTOM_TEXT
    value: Hello

The part that I'm not able to produce is the deploy.env field which is an array of name/value

For reference, I can achieve it with the helm CLI with the syntax:

$ helm install my-app --set build.uri=https://github.com/wildfly-up-and-running/wuar-demo --repo https://docs.wildfly.org/wildfly-charts/ --set "deploy.env[0].name=DEMO_CUSTOM_TEXT" --set "deploy.env[0].value=Hello" wildfly

(if you want to try it, you have to run it on OpenShift, not on a vanilla k8s)

The generated values.yaml file is the one I expect:

$ helm get values my-app
USER-SUPPLIED VALUES:
build:
  uri: https://github.com/wildfly-up-and-running/wuar-demo
deploy:
  env:
  - name: DEMO_CUSTOM_TEXT
    value: Hello

I tried to use that syntax with your demo:

              <parameter>
                <name>deploy.env[0].name</name>
                <value>DEMO_CUSTOM_TEXT!</value>
              </parameter>
              <parameter>
                <name>deploy.env[0].value</name>
                <value>Hello</value>
              </parameter>

but the output is not correct:

deploy:
  env[0]:
    name: DEMO_CUSTOM_TEXT!
    value: Hello

Is there a syntax to be able to configure arrays in the generated values.yaml?

@manusa
Copy link
Member

manusa commented Mar 29, 2023

OK, I'm more or less grasping your problem now. Support for arrays and maps is not yet here.

So the first thing to note is that parameters is not the same as values. I think it might be better if we have a sync call so I can better explain how the helm generation works. Then we can maybe discuss what would the best approach be to tackle your current problem and maybe improve JKube's Helm support. (pinging you internally)

@jmesnil
Copy link
Author

jmesnil commented Mar 29, 2023

@manusa To be fair, even if there was such a syntax, I still think there is value to let user provide their own values.yaml file instead of having to make it up from the pom.xml

I see that similar to the k8s:build where you can either generate a Docker file from the plugin configuration or directly specify a Dockerfile

@manusa
Copy link
Member

manusa commented Mar 29, 2023

To be fair, even if there was such a syntax, I still think there is value to let user provide their own values.yaml file instead of having to make it up from the pom.xml

Yes, yes.

So there are plenty of possible enhancements that can be extracted from this issue. I just want to showcase how the project works so we can devise the best solution(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/helm ⎈ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants