Skip to content

Latest commit

 

History

History
302 lines (264 loc) · 9.98 KB

enterprise-search.asciidoc

File metadata and controls

302 lines (264 loc) · 9.98 KB

Run Enterprise Search on ECK

This section describes how to deploy, configure and access Enterprise Search with ECK.

Quickstart

  1. Apply the following specification to deploy Enterprise Search. ECK automatically configures the secured connection to an Elasticsearch cluster named quickstart, created in Elasticsearch quickstart.

    cat <<EOF | kubectl apply -f -
    apiVersion: enterprisesearch.k8s.elastic.co/v1
    kind: EnterpriseSearch
    metadata:
      name: enterprise-search-quickstart
    spec:
      version: {version}
      count: 1
      elasticsearchRef:
        name: quickstart
    EOF
    Note
    Workplace Search in versions 7.7 up to and including 7.8 required an Enterprise license on ECK. You can start with a 30-day trial license.
  2. Monitor the Enterprise Search deployment.

    Retrieve details about the Enterprise Search deployment:

    kubectl get enterprisesearch
    NAME                            HEALTH    NODES    VERSION   AGE
    enterprise-search-quickstart    green     1        {version}      8m

    List all the Pods belonging to a given deployment:

    kubectl get pods --selector='enterprisesearch.k8s.elastic.co/name=enterprise-search-quickstart'
    NAME                                                READY   STATUS    RESTARTS   AGE
    enterprise-search-quickstart-ent-58b84db85-dl7c6    1/1     Running   0          2m50s
  3. Access logs for that Pod:

    kubectl logs -f enterprise-search-quickstart-ent-58b84db85-dl7c6
  4. Access Enterprise Search.

    A ClusterIP Service is automatically created for the deployment, and can be used to access the Enterprise Search API from within the Kubernetes cluster:

    kubectl get service enterprise-search-quickstart-ent-http

    Use kubectl port-forward to access Enterprise Search from your local workstation:

    kubectl port-forward service/enterprise-search-quickstart-ent-http 3002

    Open https://localhost:3002 in your browser.

    Note
    Your browser will show a warning because the self-signed certificate configured by default is not verified by a known certificate authority and not trusted by your browser. Acknowledge the warning for the purposes of this quickstart, but for a production deployment we recommend configuring valid certificates.

    Login as the elastic user created with the Elasticsearch cluster. Its password can be obtained with:

    kubectl get secret quickstart-es-elastic-user -o=jsonpath='{.data.elastic}' | base64 --decode; echo
  5. Access the Enterprise Search UI in Kibana.

    Starting with version 7.14.0, the Enterprise Search UI is accessible in Kibana.

    Apply the following specification to deploy Kibana, configured to connect to both Elasticsearch and Enterprise Search:

    cat <<EOF | kubectl apply -f -
    apiVersion: kibana.k8s.elastic.co/v1
    kind: Kibana
    metadata:
      name: quickstart
    spec:
      version: {version}
      count: 1
      elasticsearchRef:
        name: quickstart
      enterpriseSearchRef:
        name: enterprise-search-quickstart
    EOF

    Use kubectl port-forward to access Kibana from your local workstation:

    kubectl port-forward service/quickstart-kb-http 5601

    Open https://localhost:5601 in your browser and navigate to the Enterprise Search UI.

Configuration

Upgrade the Enterprise Search specification

You can upgrade the Enterprise Search version or change settings by editing the YAML specification. ECK will apply the changes by performing a rolling restart of Enterprise Search pods.

Customize Enterprise Search configuration

ECK sets up a default Enterprise Search configuration. To customize it, use the config element in the specification.

At a minimum, you must set both ent_search.external_url and kibana.host to the desired URLs.

apiVersion: enterprisesearch.k8s.elastic.co/v1
kind: EnterpriseSearch
metadata:
  name: enterprise-search-quickstart
spec:
  version: {version}
  count: 1
  elasticsearchRef:
    name: quickstart
  config:
    # define the exposed URL at which users will reach Enterprise Search
    ent_search.external_url: https://my-custom-domain:3002
    # define the exposed URL at which users will reach Kibana
    kibana.host: https://kibana.my-custom-domain:5601
    # configure app search document size limit
    app_search.engine.document_size.limit: 100kb

Reference Kubernetes Secrets for sensitive settings

