Files
Olares/docs/developer/develop/mw-integrate-with-es.md
Meow33 776848d2e2 docs: add application environment variables (#2577)
* docs: updated installation env vars and runtime values references

* docs: fix content

* docs: update content

* Update table of contents, and refactored docs.

* Fixed capitalization.

* batch update to fix readability

* refactored declarative env var

* Updated translation.

* Updated based on suggestions.

* Updated based on suggestions.

---------

Co-authored-by: yajing wang <413741312@qq.com>
2026-03-05 17:52:22 +08:00

71 lines
2.4 KiB
Markdown

---
outline: [2, 3]
description: Learn how to integrate your app with Elasticsearch service in Olares.
---
# Integrate with Elasticsearch
Use Olares Elasticsearch middleware by declaring it in `OlaresManifest.yaml`, then mapping the injected values to your container environment variables.
## Install Elasticsearch service
Install the Elasticsearch service from Market.
1. Open Market from Launchpad and search for "Elasticsearch".
2. Click **Get**, then **Install**, and wait for the installation to complete.
Once installed, the service and its connection details will appear in the Middleware list in Control Hub.
## Configure `OlaresManifest.yaml`
In `OlaresManifest.yaml`, add the required middleware configuration.
- Use the `username` field to specify the Elasticsearch user.
- Use the `indexes` field to request one or more indexes. Each index name is used as the key in `.Values.elasticsearch.indexes`.
**Example**
```yaml
middleware:
elasticsearch:
username: elasticlient
indexes:
- name: aaa
```
## Map to environment variables
In your deployment YAML, map the injected `.Values.elasticsearch.*` fields to the container environment variables your app requires.
**Example**
```yaml
containers:
- name: my-app
env:
- name: ES_HOST
value: "{{ .Values.elasticsearch.host }}"
- name: ES_PORT
value: "{{ .Values.elasticsearch.port }}"
- name: ES_USER
value: "{{ .Values.elasticsearch.username }}"
- name: ES_PASSWORD
value: "{{ .Values.elasticsearch.password }}"
# Index name
# The index name configured in OlaresManifest (for example, aaa)
- name: ES_INDEX
value: "{{ .Values.elasticsearch.indexes.aaa }}"
```
## Elasticsearch values reference
Elasticsearch values are predefined runtime values injected into `values.yaml` during deployment. They are system-managed and not user-editable.
| Value | Type | Description |
| --- | --- | --- |
| `.Values.elasticsearch.host` | String | Elasticsearch service host. |
| `.Values.elasticsearch.port` | Number | Elasticsearch service port. |
| `.Values.elasticsearch.username` | String | Elasticsearch username. |
| `.Values.elasticsearch.password` | String | Elasticsearch password. |
| `.Values.elasticsearch.indexes` | Map\<String,String> | Requested indexes, keyed by index name. For example, a request for `aaa` is available at `.Values.elasticsearch.indexes.aaa`. |