使用NAS动态存储卷创建有状态应用
介绍:
目前动态生成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
相关推荐
wenxuegeng 2020-06-10
tianyayi 2020-05-30
我爱熊猫 2020-05-06
clamzxf 2020-03-28
枫叶上的雨露 2020-02-25
sapliang 2020-01-11
wzxxtt0 2019-12-29
勿六七 2009-09-12
suoluoji 2009-03-26
qlf00 2017-08-15
gfsyy0 2019-09-08
projectharbor 2019-09-06
nydiaxiangxiang 2017-10-17
云端轻躺 2017-08-15
小菜鸟 2014-08-28
liboxue 2012-04-23
sxlongwork 2012-03-06
GimmeS 2011-06-30