kuberneters采用helm部署sig-storage-local-static-provisioner

https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner/tags

kuberneters采用helm部署sig-storage-local-static-provisioner 下载并解压tar包

wget https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner/archive/v2.3.4.tar.gz
tar -zxvf v2.3.4.tar.gz

进入解压目录后创建storageclass

kubectl create -f deployment/kubernetes/example/default_example_storageclass.yaml

查看storageclass

kubectl get sc

kuberneters采用helm部署sig-storage-local-static-provisioner

创建目录/mnt/fast-disks

mkdir /mnt/fast-disks

安装local-volume-provisioner

查看文件系统

df -h -T

kuberneters采用helm部署sig-storage-local-static-provisioner

修改helm/provisioner/values.yaml

fsTyp默认为ext4格式,默认hostDir为/mnt/fast-disks,所有的文件系统都要挂载到该目录下

kuberneters采用helm部署sig-storage-local-static-provisioner

生成yaml文件

helm template ./helm/provisioner > deployment/kubernetes/provisioner_generated.yaml

部署provisioner

kubectl apply -f deployment/kubernetes/provisioner_generated.yaml

查看部署pod

kubectl get pods -o wide

kuberneters采用helm部署sig-storage-local-static-provisioner

由于一个挂载点对应一个pv,为了创建多个pv可以使用mount --bind方式,mount bind方式挂载

mount bind的一种用法,用于本地没有多余磁盘的情况

创建mount-bind.sh  shell脚本执行,配置完成后会自动创建pv

for i in $(seq 1 5); do
  mkdir -p /mnt/fast-disks-bind/vol${i}
  mkdir -p /mnt/fast-disks/vol${i}
  mount --bind /mnt/fast-disks-bind/vol${i} /mnt/fast-disks/vol${i}
done

# 配置/etc/fstab永久挂载
for i in $(seq 1 5); do
  echo /mnt/fast-disks-bind/vol${i} /mnt/fast-disks/vol${i} none bind 0 0 | sudo tee -a /etc/fstab
done

kuberneters采用helm部署sig-storage-local-static-provisioner

kubectl get pv

kuberneters采用helm部署sig-storage-local-static-provisioner

验证 创建pod,定义pvc申请使用pv 

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: local-test
spec:
  serviceName: "local-service"
  replicas: 1
  selector:
    matchLabels:
      app: local-test
  template:
    metadata:
      labels:
        app: local-test
    spec:
      containers:
      - name: test-container
        image: busybox
        command:
        - "/bin/sh"
        args:
        - "-c"
        - "sleep 100000"
        volumeMounts:
        - name: local-vol
          mountPath: /tmp
  volumeClaimTemplates:
  - metadata:
      name: local-vol
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "fast-disks"
      resources:
        requests:
          storage: 2Gi

kuberneters采用helm部署sig-storage-local-static-provisioner

上一篇:pandas to_csv保存中文乱码问题


下一篇:Kubernetes 贡献指南