الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 11الاسم في الدورة: Storage

Give pods persistent storage

Container files are lost when a pod is replaced. PersistentVolumes (PV) are storage in the cluster; PersistentVolumeClaims (PVC) are requests for it; StorageClasses create PVs on demand (dynamic provisioning).

  • 6 الدروس
  • 1 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

المهارات في هذا الفصل

  • StorageClasses والتوفير الديناميكي و PV و PVC

11.1

Know the storage objects

The app asks with a PVC; Kubernetes binds it to a matching PV (existing or newly created).

ObjectWho makes itMeaning
StorageClassAdminA type of storage + its provisioner
PersistentVolumeAdmin or provisionerA piece of real storage
PersistentVolumeClaimApp team"I need 10 Gi, ReadWriteOnce"
Volume in the podApp teamMounts the PVC into a container

11.2

Know access modes and reclaim policies

Access modes say how many nodes may mount the volume; the reclaim policy says what happens after the PVC is deleted.

Access modeShortMeaning
ReadWriteOnceRWORead-write by one node
ReadOnlyManyROXRead-only by many nodes
ReadWriteManyRWXRead-write by many nodes (NFS, CephFS, Azure Files)
ReadWriteOncePodRWOPRead-write by one pod only
Reclaim policyAfter the PVC is deleted
DeleteThe PV and the real disk are deleted (default for dynamic)
RetainThe PV stays (status Released); an admin cleans up by hand

11.3

Use dynamic provisioning

With a StorageClass, a PVC alone is enough — the provisioner creates the PV.

storageclass.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast
  annotations: { storageclass.kubernetes.io/is-default-class: "true" }
provisioner: rancher.io/local-path
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: db-data, namespace: shop }
spec:
  accessModes: [ReadWriteOnce]
  storageClassName: fast
  resources:
    requests: { storage: 10Gi }
kubectl get storageclass
kubectl get pvc,pv -n shop
kubectl patch pvc db-data -n shop -p '{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'

تذكّر

WaitForFirstConsumer creates the volume only when a pod uses it — in the zone of that pod's node. The PVC stays Pending until then; that is normal.

الأوامر في هذا الدرس

11.4

Create a PV by hand

Without a provisioner, an admin creates PVs; a PVC with the same class, size and mode binds to one.

pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata: { name: pv-logs }
spec:
  capacity: { storage: 5Gi }
  accessModes: [ReadWriteOnce]
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual
  hostPath: { path: /mnt/data/logs }

11.5

Mount the PVC in a pod

The pod refers to the claim, the container mounts the volume.

pod-pvc.yaml
apiVersion: v1
kind: Pod
metadata: { name: db, namespace: shop }
spec:
  containers:
    - name: postgres
      image: postgres:16
      env: [{ name: POSTGRES_PASSWORD, value: change-me }]
      volumeMounts:
        - { name: data, mountPath: /var/lib/postgresql/data }
  volumes:
    - name: data
      persistentVolumeClaim: { claimName: db-data }
kubectl exec db -n shop -- df -h /var/lib/postgresql/data
kubectl describe pvc db-data -n shop

الأوامر في هذا الدرس

11.6

Use other volume types

Not every volume is persistent.

VolumeLives as long asUse
emptyDirThe podScratch space, shared between containers of a pod
hostPathThe nodeNode agents; avoid for apps (pins the pod to a node)
configMap, secretThe objectConfig files
persistentVolumeClaimThe PVCApp data

كل الأوامر في هذا الفصل