elasticsearch-config.yaml
Overview
elasticsearch-config.yaml is a Kubernetes ConfigMap manifest template designed to configure an Elasticsearch node within a deployment. It dynamically generates configuration data based on Helm chart values, specifically when the document engine (DOC_ENGINE) is set to "elasticsearch". This file provides key Elasticsearch settings such as node identity, cluster discovery mode, security features, disk allocation watermarks, and timezone configuration. The resulting ConfigMap is used by the Elasticsearch pod(s) to initialize and run with the specified parameters.
Detailed Explanation
Template Conditions
The entire content is conditionally included only if the Helm value
.Values.env.DOC_ENGINEequals"elasticsearch".{{- if eq .Values.env.DOC_ENGINE "elasticsearch" -}} ... {{- end -}}This prevents unnecessary configuration deployment when Elasticsearch is not the selected document engine.
Kubernetes Resource Definition
apiVersion:
v1kind:
ConfigMapmetadata.name: Dynamically generated name combining the Helm template helper
ragflow.fullnameand suffix-es-config. This uniquely identifies the ConfigMap for Elasticsearch configuration.
ConfigMap Data Entries
Key | Description | Type | Example Value |
|---|---|---|---|
| The name of the Elasticsearch node. Used internally by Elasticsearch cluster nodes. | string |
|
| Whether to lock the memory on startup to prevent swapping. | string (bool) |
|
| The type of discovery used by Elasticsearch. | string |
|
| Enables or disables X-Pack security features. Here it is enabled ( | string (bool) |
|
| Enables or disables SSL/TLS for HTTP communication. Disabled here ( | string (bool) |
|
| Enables or disables SSL/TLS for transport (node-to-node) communication. Disabled here ( | string (bool) |
|
| Low disk watermark threshold for shard allocation. Accepts sizes like | string |
|
| High disk watermark threshold to relocate shards away. | string |
|
| Flood stage disk watermark to mark the index read-only to prevent data loss. | string |
|
| Timezone setting, dynamically set from Helm values | string | e.g., |
Usage Example
In a Helm deployment scenario, this file is rendered only if the environment variable DOC_ENGINE is set to "elasticsearch". For example, in your values.yaml:
env:
DOC_ENGINE: elasticsearch
TIMEZONE: UTC
When Helm renders this template, it produces a ConfigMap named something like myapp-es-config with the specified Elasticsearch configuration. This ConfigMap can then be mounted as a volume in an Elasticsearch pod and used to configure the Elasticsearch instance on startup.
Implementation Details & Algorithms
Conditional Rendering: Uses Helm templating syntax to conditionally include the ConfigMap only when Elasticsearch is the chosen document engine.
Dynamic Naming: Uses Helm helper function
ragflow.fullnameto create a consistent naming scheme.Disk Watermark Settings: The disk watermarks are configured in a non-standard order — typically, the low watermark is less than high, and high is less than flood stage. Here, the values seem inverted (
low=5gb,high=3gb,flood_stage=2gb), which might indicate a mistake or intentional behavior to trigger shard relocations aggressively as disk usage grows. This should be verified against Elasticsearch documentation or adjusted accordingly.Security Settings: X-Pack security is enabled but with SSL disabled for both HTTP and transport layers, which might be acceptable for local or development environments but not recommended for production.
Timezone: The
TZenvironment variable is set for the container/pod, allowing Elasticsearch logs and timestamps to be consistent with the desired timezone.
Interaction with Other System Components
Helm Chart: This file is part of a Helm chart template set and depends on values defined in the
values.yamlor via override during deployment.Elasticsearch Pods: The ConfigMap created by this template is consumed by Elasticsearch pods, typically mounted as a configuration file or environment variables.
Cluster Discovery & Management: The
discovery.type: single-nodesetting indicates this configuration is for standalone Elasticsearch deployment without clustering.Other ConfigMaps / Secrets: This file may be used alongside other configuration files or secrets that provide certificates, credentials, or advanced Elasticsearch settings.
Application Components: Applications using Elasticsearch as their document engine will depend on this configuration to connect and interact with Elasticsearch.
Visual Diagram
flowchart TD
A[Helm Template Render] --> B{Check DOC_ENGINE}
B -- yes: elasticsearch --> C[Render elasticsearch-config.yaml]
B -- no --> D[Skip elasticsearch-config.yaml]
C --> E[Create Kubernetes ConfigMap]
E --> F[ConfigMap with Elasticsearch Settings]
F --> G[Mounted into Elasticsearch Pod]
G --> H[Elasticsearch Node Startup]
H --> I[Elasticsearch configured with:]
I -->|node.name| J["es01"]
I -->|discovery.type| K["single-node"]
I -->|xpack.security.enabled| L["true"]
I -->|Disk Watermarks| M["Low=5gb, High=3gb, Flood=2gb"]
I -->|Timezone| N[Set to .Values.env.TIMEZONE]
Summary
This file serves as a conditional Kubernetes ConfigMap template that configures Elasticsearch nodes with essential runtime parameters when Elasticsearch is used as the document engine. It enables basic security, sets discovery mode to single-node, configures disk watermarks, and applies timezone settings, providing a foundational Elasticsearch configuration for the application environment.