不操千曲而后晓声,观千剑而后识器。这篇文章主要讲述kubernetes-部署longhorn相关的知识,希望能为你提供帮助。
一、部署longhorn
【kubernetes-部署longhorn】longhorn官网:??https://www.rancher.cn/longhorn??
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.2.3/deploy/longhorn.yaml
kubectl get pods \\
--namespace longhorn-system \\
--watch
kubectl -n longhorn-system get pod
二、测试longhorn
1、查看storageclass
root@xirang:~# kubectl get sc
NAMEPROVISIONERRECLAIMPOLICYVOLUMEBINDINGMODEALLOWVOLUMEEXPANSIONAGE
longhorndriver.longhorn.ioDeleteImmediatetrue28s
2、创建pod、验证是否是pvc---->
storageclass---->
pv
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
3、查看pv、pvc
root@xirang:~# kubectl get pods
NAMEREADYSTATUSRESTARTSAGE
volume-test1/1Running05m14s
root@xirang:~# kubectl get pv
NAMECAPACITYACCESS MODESRECLAIM POLICYSTATUSCLAIMSTORAGECLASSREASONAGE
pvc-19708d1d-7cef-4800-9a78-b58dabcebe152GiRWODeleteBounddefault/longhorn-volv-pvclonghorn5m14s
root@xirang:~# kubectl get pvc
NAMESTATUSVOLUMECAPACITYACCESS MODESSTORAGECLASSAGE
longhorn-volv-pvcBoundpvc-19708d1d-7cef-4800-9a78-b58dabcebe152GiRWOlonghorn5m19s
4、查看数据存储目录,每个节点都会保存一份pvc数据的副本
[root@node02 ~]# ls /var/lib/longhorn/replicas/
pvc-19708d1d-7cef-4800-9a78-b58dabcebe15-d2569ce8
5、访问Longhorn UI
#找到拥有app=longhorn-ui标签的pod
kubectl -n longhorn-system get svc -l app=longhorn-ui
#创建service
apiVersion: v1
kind: Service
metadata:
name: longhorn-ui-svc
spec:
type: NodePort
selector:
app: longhorn-ui
ports:
- protocol: TCP
port: 80
targetPort: 8000
通过http://node_ip:nodeport访问
推荐阅读
- #yyds干货盘点#Linux常见面试题之文件管理命令
- MYSQL事务超全知识总结#yyds干货盘点#
- 用pipeline来实现一个自由风格的构建
- 有关 CentOS 7 minimal 初始配置
- #yyds干货盘点#害,这恼人的BOM头
- #yyds干货盘点#--ELK-Elasticsearch介绍-1
- #yyds干货盘点#Windows Server之CA证书服务器看不到"web服务器"模板
- Ubuntu 18.04.1安装k8s的时候,提示缺少依赖包kubernetes-cni (= 0.7.5)
- 如何在WordPress分页上向上一个/下一个添加类( (paginate_links))