Starting to Learn Kubernetes a Step Behind - 11. config&storage Part 2 -
Story
- Starting to Learn Kubernetes a Step Behind - 01. Environment Selection -
- Starting to Learn Kubernetes a Step Behind - 02. Docker For Mac -
- Starting to Learn Kubernetes a Step Behind - 03. Raspberry Pi -
- Starting to Learn Kubernetes a Step Behind - 04. kubectl -
- Starting to Learn Kubernetes a Step Behind - 05. workloads Part 1 -
- Starting to Learn Kubernetes a Step Behind - 06. workloads Part 2 -
- Starting to Learn Kubernetes a Step Behind - 07. workloads Part 3 -
- Starting to Learn Kubernetes a Step Behind - 08. discovery&LB Part 1 -
- Starting to Learn Kubernetes a Step Behind - 09. discovery&LB Part 2 -
- Starting to Learn Kubernetes a Step Behind - 10. config&storage Part 1 -
- Starting to Learn Kubernetes a Step Behind - 11. config&storage Part 2 -
- Starting to Learn Kubernetes a Step Behind - 12. Resource Limits -
- Starting to Learn Kubernetes a Step Behind - 13. Health Checks and Container Lifecycle -
- Starting to Learn Kubernetes a Step Behind - 14. Scheduling -
- Starting to Learn Kubernetes a Step Behind - 15. Security -
- 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
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
- ReadWriteOnce
- 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)
- Delete
- Policy on whether to discard or reuse the Volume after use
- StorageClass
- The type of storage provided by each provider
- Basically, it is created automatically
- The type of storage provided by each provider
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.
Share
Related tags
- Cloud Native Days Tokyo 2019 - Participation Report for July 22-23, 2019
- Starting to Learn Kubernetes a Step Behind - 16. Components -
- Starting to Learn Kubernetes a Step Behind - 15. Security -
- Starting to Learn Kubernetes a Step Behind - 14. Scheduling -
- Osaka, Umeda - Participation Report for Kubernetes Meetup Tokyo 19 Osaka Satellite - May 31, 2019
- Starting to Learn Kubernetes a Step Behind - 13. Health Checks and Container Lifecycle -
- Starting to Learn Kubernetes a Step Behind - 12. Resource Limits -
- Starting to Learn Kubernetes a Step Behind - 10. config&storage Part 1 -
- Osaka BMXUG Study Meeting -Kubernates Experience & Watson Discovery Introduction- Participation Report on March 27, 2019
- Starting to Learn Kubernetes a Step Behind - 09. discovery&LB Part 2 -
- Starting to Learn Kubernetes a Step Behind - 08. discovery&LB Part 1 -
- Starting to Learn Kubernetes a Step Behind - 07. Workloads Part 3 -
- Starting to Learn Kubernetes a Step Behind - 06. Workloads Part 2 -
- Starting to Learn Kubernetes a Step Behind - 05. workloads Part 1 -
- Starting to Learn Kubernetes a Step Behind - 04. kubectl -
- Starting to Learn Kubernetes a Step Behind - 03. Raspberry Pi -
- Starting to Learn Kubernetes a Step Behind - 02. Docker For Mac -
- Starting to Learn Kubernetes a Step Behind - 01. Choosing the Environment -