elasticsearchkuberneteskubernetes-ingresselastic-cloud

Ingress for ECK Elasticsearch not working - 502 gateway


I'm using ECK 1.5.0 and I have to use Ingress to expose Elasticsearch. But I'm getting a 502 gateway when I go to the url (http://my-db-url.com). I have confirmed the database is running fine and able to collect / display data.

I was only able to find solutions to exposing Kibana with Ingress on the web but those were not working for me.

Heres my elasticsearch.yaml (contains Elasticsearch object and Ingress object):

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: my-db
spec:
  version: 7.12.0
  volumeClaimDeletePolicy: DeleteOnScaledownOnly
  nodeSets:
  - name: default
    count: 3
    config:
      node.store.allow_mmap: false
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi
        storageClassName: longhorn

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-db-ingress
  namespace: my-namespace
  annotations:
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
    nginx.ingress.kubernetes.io/upstream-vhost: "$http_host"
spec:
  rules:
    - host: my-db-url.com
      http:
        paths:
          - backend:
              serviceName: my-db-es-http
              servicePort: 9200

Solution

  • Turns out the same question was asked here: https://discuss.elastic.co/t/received-plaintext-http-traffic-on-an-https-channel-closing-connection/271380

    and the solution is to force HTTPS using annotations, which for the nginx ingress controller can be found here: https://github.com/elastic/helm-charts/issues/779#issuecomment-781431675