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

Service not reset when set then removed from definition #8161

Closed
thbkrkr opened this issue Oct 28, 2024 · 2 comments
Closed

Service not reset when set then removed from definition #8161

thbkrkr opened this issue Oct 28, 2024 · 2 comments
Labels
>bug Something isn't working

Comments

@thbkrkr
Copy link
Contributor

thbkrkr commented Oct 28, 2024

ECK manages a set of services per Elasticsearch cluster that users can configure. By default, the operator configures the http service with typeClusterIP. If a user configures it with type LoadBalancer and later completely deletes it from the es resource definition, the service is never reconfigured to the default typeClusterIP.

Step to reproduce:

  • Deploy an Elasticsearch with a LoadBalancer service:
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: c0
spec:
  version: 8.15.3
  http:
    service:
      spec:
        type: LoadBalancer
  nodeSets:
  - name: default
    count: 1
    config:
      node.store.allow_mmap: false
  • Remove the service from the definition and redeploy:
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: c0
spec:
  version: 8.15.3
  # http:
  #   service:
  #     metadata:
  #       annotations:
  #         answer: "42"
  #     spec:
  #       type: LoadBalancer
  nodeSets:
  - name: default
    count: 1
    config:
      node.store.allow_mmap: false
  • Check that the service type is still LoadBalancer:
NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP    PORT(S)          AGE
c0-es-http            LoadBalancer   10.1.2.3   192.1.2.3   9200:31142/TCP   3m24s

Why?

We have a function to set the defaults, but we don't set the type there:

.

We have a function to applyServerSideValues for several reasons, to decide if we need to recreate or update the service, where we retrieve and restore the current reconciled type.

func needsRecreate(expected, reconciled *corev1.Service) bool {
applyServerSideValues(expected, reconciled)

@thbkrkr thbkrkr added the >bug Something isn't working label Oct 28, 2024
@thbkrkr
Copy link
Contributor Author

thbkrkr commented Oct 28, 2024

I wonder what other default value than ClusterIP may be set (comes from #1011)?

// Type may be defaulted by the api server
if expected.Spec.Type == "" {
expected.Spec.Type = reconciled.Spec.Type
}

Reading the godoc of the type field, it is written that it defaults to ClusterIP.

@kaykhan
Copy link

kaykhan commented Oct 29, 2024

@thbkrkr

I wonder if i my issue is related at all - #8157

I remember not setting NodePort to begin with which would have defaulted to ClusterIP

But now that i want to set the http service as type NodePort it always spawns as ClusterIP

Is there any way around this?

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

No branches or pull requests

2 participants