前提条件:
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:
persistentvolume/pv-nas-static created
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:
persistentvolumeclaim/pvc-nas created
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实例:
pod/test-pvc-nas created
NAME READY STATUS RESTARTS AGE test-pvc-nas 1/1 Running 0 76s
root@test-pvc-nas:/# ls /cache-test/ subpath
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。