longwuxin00 2018-11-05
介绍:
目前动态生成NAS存储卷的实现:在一个已有文件系统上,自动生成子文件系统(子目录),并生成目标存储卷(PV);
生成的PV名字为:pvc-${pv-uid}
镜像介绍:
registry.cn-hangzhou.aliyuncs.com/acs/alicloud-nas-controller:v3.1.0-k8s1.11
部署:
部署前要先创建一个NAS文件系统,并添加挂载点。注意:挂载点需要和集群处于同一个VPC内部。
部署模板中,创建Storageclass的时候可以定义reclaimPolicy类型,可以为Retain或者Delete;
根据自己NAS挂载点修改NFS_SERVER、server的值;
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: alicloud-nas mountOptions: - vers=4.0 provisioner: alicloud/nas reclaimPolicy: Retain --- kind: Deployment apiVersion: extensions/v1beta1 metadata: name: alicloud-nas-controller namespace: kube-system spec: replicas: 1 strategy: type: Recreate template: metadata: labels: app: alicloud-nas-controller spec: tolerations: - effect: NoSchedule operator: Exists key: node-role.kubernetes.io/master - effect: NoSchedule operator: Exists key: node.cloudprovider.kubernetes.io/uninitialized nodeSelector: node-role.kubernetes.io/master: "" serviceAccount: admin containers: - name: alicloud-nas-controller image: registry.cn-hangzhou.aliyuncs.com/acs/alicloud-nas-controller:v3.1.0-k8s1.11 volumeMounts: - mountPath: /persistentvolumes name: nfs-client-root env: - name: PROVISIONER_NAME value: alicloud/nas - name: NFS_SERVER value: 0cd8b4a576-mmi32.cn-hangzhou.nas.aliyuncs.com - name: NFS_PATH value: / volumes: - name: nfs-client-root nfs: server: 0cd8b4a576-mmi32.cn-hangzhou.nas.aliyuncs.com path: /
测试:
apiVersion: apps/v1beta1 kind: StatefulSet metadata: name: web spec: serviceName: "nginx" replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:alpine volumeMounts: - mountPath: "/data" name: html volumeClaimTemplates: - metadata: name: html spec: accessModes: - ReadWriteOnce storageClassName: alicloud-nas resources: requests: storage: 2Gi # kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-945ca15d-e0ab-11e8-9d2f-00163e145c08 2Gi RWO Retain Bound default/html-web-0 alicloud-nas-retain 13m pvc-9a162bb2-e0ab-11e8-9d2f-00163e145c08 2Gi RWO Retain Bound
作者:kanjunbao
安装samba实现文件共享一.准备硬盘树莓派默认挂载ntfs格式硬盘只有只读权限,所以需要安装一些工具实现读写功能。sudo chmod 777 /samba我们需要查看硬盘的设备目录。[share]