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
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
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