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

k8s:helm should use values.yaml file #327

Closed
survivant opened this issue Jul 29, 2020 · 2 comments · Fixed by #410
Closed

k8s:helm should use values.yaml file #327

survivant opened this issue Jul 29, 2020 · 2 comments · Fixed by #410
Labels
bug Something isn't working
Milestone

Comments

@survivant
Copy link
Contributor

k8s:helm

generate Helm artifacts.. but the content of deleployment.yaml and others doesn't use values.yaml

you should use standars values like this


# Kubernetes & Docker
replicaCount: 1
nameOverride: ""
fullnameOverride: ""
image: xyz
imagePullPolicy: Always
imagePullSecrets: []

deployment.yaml

spec:
  replicas: {{ .Values.replicaCount }}

...

@manusa
Copy link
Member

manusa commented Jul 30, 2020

Hi
spring-boot-helm example actually shows how you can use this for any string compatible value.
The problem with not being able to use these template values on non-string fields is related to several active issues on Kubernetes-Client:

The model classes are typed, so when generating the class instance and setting the values as placeholders for variables, this will only work for string fields that can be set with a {{ }}.

We'll need to figure out a way to overcome this, probably by converting the class instance to an intermediate Map, setting the problematic fields on the Map, and then serializing it.

@manusa manusa added this to the 1.1.0 milestone Jul 30, 2020
@manusa manusa added the bug Something isn't working label Aug 3, 2020
@manusa
Copy link
Member

manusa commented Sep 10, 2020

Besides the problems with replacing integer values, Helm mojo is not behaving correctly.

k8s:resource goal should replace all parameters with the provided Template parameter default values.

k8s:helm goal should keep those parameter placeholders and add the values to the values.yml file.

Template parameters (k8s:resource & k8s:helm)

As of now, ReourceMojo#findTemplate locates the first resource of type Template.

This means that if there are several (1-first-template.yml, template.yml, etc.) only the first will be considered to gather parameters.

The List of parameters should be gathered as:

(List<Parameter>)(Template) resources.getItems().stream()
          .filter(template -> template instanceof Template)
          .map(Template.class::cast)  
          .map(Template::getParameters)
          .collect(Collectors.toList())  

Only for k8s:resource, the place-holders in the original resources should be replaced.

Helm Mojo

Helm should be decoupled from resource goal.

Helm should run a resource generation but without replacing parameter placeholders.
This means that this line should be skipped only for helm chart generation:
https://github.com/eclipse/jkube/blob/9ce411df9aeff2be9e072f266fe879defee1c1d7/kubernetes-maven-plugin/plugin/src/main/java/org/eclipse/jkube/maven/plugin/mojo/build/ResourceMojo.java#L577-L578

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants