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

[charts/onechart] Specifying ports in values doesn't work as expected #92

Closed
davidfrickert opened this issue Nov 17, 2023 · 2 comments
Closed

Comments

@davidfrickert
Copy link
Contributor

davidfrickert commented Nov 17, 2023

Specifying ports in values doesn't work as expected.

E.g.:

ports:
  - name: 445
    svcPort: 445

The template tries to fill the name in both the actual name and in targetPort, which doesn't work, as port needs to be a number and name needs to be a string:

Error: INSTALLATION FAILED: Service in version "v1" cannot be handled as a Service: json: cannot unmarshal number into Go struct field ServicePort.spec.ports.name of type string

{{- else }}
{{- range .Values.ports }}
- name: {{ .name }}
port: {{ if .svcPort }}{{ .svcPort }}{{ else }}{{ .containerPort }}{{ end }}
{{- if .nodePort }}
nodePort: {{ .nodePort }}
{{- end }}
targetPort: {{ .name }}
protocol: TCP

Instead, maybe support passing targetPort?

ports:
  - name: tcp-445
    svcPort: 445
    targetPort: 445

Offtopic

Name could also be optional:

ports:
  - svcPort: 445
    targetPort: 445

The template could then fill the port name with a concatenation of tcp and the port.

@dzsak dzsak linked a pull request Feb 6, 2024 that will close this issue
@laszlocph
Copy link
Contributor

Hello @davidfrickert

.Values.ports is an undocumented feature, and honestly we forgot why it is in Onechart in the first place.

But the following values file produces valid yaml, and seemingly we support multiple ports.

ports:
  - name: blabla
    containerPort: 445
  - name: blabla2
    containerPort: 446

containerPort: 446

You are right about the fact that the template tries to fill the name in both the actual name and in targetPort. TargetPort can be a string and OneChart produces internally consistent yaml.

So the question is, is there something we don't support? Why did you want to provide a port number as name and not a string?

@davidfrickert
Copy link
Contributor Author

Ah I see, I wasn't aware targetPort could be a string.
I guess I was just looking for a way to do something similar to docker compose, defining external and internal port, without having to use a name for the port.

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 a pull request may close this issue.

2 participants