longhorn
所有 pod 列表
|
|
组件
Core Longhorn Components
- Longhorn Manager (longhorn-manager-*)
|
|
- Longhorn UI (longhorn-ui-*)
|
|
- Longhorn CSI Plugin (longhorn-csi-plugin-*)
|
|
- Engine Image (engine-image-ei-*)
|
|
- Instance Manager (instance-manager-*)
|
|
CSI Driver Components
- CSI Attacher (csi-attacher-*)
|
|
- CSI Provisioner (csi-provisioner-*)
|
|
- CSI Resizer (csi-resizer-*)
|
|
- CSI Snapshotter (csi-snapshotter-*)
|
|
Supporting Components
- Longhorn Driver Deployer (longhorn-driver-deployer-*)
|
|
- NFS Client Provisioner (nfs-client-provisioner-*)
|
|
Data Flow
数据流过程
- Control Plane: Longhorn Manager (orchestration)
- Data Plane: Engine Image + Instance Manager (I/O operations)
- K8s Integration: CSI Plugin + CSI components
- Management: Longhorn UI (monitoring/management)
- Multi-Attach: NFS Provisioner (RWX volumes)
总结列表
| Component | Purpose | Critical? | Replicas |
|---|---|---|---|
| Longhorn Manager | Storage orchestration | ✅ Yes | 1 per node |
| Longhorn UI | Web management interface | ⚠️ Important | 2 |
| CSI Plugin | Kubernetes integration | ✅ Yes | 1 per node |
| Engine Image | Data engine | ✅ Yes | Version-based |
| Instance Manager | Volume instance control | ✅ Yes | 1 per node |
| CSI Attacher | Volume attachment | ✅ Yes | 3 |
| CSI Provisioner | Volume provisioning | ✅ Yes | 3 |
| CSI Resizer | Volume expansion | ⚠️ Important | 3 |
| CSI Snapshotter | Snapshots | ⚠️ Important | 3 |
| Driver Deployer | CSI deployment | ✅ Yes | 1 |
| NFS Provisioner | RWX volumes | ✅ For RWX | 1 |
实现细节
关系图
flowchart LR
U["User / Admin"]
subgraph CP["Longhorn Control Plane"]
UI["Longhorn UI"]
MGR["Longhorn Manager<br/>Pod"]
DD["CSI Driver Deployer"]
LV["Longhorn Volumes"]
end
subgraph K8S["Kubernetes Cluster"]
K["Kubernetes"]
end
subgraph CSI["CSI Components"]
LP["Longhorn CSI Plugin"]
ATT["CSI Attacher"]
PROV["CSI Provisioner"]
RES["CSI Resizer"]
SNAP["CSI Snapshotter"]
end
subgraph SDP["Storage Data Plane"]
IM["Instance Manager"]
EI["Engine Image"]
VR["Volume Replicas"]
BS["Block Storage"]
end
subgraph NFS["NFS Sharing (RWX Volumes)"]
NFSP["NFS Client Provisioner"]
RWX["RWX Volumes"]
PODS["Multiple Pods"]
end
U -->|Web UI| UI
U -->|kubectl| K
UI -->|API Calls| MGR
K -->|API Requests| MGR
K -->|Storage Requests| LP
MGR -->|Manages| DD
MGR -->|Monitors| LV
MGR -->|Coordinates| IM
MGR -->|Controls| EI
MGR -->|Configures| LP
LP -->|Attach / Detach| ATT
LP -->|Create / Delete| PROV
LP -->|Expand| RES
LP -->|Snapshot| SNAP
LP -->|Volume Operations| IM
LP -->|Data Path| EI
LP -->|RWX / NFS| NFSP
LV -->|Backed by| VR
IM -->|Controls| VR
EI -->|Data I/O| BS
VR -->|Stored in| BS
NFSP -->|Shares| RWX
RWX -->|Mounted by| PODS
classDef user fill:#fce7f3,stroke:#db2777,color:#111827;
classDef control fill:#dbeafe,stroke:#2563eb,color:#111827;
classDef k8s fill:#fef3c7,stroke:#d97706,color:#111827;
classDef csi fill:#f3e8ff,stroke:#9333ea,color:#111827;
classDef storage fill:#dcfce7,stroke:#16a34a,color:#111827;
classDef nfs fill:#ffedd5,stroke:#f97316,color:#111827;
class U user;
class UI,MGR,DD,LV control;
class K k8s;
class LP,ATT,PROV,RES,SNAP csi;
class IM,EI,VR,BS storage;
class NFSP,RWX,PODS nfs;
Control Plane (Blue)
- Longhorn Manager: Brain of the system - manages all operations
- Longhorn UI: Web dashboard for visualization and management
- CSI Driver Deployer: Deploys and updates CSI components
CSI Integration (Purple)
- CSI Attacher: Handles volume attachment to nodes
- CSI Provisioner: Creates/deletes PersistentVolumes
- CSI Resizer: Expands volumes on-demand
- CSI Snapshotter: Manages volume snapshots
- Longhorn CSI Plugin: Main integration point with Kubernetes
Storage Data Plane (Green)
- Instance Manager: Manages volume lifecycle on each node
- Engine Image: Handles actual data I/O operations
- Volume Replicas: Data copies distributed across nodes
- Block Storage: Underlying storage devices
- NFS Sharing (Orange)
- NFS Client Provisioner: Enables ReadWriteMany (RWX) access
- Shared Volumes: Volumes accessible by multiple pods simultaneously
Data Flow
- User/Admin interacts via UI or kubectl
- Longhorn Manager coordinates all operations
- CSI components integrate with Kubernetes storage
- Instance Managers and Engine Images handle data operations
- NFS Provisioner enables multi-pod access for RWX volumes
写数据的过程:
flowchart TD
App[Application Pod] -->|Writes data| PVC[PersistentVolumeClaim]
PVC -->|Storage request| LonghornVol[Longhorn Volume]
subgraph "Longhorn Data Plane (Green Components)"
LonghornVol -->|I/O routing| Engine[Engine Image Pod]
Engine -->|Data distribution| Replica1[Replica 1]
Engine -->|Data distribution| Replica2[Replica 2]
Engine -->|Data distribution| Replica3[Replica 3]
Replica1 -->|Writes to| Storage1[/var/lib/longhorn/]
Replica2 -->|Writes to| Storage2[/var/lib/longhorn/]
Replica3 -->|Writes to| Storage3[/var/lib/longhorn/]
end
Storage1 -->|Physical disk| Disk1[Node 1 Disk]
Storage2 -->|Physical disk| Disk2[Node 2 Disk]
Storage3 -->|Physical disk| Disk3[Node 3 Disk]
数据默认存储在:
- 每台机器的 /var/lib/longhorn
交互过程:
sequenceDiagram
participant User as User/App
participant K8s as Kubernetes API
participant CSI as CSI Driver
participant LH_M as Longhorn Manager
participant LH_E as Engine Image
participant LH_R as Replicas
User->>K8s: kubectl create -f pvc.yaml
K8s->>CSI: ProvisionVolume request
CSI->>LH_M: Create Longhorn Volume
LH_M->>LH_E: Deploy Engine Instance
LH_E->>LH_R: Create Replicas (3x)
LH_R->>LH_E: Replica ready status
LH_E->>LH_M: Volume ready
LH_M->>CSI: Volume created success
CSI->>K8s: PV created and bound
K8s->>User: PVC Bound status
写入
|
|
其他操作
快照和读写流程
快照
Step-by-Step Location Resolution:
- Pod requests I/O → Kubernetes routes to Longhorn CSI driver
- CSI driver queries Longhorn Manager for volume location
- Longhorn Manager checks Kubernetes for the volume’s Engine pod
- Engine pod contains the complete replica map and read index
- Engine directs I/O to the appropriate replicas
Complete Flow: CSI Driver → Longhorn Manager → Engine
sequenceDiagram
participant CSI as CSI Driver
participant KM as Kubernetes API
participant LM as Longhorn Manager
participant EP as Engine Pod
participant CR as Custom Resources
CSI->>LM: HTTP API call to longhorn-backend:9500
LM->>KM: Query Volume CRD
KM->>LM: Return volume spec/status
LM->>KM: Query Engine Pod location
KM->>LM: Return Engine Pod details
LM->>CSI: Return volume location (Engine Pod info)
CSI->>EP: Direct I/O requests to Engine Pod
Scaling Summary
| Component | Scaling Type | Pod Count Formula | Fixed or Dynamic |
|---|---|---|---|
| Longhorn Manager | DaemonSet | number_of_nodes |
✅ Fixed |
| Instance Manager | DaemonSet | number_of_nodes |
✅ Fixed |
| Longhorn Engine | Per-Volume | number_of_active_volumes |
🔄 Dynamic |
pvc 绑定的过程
sequenceDiagram
participant User as User/Admin
participant K8s as Kubernetes API
participant CSI as CSI Driver
participant LM as Longhorn Manager
participant IM as Instance Manager
participant Engine as Longhorn Engine
User->>K8s: kubectl create -f pvc.yaml
K8s->>CSI: PVC Creation Request
CSI->>LM: API Call to Longhorn Manager
LM->>K8s: Create Volume CRD
LM->>IM: Deploy Engine & Replicas
IM->>Engine: Create Engine Instance
IM->>IM: Create Replica Instances
Engine->>CSI: Volume Ready Notification
CSI->>K8s: PV Created & Bound
K8s->>User: PVC Bound
备份
The Relationship between Backups in Secondary Storage and Snapshots in Primary Storage
Backup Creation Process**
graph LR
A[Live Volume] --> B[Snapshot] --> C[Backup] --> D[Backupstore]
subgraph "Cluster"
A --> E[Snapshot Chain]
E --> B
end
subgraph "External Storage"
D --> F[S3/NFS]
end
可以cron 定时触发
可以增量写 外部存储
物理和逻辑关系
物理和逻辑关系
|
|
volumes.longhorn.io 这个 CR 信息:
|
|
longhorn 相关的所有 crd
|
|
How PV, PVC, and StorageClass Work Together
graph LR
A[User creates PVC] --> B[StorageClass]
B --> C[CSI Driver]
C --> D[Storage Provider<br/>Longhorn/NFS/EBS]
D --> E[PV Created]
E --> F[PVC Bound]
F --> G[Pod uses Volume]
Advanced Longhorn Features
Incremental Snapshots with Chain Management
- Advanced Benefit: Space-efficient snapshots that only store block differences, enabling point-in-time recovery without massive storage overhead.
|
|
Cross-Cluster Disaster Recovery
- Use Case: Primary cluster in AWS us-east-1 fails → Restore volumes in us-west-2 from S3 backups within minutes.
|
|
Quality of Service (QoS) Controls
- Enterprise Feature: Ensure predictable performance for production databases while allowing burst capacity for less critical workloads.
|
|
Volume Cloning and Templating
- DevOps Benefit: Create 100+ development environments from production snapshots in seconds, each consuming storage incrementally.
|
|
Advanced Replication Strategies
- HA Pattern: Survives entire availability zone failures while maintaining data locality optimizations.
|
|
CSI Snapshots Integration with Kubernetes
|
|
Performance Monitoring and Analytics
|
|
Encryption at Rest with Key Rotation
- Security: Enterprise-grade encryption with compliance-friendly key rotation policies.
|
|