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

Allow users to spec a serviceName in associations #4404

Merged
merged 3 commits into from Apr 20, 2021

Conversation

pebrc
Copy link
Collaborator

@pebrc pebrc commented Apr 2, 2021

Fixes #3732

1000 lines of YAML say more than 100 words:

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  annotations:
  name: test-coord
  namespace: default
spec:
  nodeSets:
  - config:
      node.roles: []
      node.store.allow_mmap: false
    count: 2
    name: coord
    podTemplate:
      metadata:
        labels:
          app: coord-node
  - config:
      node.store.allow_mmap: false
    count: 2
    name: default
  version: 7.12.0
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: kibana-sample
spec:
  version: 7.12.0
  count: 1
  elasticsearchRef:
    name: "test-coord"
    serviceName: "es-coord"
--- 
apiVersion: v1
kind: Service
metadata:
  name: es-coord
  namespace: default
spec:
  ports:
  - name: https
    port: 80
    protocol: TCP
    targetPort: 9200
  selector:
    app: coord-node

Add a new serviceName attribute to all associations (even though it makes only sense for Elasticsearch but the tradeoff here is additional complexity in the code). Query for the referenced service, extract the configured port which matches the currently configured protocol of the managed resource (e.g. Elasticsearch running with HTTPS) and use it to construct a service URL which will be configured in the associated resource.

  • users need to create a service either ahead of time or once the Elastic stack resource have been deployed.
  • users need to follow the port naming convention we use in ECK i.e. https or http (which is compatible with Istio's port naming convention btw)

@pebrc pebrc added >enhancement Enhancement of existing functionality v1.6.0 labels Apr 2, 2021
@pebrc
Copy link
Collaborator Author

pebrc commented Apr 6, 2021

Jenkins test this please

Copy link
Contributor

@sebgl sebgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -49,6 +49,9 @@ type ObjectSelector struct {
Name string `json:"name"`
// Namespace of the Kubernetes object. If empty, defaults to the current namespace.
Namespace string `json:"namespace,omitempty"`
// ServiceName is the name of an existing Kubernetes service which will be used to make requests to the referenced
// object. If left empty the default HTTP service of the referenced resource will be used.
ServiceName string `json:"serviceName,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it clear in the comment and generated doc that the service must exist in the referenced object namespace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v1.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create the ability to target a custom service with elasticsearchRef
2 participants