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

Custom Logstash service labels are not preserved #7855

Closed
lpeter91 opened this issue May 28, 2024 · 1 comment · Fixed by #7895
Closed

Custom Logstash service labels are not preserved #7855

lpeter91 opened this issue May 28, 2024 · 1 comment · Fixed by #7895
Labels
>bug Something isn't working >enhancement Enhancement of existing functionality :logstash

Comments

@lpeter91
Copy link

lpeter91 commented May 28, 2024

What did you do?

I tried to add custom labels to a Logstash service definition (see below how).

What did you expect to see?

I expected to see the defined labels on the created service resource.

What did you see instead? Under which circumstances?

The custom labels were replaced by the ones generated by the operator.

Environment

  • ECK version: 2.12.1

  • Kubernetes information: On premise, Kubespary v2.25.0.

  • Partial resource definition:

apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
  name: "logstash"
spec:
  # Actual spec cut for brevity
  services:
    - name: inputs
      service:
        metadata:
          annotations:
            io.cilium/lb-ipam-ips: "1.2.3.4"
          labels:
            io.cilium/address-pool: public
        spec:
          type: LoadBalancer
          allocateLoadBalancerNodePorts: false
          ports:
            - port: 5044
              name: agent
              protocol: TCP
              targetPort: 5044
            - port: 9800
              name: logstash
              protocol: TCP
              targetPort: 9800

Comments
The custom annotations are preserved, but the labels are replaced. I think here:

https://github.com/elastic/cloud-on-k8s/blob/v2.12.1/pkg/controller/logstash/service.go#L72-L74

I think merging with user-defined labels would be preferrable.

@botelastic botelastic bot added the triage label May 28, 2024
@rhr323
Copy link
Contributor

rhr323 commented May 30, 2024

Hey @lpeter91

Thank you for reporting this issue.

I think merging with user-defined labels would be preferable.

I agree, we seem to do this for other services, too.

@rhr323 rhr323 added >bug Something isn't working >enhancement Enhancement of existing functionality and removed triage labels May 30, 2024
kaisecheng added a commit to kaisecheng/cloud-on-k8s that referenced this issue Jun 11, 2024
pebrc added a commit that referenced this issue Jun 12, 2024
This commit preserves user labels in Logstash Service

Fixes: #7855

The following resource should keep customized label in service `logstash-sample-ls-beats`

```yaml
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
  name: logstash-sample
spec:
  count: 1
  version: 8.14.0
  pipelines:
    - pipeline.id: main
      pipeline.workers: 2
      config.string: "input { beats { port => 5044 }} output { stdout {}}"
  services:
    - name: beats
      service:
        metadata:
          labels:
            i.am.label: here
        spec:
          type: ClusterIP
          ports:
            - port: 5044
              name: "filebeat"
              protocol: TCP
              targetPort: 5044
```
---------

Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working >enhancement Enhancement of existing functionality :logstash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants