<

Starting to Learn Kubernetes a Step Behind - 11. config&storage Part 2 -

Story

  1. Starting to Learn Kubernetes a Step Behind - 01. Environment Selection -
  2. Starting to Learn Kubernetes a Step Behind - 02. Docker For Mac -
  3. Starting to Learn Kubernetes a Step Behind - 03. Raspberry Pi -
  4. Starting to Learn Kubernetes a Step Behind - 04. kubectl -
  5. Starting to Learn Kubernetes a Step Behind - 05. workloads Part 1 -
  6. Starting to Learn Kubernetes a Step Behind - 06. workloads Part 2 -
  7. Starting to Learn Kubernetes a Step Behind - 07. workloads Part 3 -
  8. Starting to Learn Kubernetes a Step Behind - 08. discovery&LB Part 1 -
  9. Starting to Learn Kubernetes a Step Behind - 09. discovery&LB Part 2 -
  10. Starting to Learn Kubernetes a Step Behind - 10. config&storage Part 1 -
  11. Starting to Learn Kubernetes a Step Behind - 11. config&storage Part 2 -
  12. Starting to Learn Kubernetes a Step Behind - 12. Resource Limits -
  13. Starting to Learn Kubernetes a Step Behind - 13. Health Checks and Container Lifecycle -
  14. Starting to Learn Kubernetes a Step Behind - 14. Scheduling -
  15. Starting to Learn Kubernetes a Step Behind - 15. Security -
  16. Starting to Learn Kubernetes a Step Behind - 16. Components -

Last time

In Starting to Learn Kubernetes Late - 10. config&storage Part 1 -, we learned about config. This time, we will learn about storage.

Volume and PresistentVolume

A Volume refers to a predetermined available volume. You cannot delete or create new volumes here. PresistentVolume refers to a persistent volume located externally. Here, you can delete or create new volumes. For stateful things like DB, use PresistentVolume. For temporary things, do you use Volume?

※ PresistentVolumeClaim is a resource for assigning PresistentVolume.

Types of Volume

The types of Volume introduced in the book (Kubernetes Complete Guide) are as follows:

  • emptyDir
    • Uses temporary disk space
    • When the pod is deleted, emptyDir is also deleted
    • Cannot specify the mount destination
  • hostPath
    • A version of emptyDir where you can specify the mount destination
  • downwardAPI
    • Mounts a file that has placed Pod information as a file
  • projected
    • Creates a directory that combines secret/configMap/downwardAPI/serviceAccountToken and mounts it

types-of-volumes

Since you can't keep the Volume, you have to be careful when deleting the Pod. If you save logs as files, is it good to have a temporary Volume? However, you have to regularly move it to external storage, which is a hassle. (After all, it's best to stream logs and flow them to an external service)

As a product, there's not much use...?

Types of PresistentVolume

Use an external persistent volume. For example, the following types are available:

  • GCE Persistent Disk
  • AWS Elastic Block Store
  • NFS
  • iSCSI
  • Ceph
  • OpenStack Cinder
  • GlusterFS

In Starting to Learn Kubernetes Late - 06. workloads Part 2 -, we used NFS. The method of creating a PersistentVolume varies depending on the external persistent volume, but there seem to be common points, so I'll write about them here.

  • Label
    • Make it easier to specify by labeling the PersistentVolume
  • Capacity
    • The capacity required by the Volume. Assigned from the smallest capacity.
  • Access Mode
    • ReadWriteOnce
      • Read/Write is possible from a single node
    • ReadOnlyMany
      • Read is possible from multiple nodes
    • ReadWriteMany
      • Read/Write is possible from multiple nodes
  • Reclaim Policy
    • Policy on whether to discard or reuse the Volume after use
      • Delete
        • Delete the entity of the PersistentVolume
      • Retain
        • Keep the entity of the PersistentVolume without leaving it
        • Not mounted again
      • Recycle
        • Delete the data of the PersistentVolume and make it reusable
        • Mounted again
        • (Scheduled to be abolished, use DynamicProvisioning)
  • StorageClass
    • The type of storage provided by each provider
      • Basically, it is created automatically

PersistentVolumeClaim

In fact, to use PresistentVolume, you need to make a request with PresistentVolumeClaim. The necessary items are as follows:

  • Label Selector
    • Filtering by label
  • Capacity
    • The capacity you are asking for
  • Access Mode
    • Refer to the Access Mode of PresistentVolume
  • StorageClass
    • Refer to the StorageClass of PresistentVolume

If the Volume that meets the requirements was RetainPolicy, it will become "Released" when the Claim is deleted.

Finally

This time, it felt like I just wrote the book as it is. What I actually tried is Starting to learn Kubernetes a step behind - 06. workloads part 2 -. Well, I thought it would be better not to get too deeply involved. Next time is here.

If it was helpful, support me with a ☕!

Share

Related tags