0Pricing
Docker & Kubernetes for Developers · 강의

영구 볼륨 및 영구 볼륨 클레임

PV와 PVC를 사용하여 Kubernetes에서 스토리지를 동적으로 프로비저닝하고 사용하는 방법을 이해합니다.

영구 볼륨 및 영구 볼륨 클레임은(는) CoddyKit의 무료 Docker & Kubernetes for Developers 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Docker & Kubernetes for Developers 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Ephemeral Pods, Persistent Data

In Kubernetes, Pods are designed to be temporary and replaceable. If a Pod crashes or is rescheduled, any data stored directly within it is lost.

This ephemeral nature is great for stateless applications, but what about applications that need to store data persistently, like databases or file servers?

Introducing Persistent Volumes

A Persistent Volume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically by Kubernetes.

It's an abstraction of the underlying storage (like a cloud disk, NFS share, or local disk), making it available for use by Pods without them needing to know the storage's specifics.

PV Capacity & Access Modes

Each PV has specific characteristics:

  • Capacity: The size of the storage, e.g., 10Gi.
  • Access Modes: How the storage can be mounted by Pods.
  • Reclaim Policy: What happens to the volume after a Pod is done using it.

These properties help Kubernetes match storage requests to available volumes.

How Pods Access Storage

PV Access Modes define how the volume can be mounted:

  • ReadWriteOnce (RWO): The volume can be mounted as read-write by a single node.
  • ReadOnlyMany (ROX): The volume can be mounted as read-only by many nodes.
  • ReadWriteMany (RWX): The volume can be mounted as read-write by many nodes.

Not all storage types support all modes. For example, a local disk typically only supports RWO.

Handling Released PVs

A PV's Reclaim Policy dictates what happens to the underlying storage when the PV is released from its claim:

  • Retain: Manual reclamation. Data remains, administrator must manually delete.
  • Delete: The underlying storage is automatically deleted along with the PV. This is common for dynamically provisioned volumes.
  • Recycle: (Deprecated) Wipes the volume and makes it available again.

Retain is useful for critical data that needs manual review before deletion.

Requesting Persistent Storage

A Persistent Volume Claim (PVC) is a request for storage by a user or application.

Think of it like a request for a specific type and size of storage. Instead of directly interacting with PVs, Pods request storage through PVCs.

PVCs provide a layer of abstraction, allowing developers to request storage without knowing the underlying infrastructure details.

Matching Storage Requests

When a PVC is created, Kubernetes tries to find a suitable PV to bind it to. This process is called binding.

It looks for PVs that meet the PVC's requirements:

  • Capacity (size)
  • Access Modes
  • Storage Class (if specified)

Once bound, the PV is exclusively reserved for that PVC.

Defining a Basic PV

Here's how you might define a simple hostPath Persistent Volume. This type uses a directory on the node's filesystem, primarily for single-node testing.

Try running this example (kubectl apply -f pv.yaml):

apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/mnt/data"

Requesting Storage with a PVC

Now, let's create a Persistent Volume Claim that requests 1Gi of storage with ReadWriteOnce access. It will bind to our my-pv if available.

Try running this example (kubectl apply -f pvc.yaml):

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Attaching PVC to a Pod

Finally, let's see how a Pod can use the storage provided by our PVC. We reference the PVC in the Pod's volumes section and then mount it into a container.

Try running this example (kubectl apply -f pod.yaml):

apiVersion: v1
kind: Pod
metadata:
  name: my-app-pod
spec:
  volumes:
    - name: my-storage
      persistentVolumeClaim:
        claimName: my-pvc
  containers:
    - name: my-container
      image: busybox
      command: ["sh", "-c", "echo 'Hello from CoddyKit!' > /data/message.txt && sleep 3600"]
      volumeMounts:
        - mountPath: "/data"
          name: my-storage

PV vs. PVC Roles

Understanding the distinct roles of Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) is crucial for managing storage in Kubernetes.

Which statement accurately describes the primary role of a Persistent Volume (PV)?

Recap: Persistent Storage

Great job! You've learned how Kubernetes manages persistent storage:

  • Persistent Volumes (PVs) abstract physical storage resources.
  • Persistent Volume Claims (PVCs) are user requests for storage.
  • PVs have capacity, access modes (RWO, ROX, RWX), and reclaim policies (Retain, Delete).
  • PVCs bind to available PVs, and Pods then use PVCs to mount storage.

This system allows applications to reliably store data, even when Pods are recreated or moved.

자주 묻는 질문

“영구 볼륨 및 영구 볼륨 클레임” 강의는 무료인가요?

네 — “영구 볼륨 및 영구 볼륨 클레임” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Docker & Kubernetes for Developers 강의 전체를 잠금 해제할 수 있습니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.

“영구 볼륨 및 영구 볼륨 클레임”에서 뭘 배우나요?

PV와 PVC를 사용하여 Kubernetes에서 스토리지를 동적으로 프로비저닝하고 사용하는 방법을 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 Docker & Kubernetes for Developers을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Docker & Kubernetes for Developers을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Docker & Kubernetes for Developers은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“영구 볼륨 및 영구 볼륨 클레임” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Docker & Kubernetes for Developers 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Docker & Kubernetes for Developers 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 영구 볼륨 및 영구 볼륨 클레임
  2. StatefulSets를 활용한 상태 저장 애플리케이션 관리
  3. 구성을 위한 ConfigMaps 및 Secrets
  4. StorageClasses와 동적 프로비저닝
← Docker & Kubernetes for Developers(으)로 돌아가기