Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[logstash] Invalid ports in headless service #765

Closed
andriilahuta opened this issue Aug 3, 2020 · 12 comments · Fixed by #776
Closed

[logstash] Invalid ports in headless service #765

andriilahuta opened this issue Aug 3, 2020 · 12 comments · Fixed by #776
Labels
bug Something isn't working logstash

Comments

@andriilahuta
Copy link

Chart version: 7.8.1

Kubernetes version: 1.18

Helm Version: 3.3.0-rc.2

Logstash headless service uses container ports from .Values.extraPorts which are incompatible with the service spec.

@ebuildy
Copy link
Contributor

ebuildy commented Aug 4, 2020

@andriilahuta
Copy link
Author

I meant this part:

{{- if .Values.extraPorts }}
{{- toYaml .Values.extraPorts | nindent 2 }}
{{- end }}

# Custom ports to add to logstash
extraPorts: []
# - name: beats
# containerPort: 5001

@ebuildy
Copy link
Contributor

ebuildy commented Aug 4, 2020

What is the problem exactly? service supports multi-ports.

@andriilahuta
Copy link
Author

.Values.extraPorts is a container port spec used in statefulset:

ports:
- name: http
containerPort: {{ .Values.httpPort }}
{{- if .Values.extraPorts }}
{{- toYaml .Values.extraPorts | nindent 8 }}
{{- end }}

Service has a different spec for ports, so chart installation fails when .Values.extraPorts is specified due to invalid service spec.

@kopwei
Copy link

kopwei commented Aug 4, 2020

Yes, i got the same issue. "extraPorts" defined in values.yaml are used on both service-headless and statefulset directly but they require different definition. E.g. containerPort cannot exist in Service definition and containerPort is mandatory in Statefulset definition. This issue is introduced by #695

@disaster37
Copy link

+1

@autarchprinceps
Copy link

autarchprinceps commented Aug 7, 2020

The non-headless service uses .Values.service.ports, which is what the headless service also needs to use.

@itssimon
Copy link
Contributor

itssimon commented Aug 12, 2020

This issue prevents the Logstash Helm chart from being used when extra ports need to be opened (e.g. for a Beats input). I don't think there is a workaround either.

I just submitted a PR (#776) to address it as suggested by @autarchprinceps. Can this please be reviewed, merged and released ASAP so that the chart becomes usable again?

@acartapanis
Copy link

acartapanis commented Aug 19, 2020

+1

To be more explicit :
With

extraPorts:
  - name: beats
    containerPort: 5044

I have an error : error validating data: [ValidationError(Service.spec.ports[1]): unknown field "containerPort" in io.k8s.api.core.v1.ServicePort, ValidationError(Service.spec.ports[1]): missing required field "port" in io.k8s.api.core.v1.ServicePort]

extraPorts:
  - name: beats
    port: 5044

I have an error : error validating data: [ValidationError(StatefulSet.spec.template.spec.containers[0].ports[1]): unknown field "port" in io.k8s.api.core.v1.ContainerPort, ValidationError(StatefulSet.spec.template.spec.containers[0].ports[1]): missing required field "containerPort" in io.k8s.api.core.v1.ContainerPort]

As @kopwei said, ServicePort and ContainerPort definition are not the same (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#serviceport-v1-core and https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#containerport-v1-core), so you cannot use the same value for both.

Note that the error is only located on the headless-service.yaml, the service.yaml is working well.

As headless-service cannot be skipped in the chart, there is no workaround.

@adri
Copy link

adri commented Aug 24, 2020

I'm having the same problem :/

The extraPorts is used in a service definition and on a pod container definition. That doesn't work because these are two different APIs.

  1. service port https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#serviceport-v1-core
  2. container port https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#containerport-v1-core

@paprickar
Copy link

Same for me:
Chart version: 7.9.0
Kubernetes version: 1.18
Helm Version: 3.2.0

@adri
Copy link

adri commented Aug 25, 2020

It works when downgrading 2 versions. I'm using 6.8.10 instead of 6.8.12 with Helm 3. I wanted to configure an extra UDP port. This is a working config:

extraPorts:
  - name: logs # UDP port to send GraphQL logs to
    containerPort: 11111

service:
  ports:
    - name: logs
      port: 11111
      protocol: UDP
      targetPort: 11111

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

Successfully merging a pull request may close this issue.

10 participants