Day 34 Task: Managing Persistent Volumes in Your Deployment ??
RAHUL SHARMA
DevOps Engineer (Seeking Opportunities as a DevOps Engineer) Linux, git, Github, Docker, kubernetes, terraform, ansible,AWS
Table of contents
?? Persistent Volumes (PVs): Think of these as storage units. They're like lockers where you store your stuff, but in the digital world. PVs exist independently of any particular pod (container).
??? Persistent Volume Claims (PVCs): These are requests for storage. When a pod needs storage, it submits a claim for a PV of a specific size and access mode.
?? Reclaim Policy: Imagine when you move out of a storage unit, you can either clean it up for the next person (like sweeping it out) or leave your stuff there. The reclaim policy decides what happens to the PV when it's released.
?? Dynamic Provisioning: This is like a magical storage genie. Instead of manually creating PVs, dynamic provisioning automatically creates them when a PVC requests storage. It's like saying "Hey genie, I need a storage space of X size with Y features," and poof, it appears!
?? Storage Classes: Think of these as different types of storage options. You might have premium storage, standard storage, or even economy storage. Each storage class offers different features and performance levels.
?? Access Modes: Just like some lockers might only allow one person in at a time (ReadWriteOnce), while others allow multiple people (ReadOnlyMany or ReadWriteMany), access modes define how many pods can access the PV simultaneously and whether they can read or write.
?? Rolling Updates: When you need to update your application, you don't want to lose your data. With rolling updates, Kubernetes ensures that while your pods are being updated one by one, your data remains intact by gracefully moving it from one pod to another.
?? Monitoring and Alerts: It's like having a security guard watching over your storage units. Monitoring ensures that everything is running smoothly, while alerts notify you if something goes wrong, like if a PV is almost full or if there's an issue with access.
By managing persistent volumes in your deployment using these emojis, you can ensure your data storage is reliable, scalable, and secure in your DevOps environment!
What are Persistent Volumes in k8s
?? Persistent Volumes (PVs): These are like digital storage units in Kubernetes. They exist independently of any particular pod (container). PVs provide a way for pods to claim durable storage resources.
?? Binding: Just like finding the right key for a lock, binding in Kubernetes means connecting a Persistent Volume Claim (PVC) to an available PV. It's like matching a request for storage to an actual storage unit.
??? Persistent Volume Claims (PVCs): When a pod needs storage, it submits a claim for a PVC, specifying the desired size and access mode. It's like placing a request for a specific-sized storage unit with certain features.
??? Access Modes: Think of access modes as permissions for accessing the storage. It specifies whether the volume can be mounted as read-only or read-write, and whether it can be shared by multiple pods.
?? Reclaim Policy: Similar to what happens when you move out of a storage unit, the reclaim policy decides what should be done with the PV when it's released. It could be retained, recycled, or deleted.
?? Storage Classes: These are like different types or qualities of storage available in a facility. Each storage class represents a different set of parameters, such as performance, availability, and cost.
?? Dynamic Provisioning: This is like having an automated system that creates PVs on-demand when PVCs claim them. It dynamically allocates storage resources as needed, streamlining the storage management process.
??? Protection: Kubernetes ensures that PVs are protected from unauthorized access or data loss. Just like securing a physical storage unit with a lock, Kubernetes employs authentication and authorization mechanisms to safeguard PVs.
领英推荐
?? Snapshotting: Snapshotting allows you to capture the state of a PV at a specific point in time. It's like taking a photo of your storage unit's contents so that you can restore it later if needed.
Replace <node_label_key> and <node_label_value> with the appropriate node label key and value to target a specific node where the file is located. Additionally, replace /path/to/your/file with the actual path to the file on your node.
Once you've customized the template according to your environment, you can apply it using the kubectl apply -f filename.yaml command.
Task 2:
Accessing data in the Persistent Volume,
To connect to a pod in your deployment using the kubectl exec command, you'll need to specify the name of the pod you want to connect to. Here's the correct command:
COPY
COPY
bashCopy codekubectl exec -it <pod_name> -- /bin/bash
Replace <pod_name> with the name of the pod you want to connect to. If you're unsure about the pod names in your deployment, you can list all the pods in your deployment using:
COPY
COPY
bashCopy codekubectl get pods
This command will list all the pods in your current namespace. Once you identify the pod you want to connect to, you can use its name in the kubectl exec command.
For example, if you want to connect to a pod named my-pod, the command would be:
COPY
COPY
bashCopy codekubectl exec -it my-pod -- /bin/bash
This command will open an interactive shell (bash) within the specified pod, allowing you to execute commands and interact with the container.