PV銆丳VC鍜孲torageClass

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PV銆丳VC鍜孲torageClass相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/auto' title='auto'>auto   閫傚悎   write   琛ㄧず   瀹氬埗   oca   attr   created   瀛樺偍   

涓婁竴绔犺妭浠嬬粛鐨凥ostPath鏄竴绉嶆寔涔呭寲瀛樺偍锛屼絾鏄疕ostPath鐨勫唴瀹规槸瀛樺偍鍦ㄨ妭鐐逛笂锛屽鑷村彧閫傚悎璇诲彇銆?/p>

濡傛灉瑕佹眰Pod閲嶆柊璋冨害鍚庝粛鐒惰兘浣跨敤涔嬪墠璇诲啓杩囩殑鏁版嵁锛屽氨鍙兘浣跨敤缃戠粶瀛樺偍浜嗭紝缃戠粶瀛樺偍绉嶇被闈炲父澶氫笖鏈変笉鍚岀殑浣跨敤鏂规硶锛岄€氬父涓€涓簯鏈嶅姟鎻愪緵鍟嗚嚦灏戞湁鍧楀瓨鍌ㄣ€佹枃浠跺瓨鍌ㄣ€佸璞″瓨鍌ㄤ笁绉嶏紝濡傚崕涓轰簯鐨凟VS銆丼FS鍜孫BS銆侹ubernetes瑙e喅杩欎釜闂鐨勬柟寮忔槸鎶借薄浜哖V锛圥ersistentVolume锛夊拰PVC锛圥ersistentVolumeClaim锛夋潵瑙h€﹁繖涓棶棰橈紝浠庤€岃浣跨敤鑰呬笉鐢ㄥ叧蹇冨叿浣撶殑鍩虹璁炬柦锛屽綋闇€瑕佸瓨鍌ㄨ祫婧愮殑鏃跺€欙紝鍙鍍廋PU鍜屽唴瀛樹竴鏍凤紝澹版槑瑕佸灏戝嵆鍙€?/p>

  • PV锛歅V鎻忚堪鐨勬槸鎸佷箙鍖栧瓨鍌ㄥ嵎锛屼富瑕佸畾涔夌殑鏄竴涓寔涔呭寲瀛樺偍鍦ㄥ涓绘満涓婄殑鐩綍锛屾瘮濡備竴涓狽FS鐨勬寕杞界洰褰曘€?/li>
  • PVC锛歅VC鎻忚堪鐨勬槸Pod鎵€甯屾湜浣跨敤鐨勬寔涔呭寲瀛樺偍鐨勫睘鎬э紝姣斿锛孷olume瀛樺偍鐨勫ぇ灏忋€佸彲璇诲啓鏉冮檺绛夌瓑銆?br/>Kubernetes绠$悊鍛樿缃ソ缃戠粶瀛樺偍鐨勭被鍨嬶紝鎻愪緵瀵瑰簲鐨凱V鎻忚堪绗﹂厤缃埌Kubernetes锛屼娇鐢ㄨ€呴渶瑕佸瓨鍌ㄧ殑鏃跺€欏彧闇€瑕佸垱寤篜VC锛岀劧鍚庡湪Pod涓娇鐢╒olume鍏宠仈PVC锛屽嵆鍙Pod浣跨敤鍒板瓨鍌ㄨ祫婧愶紝瀹冧滑涔嬮棿鐨勫叧绯诲涓嬪浘鎵€绀恒€?/li>

鍥? PVC缁戝畾PV

鎶€鏈浘鐗? src=

CSI

Kubernetes鎻愪緵浜咰SI鎺ュ彛锛圕ontainer Storage Interface锛屽鍣ㄥ瓨鍌ㄦ帴鍙o級锛屽熀浜嶤SI杩欏鎺ュ彛锛屽彲浠ュ紑鍙戝畾鍒跺嚭CSI鎻掍欢锛屼粠鑰屾敮鎸佺壒瀹氱殑瀛樺偍锛岃揪鍒拌В鑰︾殑鐩殑銆備緥濡傚湪Namespace锛氳祫婧愬垎缁勪腑鐪嬪埌鐨刱ube-system鍛藉悕绌洪棿涓媏verest-csi-controller鍜宔verest-csi-driver灏辨槸鍗庝负浜慍CE寮€鍙戝瓨鍌ㄦ帶鍒跺櫒鍜岄┍鍔ㄣ€傛湁浜嗚繖浜涢┍鍔ㄥ氨鍙互浣跨敤鍗庝负浜戜笂鐨凟VS銆丼FS銆丱BS瀛樺偍銆?/p>

$ kubectl get po --namespace=kube-system
NAME                                      READY   STATUS    RESTARTS   AGE
everest-csi-controller-6d796fb9c5-v22df   2/2     Running   0          9m11s
everest-csi-driver-snzrr                  1/1     Running   0          12m
everest-csi-driver-ttj28                  1/1     Running   0          12m
everest-csi-driver-wtrk6                  1/1     Running   0          12m

PV

