开发者社区> 问答> 正文

如何静态挂载NAS(PVC)?

如何静态挂载NAS(PVC)?

展开
收起
小天使爱美 2020-03-20 17:59:49 1022 0
1 条回答
写回答
取消 提交回答
  • 前提条件:

    K8S集群中正确部署了virtual-kubelet(serverless Kubernetes 默认集成) 已经在virtual-kubelet配置的同VSwitch创建NAS挂载点 步骤1. 创建PV 将以下内容保存为nas_pv_static.yaml:

    apiVersion: v1 kind: PersistentVolume metadata: name: pv-nas-static spec: capacity: storage: 5Gi storageClassName: nas persistentVolumeReclaimPolicy: Recycle accessModes: - ReadWriteMany flexVolume: driver: "alicloud/nas" options: server: "1a93e496ef-fuu9.cn-beijing.nas.aliyuncs.com" path: "/" vers: "3" 使用kubectl创建PV:

    kubectl create -f nas_pv_static.yaml

    persistentvolume/pv-nas-static created

    kubectl get pv pv-nas-static

    NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pv-nas-static 5Gi RWX Recycle Available nas 97s 步骤2. 创建PVC 将以下内容保存为nas_pvc_static.yaml:

    apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-nas spec: accessModes: - ReadWriteMany storageClassName: nas resources: requests: storage: 5Gi 使用kubectl创建PVC:

    kubectl create -f nas_pvc_static.yaml

    persistentvolumeclaim/pvc-nas created

    kubectl get pvc pvc-nas

    NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE pvc-nas Bound pv-nas-static 5Gi RWX nas 7s 步骤3. 创建Pod 将以下内容保存为pod.yaml:

    apiVersion: v1 kind: Pod metadata: name: test-pvc-nas spec: nodeName: virtual-kubelet containers: - image: nginx:latest name: test-container volumeMounts: - mountPath: /cache-test name: cache-volume volumes: - name: cache-volume persistentVolumeClaim: claimName: pvc-nas 使用kubectl创建ECI实例:

    kubectl create -f pod.yaml

    pod/test-pvc-nas created

    kubectl get pod test-pvc-nas

    NAME READY STATUS RESTARTS AGE test-pvc-nas 1/1 Running 0 76s

    kubectl exec -it test-pvc-nas bash

    root@test-pvc-nas:/# ls /cache-test/ subpath

    2020-03-20 18:00:43
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云上高性能NAS的技术揭秘和行业应用 立即下载
高性能NAS助力企业业务上云 立即下载
云上NAS:云上高性能NAS技术揭秘和行业应用 立即下载