opensearch.yaml

Overview

The opensearch.yaml file is a Helm template used for deploying an OpenSearch service within a Kubernetes cluster as part of the Ragflow application. It orchestrates the creation and configuration of multiple Kubernetes resources, including:

This template is conditionally rendered only if the .Values.env.DOC_ENGINE Helm value is set to "opensearch". It leverages Helm templating features such as includes, conditionals, and value injections to customize resource specifications dynamically.


Detailed Explanation of the Resources

1. PersistentVolumeClaim (PVC)

Purpose:
Allocates persistent storage for OpenSearch data to ensure data durability across pod restarts.

Key Fields:


2. StatefulSet

Purpose:
Manages a set of OpenSearch pods with persistent identities and stable storage, enabling reliable cluster behavior and data persistence.

Key Fields:

Pod Spec:


3. Service

Purpose:
Creates a Kubernetes Service to expose OpenSearch pods internally within the cluster, allowing other components to communicate with OpenSearch.

Key Fields:


Important Implementation Details and Algorithms


Interaction with Other System Components


Usage Example

To deploy OpenSearch with this Helm template, ensure your values.yaml includes:

env:
  DOC_ENGINE: "opensearch"

opensearch:
  storage:
    className: "fast-ssd"         # Optional storage class
    capacity: "10Gi"              # Storage size for PVC
  image:
    repository: "opensearchproject/opensearch"
    tag: "2.9.0"
    pullPolicy: "IfNotPresent"
  initContainers:
    alpine:
      repository: "alpine"
      tag: "3.15"
      pullPolicy: "IfNotPresent"
    busybox:
      repository: "busybox"
      tag: "1.35"
      pullPolicy: "IfNotPresent"
  deployment:
    strategy:
      type: RollingUpdate
    resources:
      requests:
        cpu: "500m"
        memory: "1Gi"
      limits:
        cpu: "1"
        memory: "2Gi"
  service:
    type: ClusterIP

Then run:

helm install ragflow ./ragflow-chart -f values.yaml

Mermaid Diagram

flowchart TD
    PVC[PersistentVolumeClaim]
    StatefulSet[StatefulSet: opensearch]
    Service[Service: opensearch]

    PVC --> StatefulSet
    StatefulSet --> Service

    subgraph StatefulSet Pods
        direction TB
        InitContainer1["fix-data-volume-permissions"]
        InitContainer2["sysctl (vm.max_map_count)"]
        Container["opensearch container"]
    end

    StatefulSet --> InitContainer1
    StatefulSet --> InitContainer2
    StatefulSet --> Container

Summary

The opensearch.yaml Helm template defines a robust and configurable OpenSearch deployment within the Ragflow Kubernetes environment. It ensures persistent storage, secure and properly configured container execution, and seamless integration with the rest of the system through services and config management. The use of init containers and liveness probes reflects best practices for stateful service deployments in Kubernetes.