Before going to k8s, will see the storage in Docker.
Storage in docker:
Stores the data in layers in turn the docker image are very small in size.
The docker file system architecture is layered architecture, below example of one docker file.
-
Layer 1. Base OS layer
-
Changes in packages
-
Changes in Pip packages
-
Source Code
-
Update entrypoint
The layers are categorized in two parts
1. Image layer 2. Container layer.
If new changes want to make in image, it can be only done in container layer as image layers are read-only once it is created. This is only one time change.
COPY-ON-WRITE:
If want to make changes in source code, kubernetes copy that file from image layer to container layer as this layer is writable then make changes in file so that is called as copy-on-write.
Challenge: The container data get deleted once pod finished.
To fix this a volume comes in picture. We can create the volume and mount in container to store data even when pod get deleted.
There are two ways we can mount the volume.
-
Volume Mount
Create a volume using docker create command and then mount to pod by specifying in pod definition file.
-
Bind Mount
The mounting of external/folder on local host to pod without creating the volume.
Who is responsible for these operation in docker?
The storage driver is responsible for executing these operations.
There are some storage driver are already available in market
-
AUFS – comes with Ubuntu
-
NFS
-
Device mapper – supports in Centos, Federo, Linux
-
ZFS
-
BTRFS
-
Overlay
-
Overlay2
Who is responsible volume for operation?
Volume driver operates volume work.
The solutions are available in the markets.
-
Local
-
Azure file storage
-
Convoy
-
Digital Ocean Block storage
-
gce-docker
-
Vmware vSphere storage
-
NetApp