k8s对接群晖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服务器

修改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

原文链接:https://blog.csdn.net/cloud_engineer/article/details/123943089?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167586359916782429780423%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=167586359916782429780423&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-6-123943089-null-null.blog_rank_default&utm_term=%E9%BB%91%E7%BE%A4%E6%99%96%2C%E7%BE%A4%E6%99%96%2Cnas%2C%E8%9C%97%E7%89%9B%E6%98%9F%E9%99%85%2CDSM%EF%BC%8C%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%2Cipv6%2C%E8%BF%9C%E7%A8%8B%E8%AE%BF%E9%97%AE%2Cwordpress%EF%BC%8C%E5%BB%BA%E7%AB%99%2C%E9%98%BF%E9%87%8C%E4%BA%91%2C%E8%85%BE%E8%AE%AF%E4%BA%91%2C%E5%9F%9F%E5%90%8D%2C%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%2C

上一篇
下一篇