mysql.yaml


Overview

The mysql.yaml file is a Kubernetes manifest template designed for deploying a MySQL database service within a Kubernetes cluster using Helm templating syntax. It defines three primary Kubernetes resources:

This file enables a configurable, replicable, and manageable MySQL deployment that integrates with the overall application (named ragflow in this context), providing persistent storage, initialization scripts, resource allocation, and secure environment management.


Detailed Resource Breakdown

1. PersistentVolumeClaim (PVC)

Purpose

Reserves persistent storage for the MySQL database to ensure data durability beyond pod lifecycles.

Key Fields

Usage Example

kubectl apply -f mysql.yaml

This will create a PVC with requested storage capacity defined in the Helm values, e.g., 10Gi.


2. StatefulSet

Purpose

Deploys and manages the MySQL database pod with stable network identity and persistent storage.

Key Fields

Important Implementation Details

Usage Example

helm install ragflow ./chart-directory

This command deploys the StatefulSet with associated PVC and Service, using values defined in your Helm values.yaml.


3. Service

Purpose

Provides a stable internal endpoint for accessing the MySQL database within the Kubernetes cluster.

Key Fields

Usage Example

Once deployed, other services/pods can connect to MySQL using the service DNS name:

mysql -h ragflow-mysql -P 3306 -u user -p

Interaction With Other System Components


Key Algorithms and Implementation Notes


Mermaid Diagram: Kubernetes Resource Structure and Relationships

flowchart TD
    PVC[PersistentVolumeClaim]
    PVC -->|Bound to| PV[PersistentVolume]

    StatefulSet -->|Uses PVC| PVC
    StatefulSet -->|Mounts ConfigMap| ConfigMap[ConfigMap: mysql-init-script]
    StatefulSet -->|Uses Secret| Secret[Secret: ragflow-env-config]
    StatefulSet -->|Runs container| Container[Container: mysql]

    Service -->|Selects pods by labels| StatefulSet

    style PVC fill:#f9f,stroke:#333,stroke-width:1px
    style PV fill:#bbf,stroke:#333,stroke-width:1px
    style StatefulSet fill:#bfb,stroke:#333,stroke-width:1px
    style Service fill:#ffb,stroke:#333,stroke-width:1px
    style ConfigMap fill:#fbf,stroke:#333,stroke-width:1px
    style Secret fill:#fbb,stroke:#333,stroke-width:1px
    style Container fill:#aff,stroke:#333,stroke-width:1px

Summary

The mysql.yaml file is a Helm-templated Kubernetes manifest that orchestrates a highly available, persistent MySQL deployment tailored for the ragflow application. It leverages Kubernetes StatefulSets for stable pod identity, PVCs for durable storage, and a Service for internal connectivity. The manifest is highly configurable via Helm values, supports secure environment injection, initialization scripting, and resource management, making it a robust solution for containerized MySQL deployment.


If you need further information on Helm templating or Kubernetes StatefulSets, PVCs, and Services, please refer to the official Kubernetes and Helm documentation.