鏉ョ湅涓€涓婸V鏄浣曟弿杩版寔涔呭寲瀛樺偍锛屼緥濡傚湪鍗庝负浜慡FS涓垱寤轰簡涓€涓枃浠跺瓨鍌紝杩欎釜鏂囦欢瀛樺偍ID涓?8e4a4fd-d759-444b-8265-20dc66c8c502锛屾寕杞藉湴鍧€涓簊fs-nas01.cn-north-4b.myhuaweicloud.com:/share-96314776銆傚鏋滄兂鍦–CE涓娇鐢ㄨ繖涓枃浠跺瓨鍌紝鍒欓渶瑕佸厛鍒涘缓涓€涓狿V鏉ユ弿杩拌繖涓瓨鍌紝濡備笅鎵€绀恒€?/p>

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-example
spec:
  accessModes:
  - ReadWriteMany                      # 璇诲啓妯″紡
  capacity:
    storage: 10Gi                      # 瀹氫箟PV鐨勫ぇ灏?  csi:
    driver: nas.csi.everest.io         # 澹版槑浣跨敤鐨勯┍鍔?                  
    fsType: nfs                        # 瀛樺偍绫诲瀷
    volumeAttributes:
      everest.io/share-export-location: sfs-nas01.cn-north-4b.myhuaweicloud.com:/share-96314776   # 鎸傝浇鍦板潃
    volumeHandle: 68e4a4fd-d759-444b-8265-20dc66c8c502                                            # 瀛樺偍ID

杩欓噷csi涓嬮潰鐨勫唴瀹瑰氨鏄崕涓轰簯CCE涓壒瀹氱殑瀛楁锛屽湪鍏朵粬鍦版柟鏃犳硶浣跨敤銆?/p>

涓嬮潰鍒涘缓杩欎釜PV骞舵煡鐪嬨€?/p>

$ kubectl create -f pv.yaml
persistentvolume/pv-example created

$ kubectl get pv
NAME                 CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM    STORAGECLASS   REASON   AGE
pv-example           10Gi       RWX            Retain           Available                                    4s

RECLAIM POLICY鏄寚PV鐨勫洖鏀剁瓥鐣ワ紝Retain琛ㄧずPVC琚噴鏀惧悗PV缁х画淇濈暀銆係TATUS鍊间负Available锛岃〃绀篜V澶勪簬鍙敤鐨勭姸鎬併€?/p>

PVC

PVC鍙互缁戝畾涓€涓狿V锛岀ず渚嬪涓嬨€?/p>

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-example
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 10Gi              # 澹版槑瀛樺偍鐨勫ぇ灏?  volumeName: pv-example         # PV鐨勫悕绉?/code>

鍒涘缓PVC骞舵煡鐪嬨€?/p>

$ kubectl create -f pvc.yaml
persistentvolumeclaim/pvc-example created

$ kubectl get pvc
NAME          STATUS   VOLUME       CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pvc-example   Bound    pv-example   10Gi       RWX                           9s

杩欓噷鍙互鐪嬪埌鐘舵€佹槸Bound锛孷OLUME鏄痯v-example锛岃〃绀篜VC宸茬粡缁戝畾浜哖V銆?/p>

鍐嶆潵鐪嬩笅PV銆?/p>

$ kubectl get pv
NAME          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                  STORAGECLASS   REASON   AGE
pv-example    10Gi       RWX            Retain           Bound    default/pvc-example                            50s

鍙互鐪嬪埌鐘舵€佷篃鍙樻垚浜咮ound锛孋LAIM鏄痙efault/pvc-example锛岃〃绀鸿繖涓狿V缁戝畾浜哾efault鍛藉悕绌洪棿涓嬬殑pvc-example杩欎釜PVC銆?/p>

杩欓噷涓€涓瘮杈冩湁鎰忔€濈殑鍦版柟鏄疌LAIM鏄痙efault/pvc-example锛屼负浠€涔堣鏄剧ずdefault鍛紝杩欐槸鍥犱负PV鏄泦缇ょ骇鍒殑璧勬簮锛屽苟涓嶅睘浜庢煇涓懡鍚嶇┖闂达紝鑰孭VC鏄懡鍚嶇┖闂寸骇鍒殑璧勬簮锛孭V鍙互涓庝换浣曞懡鍚嶇┖闂寸殑PVC璧勬簮缁戝畾銆?/p>

鍥? PV涓嶱VC

鎶€鏈浘鐗? src=

StorageClass

涓婅妭璇寸殑PV鍜孭VC鏂规硶铏界劧鑳藉疄鐜板睆钄藉簳灞傚瓨鍌紝浣嗘槸PV鍒涘缓姣旇緝澶嶆潅锛堝彲浠ョ湅鍒癙V涓璫si瀛楁鐨勯厤缃緢楹荤儲锛夛紝閫氬父閮芥槸鐢遍泦缇ょ鐞嗗憳绠$悊锛岃繖闈炲父涓嶆柟渚裤€?/p>

