1 sealos 安装应用

sealos run labring/local-path-provisioner:v0.0.23

2 查看当前 StorageClass 资源

1
kubectl get storageclass -n kube-system

3 本地存储配置方案

3.1 Local PersistentVolume

方案一: Local PersistentVolume 适合生产环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv
spec:
capacity:
storage: 500Gi # 根据k8snode01-03的500GB磁盘配置
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain # 生产环境建议Retain
storageClassName: local-storage
local:
path: /mnt/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- k8snode01

3.2 HostPath

方案二:HostPath适合研发环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apiVersion: v1
kind: Pod
metadata:
name: lowcode-pod
spec:
containers:
- name: app
image: nginx:latest
volumeMounts:
- mountPath: /app/data
name: data-volume
volumes:
- name: data-volume
hostPath:
path: /mnt/ldata
type: DirectoryOrCreate