K8s pt.7 / Sketch of Database Operations

Liebertar
Dev-ops
Published in
3 min readMar 10, 2024

Now that we’ve gotten the essence of PV and PVC and understood their distinction from the database itself, let’s going into deeper. In the Kubernetes world, a Pod may act as a database, but it’s just a temporary storage solution. To ensure durability, we turn to Persistent Volumes (PV) and Persistent Volume Claims (PVC).

We’re sketching out the intricate connections between the cluster, external resources, and each component in the process. Let’s unravel the entire journey, starting with the client’s initial request.

Edited by Liebertar

What is the Overall Procedure? Let’s starts from the client request

Exploring Data Processing After StatefulSet part

After the StatefulSet takes charge, the actual management of data kicks in. The database pod steps into prominence, showcasing its repository within the pod environment, housing essential logs and valuable data. This data, the vital force behind our operations, securely resides within the database pod.

1. A Simple and Smooth Routine : “CronJob”

Visualize the data transfer process as a smoothly orchestrated routine, where each step effortlessly falls into place. As the works begins, data integrates itself within the database pod, becoming an integral part of its environment. This pod transitions is responsible for preserving our information, ensuring it remains intact and prepared for the next phase.

Inside of Statefulset (DB pod)

(1) Logs Repository: Documenting Every Step

In the data processing, the logs repository operates like a record-keeper, documenting every action and event within the database pod. Think of it as a backstage journal, chronicling the pulse of the pod’s activities. Every operation, whether it’s a successful transaction or an encountered error, finds its place in this repository. The logs provide a comprehensive record of the performance, offering insights into the system’s health and functionality.

(2) Data Repository: Storing the Substance

Data repository is a neighbor of the logs repository, the storehouse of our data. This repository represents the structured shelves where data is neatly organized. Imagine it as a well-organized library, with different sections for various datasets. Here, our critical information, like customer details or transaction records, finds its place.

(3) “The Data Transfer Act”

As the operation approaches its peak, the Cronjob takes a vital role. It accurately collects the data, navigating between the logs and data repositories within the database pod. The gathered information is then deposited into the Persistent Volume (PV), ensuring its persistence even beyond the pod’s lifecycle. This PV collaborates with the Persistent Volume Claim (PVC), acting as a conduit between the pod and the external storage disk.

In essence, the Cronjob’s operation delicately transfers the logs and data from the operational space of the database pod to the secure and enduring storage provided by the PVC-PV-DISK ensemble. This guarantees that our data not only smoothly operates within the pod but also stands ready for the next chapter in the expansive landscape of Kubernetes data management.

2. Enter the Cronjob

But what about our data’s final exit? This is where the Cronjob takes center stage. Configured to run daily, the Cronjob is our trusty timekeeper, orchestrating the process of extracting the stored data and pushing it to an external resource.

3. Daily Performance of the Cronjob

Every day, like clockwork, the Cronjob swings into action. It carefully accesses the stored data within the database pod, creating a meticulously crafted backup. This backup, a snapshot of our system at a specific moment, ensures that our data is not only secure within the confines of the Kubernetes cluster but also stored externally for added resilience.

4. Vanishing Act or Curtain Call?

Now, here’s the interesting part : what happens to the Cronjob once its task is complete? Think of it as a performer taking a graceful bow after an impeccable performance. The Cronjob doesn’t staying in the resources. Instead, it will exits the stage, ensuring resource efficiency and maintaining the clean aesthetics of our Kubernetes environment.

5. Sum up

The StatefulSet orchestrates the performance, the database pod holds the narrative, and the Cronjob takes a bow after each act. Together, they compose a symphony of reliability, securing and preserving our data in the ever-evolving landscape of Kubernetes.

03.10.2024 — Fin.

--

--