K8s CKA Certificate 9 — Persistent Storage

Tony
8 min readOct 17, 2024

In applications, there are two main scenarios for handling data storage:

  1. Database Storage: Data is saved to a database. The application connects to the database service via code and uses SQL statements to read and write data. This method does not require storage provided by the K8s cluster.
  2. File Storage: Since the file system within a Pod’s container is recreated with each restart, any files stored within the container are not retained after a restart. However, applications may need to persist certain files (such as logs, user-uploaded files, etc.) so that they can be accessed again after a container restart. This is the problem of persistent file storage, which requires the K8s cluster to provide a storage solution.

K8S Volume

K8s uses an abstract concept called a Volume to solve the problem of persistent file storage. In a Pod, we first define a Volume representing a certain storage space. Then, within the Pod’s container, by mounting this Volume to a specific directory in the container, we create a mapping relationship.

Any operations performed in this directory (such as creating directories, reading/writing files, etc.) are actually performed in the designated storage space. As a result, these operations are naturally retained in the storage space, achieving…

--

--

Tony
Tony

No responses yet