Sensitive settings are best stored in Kubernetes Secrets, referenced in the Enterprise Search specification.

This example sets up a Secret with SMTP credentials:

apiVersion: enterprisesearch.k8s.elastic.co/v1
kind: EnterpriseSearch
metadata:
  name: enterprise-search-quickstart
spec:
  version: {version}
  count: 1
  elasticsearchRef:
    name: quickstart
  config:
    ent_search.external_url: https://my-custom-domain:3002
    kibana.host: https://kibana.my-custom-domain:5601
  configRef:
    secretName: smtp-credentials
---
kind: Secret
apiVersion: v1
metadata:
  name: smtp-credentials
stringData:
  enterprise-search.yml: |-
    email.account.enabled: true
    email.account.smtp.auth: plain
    email.account.smtp.starttls.enable: false
    email.account.smtp.host: 127.0.0.1
    email.account.smtp.port: 25
    email.account.smtp.user: myuser
    email.account.smtp.password: mypassword
    email.account.email_defaults.from: my@email.com

ECK merges the content of config and configRef into a single internal Secret. In case of duplicate settings, the configRef secret has precedence.

Customize the Pod template

You can override the Enterprise Search Pods specification through the podTemplate element.

This example overrides the default 4Gi deployment to use 8Gi instead, and makes the deployment highly-available with 3 Pods:

apiVersion: enterprisesearch.k8s.elastic.co/v1
kind: EnterpriseSearch
metadata:
  name: enterprise-search-quickstart
spec:
  version: {version}
  count: 3
  elasticsearchRef:
    name: quickstart
  podTemplate:
    spec:
      containers:
      - name: enterprise-search
        resources:
          requests:
            cpu: 3
            memory: 8Gi
          limits:
            memory: 8Gi
        env:
        - name: JAVA_OPTS
          value: -Xms7500m -Xmx7500m

Expose Enterprise Search

By default ECK manages self-signed TLS certificates to secure the connection to Enterprise Search. It also restricts the Kubernetes service to ClusterIP type that cannot be accessed publicly.

Check how to access Elastic Stack services to customize TLS settings and expose the service.

Note
When exposed outside the scope of localhost, make sure to set both ent_search.external_url, and kibana.host accordingly in the Enterprise Search configuration.

Customize the connection to an Elasticsearch cluster

The elasticsearchRef element allows ECK to automatically configure Enterprise Search to establish a secured connection to a managed Elasticsearch cluster. By default it targets all nodes in your cluster. If you want to direct traffic to specific nodes of your Elasticsearch cluster, refer to [{p}-traffic-splitting] for more information and examples.

Connect to an external Elasticsearch cluster

If you do not want to use the elasticsearchRef mechanism or if you want to connect to an Elasticsearch cluster not managed by ECK, you can manually configure Enterprise Search to access any available Elasticsearch cluster:

apiVersion: enterprisesearch.k8s.elastic.co/v1
kind: EnterpriseSearch
metadata:
  name: enterprise-search-quickstart
spec:
  version: {version}
  count: 1
  configRef:
    secretName: elasticsearch-credentials
---
kind: Secret
apiVersion: v1
metadata:
  name: elasticsearch-credentials
stringData:
  enterprise-search.yml: |-
    elasticsearch.host: https://elasticsearch-url:9200
    elasticsearch.username: elastic
    elasticsearch.password: my-password
    elasticsearch.ssl.enabled: true

Troubleshooting

Capture a JVM heap dump

For advanced troubleshooting you might need to capture a JVM heap dump. By default, the Enterprise Search Docker image is not configured to run with a data volume by the ECK operator. However, you can write a heap dump to the tmp directory that Enterprise Search uses. Note that your heap dump will be lost if you do not extract it before the container restarts.

kubectl exec $POD_NAME -- bash -c \
  'jmap -dump:format=b,file=tmp/heap.hprof $(jps| grep Main | cut -f 1 -d " ")'

# The Enterprise Search Docker images don't have tar installed so we cannot use kubectl cp
kubectl exec $POD_NAME -- cat /usr/share/enterprise-search/tmp/heap.hprof | gzip -c > heap.hprof.gz

# Remove the heap dump from the running container to free up space
kubectl exec $POD_NAME -- rm /usr/share/enterprise-search/tmp/heap.hprof