Helm-charts: [logstash] Invalid ports in headless service

Created on 3 Aug 2020  路  12Comments  路  Source: elastic/helm-charts

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.

bug logstash

Most helpful comment

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

All 12 comments

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

.Values.extraPorts is a container port spec used in statefulset:
https://github.com/elastic/helm-charts/blob/c5660f410ca108c05ce884d257639d77d55fb89a/logstash/templates/statefulset.yaml#L151-L156

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

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

+1

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

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?

+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.

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

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

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dperetti picture dperetti  路  4Comments

milijander88 picture milijander88  路  5Comments

kawat55 picture kawat55  路  3Comments

davidkarlsen picture davidkarlsen  路  5Comments

ebuildy picture ebuildy  路  6Comments