Linuzb' 的博客

记录学习点滴

28 Apr 2024

Kubernetes 部署 longhorn 存储

背景

longhorn 是基于 Kubernetes 构建的云原生分布式存储

依赖

Installation Requirements

ubuntu 安装依赖

运行以下脚本,检查是否满足依赖

1
curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/scripts/environment_check.sh | bash

如果缺少依赖,需要安装依赖,例如

1
2
apt-get install open-iscsi
apt-get install nfs-common

kubectl 安装及 kubeconfig 配置

部署

helm

Longhorn | Documentation

1
2
3
4
5
6
helm pull longhorn/longhorn --version 1.6.1
helm upgrade --install longhorn ./longhorn \
  --namespace longhorn-system \
  --create-namespace \
  --version 1.6.1 \
  --values config.yaml

config.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defaultSettings:
  # 配置默认数据存放地址
  defaultDataPath: /data/longhorn

service:
  ui:
    # -- Service type for Longhorn UI. (Options: "ClusterIP", "NodePort", "LoadBalancer", "Rancher-Proxy")
    type: NodePort
    # -- NodePort port number for Longhorn UI. When unspecified, Longhorn selects a free port between 30000 and 32767.
    nodePort: 30180
  manager:
    # -- Service type for Longhorn Manager.
    type: NodePort
    # -- NodePort port number for Longhorn Manager. When unspecified, Longhorn selects a free port between 30000 and 32767.
    nodePort: 30181

longhornManager:
  # -- Toleration for Longhorn Manager on nodes allowed to run Longhorn Manager.
  tolerations:
  - key: "node-role.kubernetes.io/control-plane"
    operator: "Exists"
    effect: "NoSchedule"

longhornDriver:
  # -- Toleration for Longhorn Driver on nodes allowed to run Longhorn components.
  tolerations: 
  - key: "node-role.kubernetes.io/control-plane"
    operator: "Exists"
    effect: "NoSchedule"

访问管理页面

Longhorn dashboard http://{EXTERNAL-IP}:30180/#/dashboard

故障恢复

从 replica 中恢复

参考

Next time, we'll talk about "10 Reasons why gcc SHOULD be re-written in JavaScript - You won't believe #8!"