k8s csi对接群晖synology-csi使用块存储
1 下载,上传到服务器并解压
百度网盘下载地址:链接: https://pan.baidu.com/s/1duY3D4qAizlgLz9o9nrKmg 密码: tlv8
西瓜视频:https://www.ixigua.com/7080176189909762591?logTag=205c805ad3489b4831cc
tar zxvf synology-csi-1.0.0.tar.gz
2 拷贝生成一个client-info.yml文件,并编辑文件对接群晖nas服务器
cd synology-csi-1.0.0
cp config/client-info-template.yml config/client-info.yml
修改client-info.yml
cat client-info.yml
---
clients:
- host: 192.168.3.231
port: 5000
https: false
username: wangjinxiong
password: 21Vianet!@
#host: # ipv4 address or domain of the DSM
#port: # port for connecting to the DSM
#https: # set this true to use https. you need to specify the port to DSM HTTPS port as well
#username: # username
#password: # password
3 运行脚本安装synology-csi
cd synology-csi-1.0.0
chmod +x scripts/deploy.sh
./scripts/deploy.sh install --all
4 修改SC配置并应用
把默认安装的sc删掉
kubectl delete sc synology-iscsi-storage
vi storage-class.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "false"
name: synostorage
provisioner: csi.san.synology.com
parameters:
fsType: 'ext4'
dsm: '192.168.3.231'
location: '/volume1'
reclaimPolicy: Delete
allowVolumeExpansion: true
重新应用:
kubectl apply -f storage-class.yaml
5 创建一个pvc测试
cat pvc0327.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc0327
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 2Gi
storageClassName: synostorage
kubectl apply -f pvc0327.yaml
查看pvc情况:
# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc0327 Bound pvc-7c6d335c-2f65-40ae-aa56-962ea93ff86e 2Gi RWX synostorage 2s
6 应用statefulsets
cat sts0327.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx-svc"
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
storageClassName: synostorage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
kubectl apply -f sts0327.yaml
登录容器查看挂载情况:
# kubectl exec -it web-0 -- /bin/bash
root@web-0:/# df
Filesystem 1K-blocks Used Available Use% Mounted on
overlay 204372480 3227900 201144580 2% /
tmpfs 65536 0 65536 0% /dev
tmpfs 1931788 0 1931788 0% /sys/fs/cgroup
/dev/mapper/centos-root 204372480 3227900 201144580 2% /etc/hosts
shm 65536 0 65536 0% /dev/shm
/dev/sdb 996780 24 980372 1% /usr/share/nginx/html
tmpfs 1931788 12 1931776 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 1931788 0 1931788 0% /proc/acpi
tmpfs 1931788 0 1931788 0% /proc/scsi
tmpfs 1931788 0 1931788 0% /sys/firmware
root@web-0:/# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
|-sda1 8:1 0 1G 0 part
`-sda2 8:2 0 198.9G 0 part
sdb 8:16 0 1G 0 disk /usr/share/nginx/html
西瓜视频:https://www.ixigua.com/7080176189909762591?logTag=205c805ad3489b4831cc