官网:https://www.rancher.cn/longhorn
架构图:
1.安装要求
官网提供:https://longhorn.io/docs/1.5.3/deploy/install
注:这里关于安装要求我们就不多做赘述,请看官方文档内的要求,这里只是将需要的进行安装,目前系统为:ubuntu 22.04
,集群版本:v1.26.5
。
apt-get install open-iscsi nfs-common jq -y
# iscsi启动
modprobe iscsi_tcp
bash -c 'echo iscsi_tcp > /etc/modprobe.d/iscsi-tcp.conf'
systemctl enable iscsid.service
systemctl restart iscsid.service
systemctl status iscsid.service
# 检查项
##请确保在 iscsid 服务启动之前iscsi_tcp模块已加载。通常,它应该与软件包安装一起自动加载。
sudo lsmod | grep iscsi -i
##启用了支持NFSv4.1、NFSv4.2
cat /boot/config-`uname -r`| grep CONFIG_NFS_V4_1
cat /boot/config-`uname -r`| grep CONFIG_NFS_V4_2
1.1.使用容器安装open-iscsi、nfs
前言:这里二选一要么直接安装命令,要么使用容器去进行安装,这里选择之间安装的命令。
# open-iscsi
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.5.3/deploy/prerequisite/longhorn-iscsi-installation.yaml
# nfs
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.5.3/deploy/prerequisite/longhorn-nfs-installation.yaml
环境检查脚本:
curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/v1.5.3/scripts/environment_check.sh | bash
[INFO] Required dependencies 'kubectl jq mktemp sort printf' are installed.
[INFO] All nodes have unique hostnames.
[INFO] Waiting for longhorn-environment-check pods to become ready (0/2)...
[INFO] All longhorn-environment-check pods are ready (2/2).
[INFO] MountPropagation is enabled
[INFO] Checking kernel release...
[INFO] Checking iscsid...
[INFO] Checking multipathd...
[INFO] Checking packages...
[INFO] Checking nfs client...
[INFO] Cleaning up longhorn-environment-check pods...
[INFO] Cleanup completed.
2.Longhorn部署
官网提供:https://longhorn.io/docs/1.5.3/deploy/install/install-with-kubectl kubectl方式部署。
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.5.3/deploy/longhorn.yaml
# 查看pod情况
kubectl get pods --namespace longhorn-system
NAME READY STATUS RESTARTS AGE
csi-attacher-785fd6545b-29hb6 1/1 Running 0 90m
csi-attacher-785fd6545b-bw8f5 1/1 Running 0 90m
csi-attacher-785fd6545b-wb6rd 1/1 Running 0 90m
csi-provisioner-8658f9bd9c-5rj72 1/1 Running 0 90m
csi-provisioner-8658f9bd9c-8l2mm 1/1 Running 0 90m
csi-provisioner-8658f9bd9c-dc6z8 1/1 Running 0 90m
csi-resizer-68c4c75bf5-9jqqq 1/1 Running 0 90m
csi-resizer-68c4c75bf5-zljnc 1/1 Running 0 90m
csi-resizer-68c4c75bf5-zsxnc 1/1 Running 0 90m
csi-snapshotter-7c466dd68f-52c9c 1/1 Running 0 90m
csi-snapshotter-7c466dd68f-fsrrx 1/1 Running 0 90m
csi-snapshotter-7c466dd68f-rr6lm 1/1 Running 0 90m
engine-image-ei-68f17757-bq55k 1/1 Running 0 90m
engine-image-ei-68f17757-prcx6 1/1 Running 0 90m
instance-manager-544a56b5046e48a6d0f28f76191f9c69 1/1 Running 0 90m
instance-manager-66c416b8fb1e0289ae85f2edca30bccc 1/1 Running 0 90m
longhorn-csi-plugin-hzt6t 3/3 Running 0 90m
longhorn-csi-plugin-x56sr 3/3 Running 0 90m
longhorn-driver-deployer-7d5dc67667-wgbm4 1/1 Running 0 90m
longhorn-manager-dw65w 1/1 Running 0 90m
longhorn-manager-x487m 1/1 Running 0 90m
longhorn-ui-85cc67494f-7fcfk 1/1 Running 0 90m
longhorn-ui-85cc67494f-l5kw2 1/1 Running 0 90m
2.1.Longhorn使用
注:这里如果部署完成
创建pod:
# https://raw.githubusercontent.com/longhorn/longhorn/v1.5.3/examples/pod_with_pvc.yaml
cat > pod_with_pvc.yaml <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-volv-pvc
namespace: default
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: Pod
metadata:
name: volume-test
namespace: default
spec:
restartPolicy: Always
containers:
- name: volume-test
image: nginx:stable-alpine
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- ls
- /data/lost+found
initialDelaySeconds: 5
periodSeconds: 5
volumeMounts:
- name: volv
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: volv
persistentVolumeClaim:
claimName: longhorn-volv-pvc
EOF
cat pod_with_pvc.yaml | kubectl apply -f -
查看资源创建情况:
kubectl get pvc
longhorn-volv-pvc Bound pvc-4ad1865e-6d68-4f24-af7d-6020c2ed1978 2Gi RWO longhorn 4m17s
kubectl get pod | grep volume-test
volume-test 1/1 Running 0 4m42s
文章:
标签:INFO,csi,部署,iscsi,使用,Running,longhorn,Longhorn,90m From: https://www.cnblogs.com/-k8s/p/17925958.html