Storages in Kubernetes

Kubernetes Fundamental | Understanding of Storages
이민석's avatar
Mar 23, 2024
Storages in Kubernetes

Introduction

Thank you for clicking through to my arcticle. I've been a DevOps engineer for 2 years in dev-team of 7 engineers.

My name is MINSEOK, LEE, but I use Unchaptered as an alias on the interenet. So, you can call me anythings "MINSEOK, LEE" or "Unchaptered" to ask something.


 

Empemeral Volume(EV), emptyDir

References

  1. All data inside the Pod is deleted when the Pod is stopped.
    → The pods were stateless applications.

Persistent Volume(PV), hostPath or PV/PVC

References

  1. Dynamic Provisioning

    Ability to automatically mount and attach volumes to Pods when they are created

  2. Reclaim Policy

    1. When you are done using a persistent volume, you can separately set how you want it to be initialized. This is called a Recalim Policy in Kubernetes.

    2. Sup Types : Retain, Delete, Recylce(deprecated)

Lifecycle of Storage

References

  • PV

    • PV is kubernetes cluster's storage that administrators can provision to follow users' storage requests

  • PVC

    • PVC is spec to request about PV.

    • It defines storage, access mode to request PV.

  • LIfeCycle

    • Because PVs and PVCs are so closely related, we can distinguish their states through a life cycle. Below picture shows lifecycle steps of PVs and PVCs.

    • Provisioning

      • Steps to provision PV.

      • Sup Types : Static Type(Pre Provision), Dynamic Type(On Demand)

    • Binding

      • Bind between PV and PVC.

      • All binding is 1:1 binding.

      • If PV isn't prepared for specific PVC, the PVC is waiting for binding PV.

    • Using

      • The PVC is set up in the Pod, and the Pod recognized and uses the VPC as a volume

    • Recaliming

      • Retain

      • Delete

      • Recycle(deprecated)?

CSI(Container Storage Interface)

References

Why we needs CSI for kubernetes?
According to AWS EBS provisioner is deployed to follow Kubernetes release lifecycle, you must upgrade kubernetes' version to use new func of provisioner.
Therefore, the kubernetes developer removed the build-in provisioner inside kubernetes' tree. And then, the kubernetes developer made dynamic provisioning available via a separate controller pod. This is the CSI driver.

  1. Provisioner

    1. The provisioner monitors the creation of PVCs in the cluster and is responsible for creating PVs when they are created.

  2. Attacher

    1. The attacher is responsible for mounting the PV in its container when a Pod wants to use the PVC.

  3. Controller

    1. The controller are responsible for creating and deleting volumes on storage servers for use by Kubernetes containers.

  4. NodeServer

    1. The NodeServer are responsible for making the environment ready to mount storage volumes on the nodes where Pods will be deployed.

More information of advanced CSI driver such as SPDK storage server, check this documents.

Conclusion

  1. Defuault Volume setting of pod is Empemeral(Temporal) Storage.

  2. If you want persistent storage, you must use PV/PVC or hostPath.

  3. The hostPath isn't secure.

Share article

Unchaptered