Kubernetes瑙e喅杩欎釜闂鐨勬柟娉曟槸鎻愪緵鍔ㄦ€侀厤缃甈V鐨勬柟娉曪紝鍙互鑷姩鍒汸V銆傜鐞嗗憳鍙互閮ㄧ讲PV閰嶇疆鍣紙provisioner锛夛紝鐒跺悗瀹氫箟瀵瑰簲鐨凷torageClass锛岃繖鏍峰紑鍙戣€呭湪鍒涘缓PVC鐨勬椂鍊欏氨鍙互閫夋嫨闇€瑕佸垱寤哄瓨鍌ㄧ殑绫诲瀷锛孭VC浼氭妸StorageClass浼犻€掔粰PV provisioner锛岀敱provisioner鑷姩鍒涘缓PV銆傚CCE灏辨彁渚沜si-disk銆乧si-nas銆乧si-obs绛塖torageClass锛屽湪澹版槑PVC鍔犱笂StorageClassName锛屽氨鍙互鑷姩鍒涘缓PV锛屽苟鑷姩鍒涘缓搴曞眰鐨勫瓨鍌ㄨ祫婧愩€?/p>

璇存槑锛?br/>涓嬮潰鏄互CCE 1.15鍙婁互涓婄増鏈泦缇や娇鐢ㄦ柟娉曚妇渚嬶紝1.13浠ュ強涔嬪墠鐗堟湰闆嗙兢涓婁娇鐢ㄦ柟娉曟湁宸紓锛屽叿浣撹鍙傝浣跨敤kubectl鍒涘缓鏂囦欢瀛樺偍銆?/p>

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name:  pvc-sfs-auto-example
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
  storageClassName: csi-nas        # StorageClass

鍒涘缓PVC骞舵煡鐪婸VC鍜孭V銆?/p>

$ kubectl create -f pvc2.yaml
persistentvolumeclaim/pvc-sfs-auto-example created

$ kubectl get pvc
NAME                   STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pvc-sfs-auto-example   Bound    pvc-1f1c1812-f85f-41a6-a3b4-785d21063ff3   10Gi       RWX            csi-nas        29s

$ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                         STORAGECLASS   REASON   AGE
pvc-1f1c1812-f85f-41a6-a3b4-785d21063ff3   10Gi       RWO            Delete           Bound    default/pvc-sfs-auto-example  csi-nas                 20s

杩欏彲浠ョ湅鍒颁娇鐢⊿torageClass鍚庯紝涓嶄粎鍒涘缓浜哖VC锛岃€屼笖鍒涘缓浜哖V锛屽苟涓斿皢浜岃€呯粦瀹氫簡銆?/p>

瀹氫箟浜哠torageClass鍚庯紝灏卞彲浠ュ噺灏戝垱寤哄苟缁存姢PV鐨勫伐浣滐紝PV鍙樻垚浜嗚嚜鍔ㄥ垱寤猴紝浣滀负浣跨敤鑰咃紝鍙渶瑕佸湪澹版槑PVC鏃舵寚瀹歋torageClassName鍗冲彲锛岃繖灏卞ぇ澶у噺灏戝伐浣滈噺銆?/p>

鍐嶆璇存槑锛孲torageClassName鐨勭被鍨嬪湪涓嶅悓鍘傚晢鐨勪骇鍝佷笂鍚勪笉鐩稿悓锛岃繖閲屽彧鏄娇鐢ㄤ簡鍗庝负浜戞枃浠跺瓨鍌ㄤ綔涓虹ず渚嬶紝鍏朵綑瀛樺偍绫诲瀷璇峰弬瑙佸瓨鍌ㄦ杩般€?/p>

鍦≒od涓娇鐢≒VC

鏈変簡PVC鍚庯紝鍦≒od涓娇鐢ㄦ寔涔呭寲瀛樺偍灏遍潪甯告柟渚夸簡锛屽湪Pod Template涓殑Volume鐩存帴鍏宠仈PVC鐨勫悕绉帮紝鐒跺悗鎸傝浇鍒板鍣ㄤ箣涓嵆鍙紝濡備笅鎵€绀恒€傜敋鑷冲湪StatefulSet涓繕鍙互鐩存帴澹版槑PVC锛岃鎯呰鍙傝StatefulSet銆?/p>

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers: 
      - image: nginx:alpine
        name: container-0 
        volumeMounts: 
        - mountPath: /tmp                                # 鎸傝浇璺緞
          name: pvc-sfs-example 
      restartPolicy: Always 
      volumes: 
      - name: pvc-sfs-example 
        persistentVolumeClaim: 
          claimName:  pvc-example                       # PVC鐨勫悕绉?/code>

以上是关于PV銆丳VC鍜孲torageClass的主要内容,如果未能解决你的问题,请参考以下文章

SQL涔婭NSERT INTO SELECT 鍜孲ELECT INTO FROM 璇彞

需要示例代码片段帮助

vc++2010设置和c#一样的代码段,vs2010 两下tab设置

Leaflet锛歀atLng銆丩atLngBounds銆丳oint銆丅ounds銆両con

iOS銆丳C銆丄ndroid 鍊煎緱涓嬭浇鐨?46 涓?App

VC ++ WINAPI窗体:找不到标识符(C3861错误)