DevOps(Day-36) : Managing Persistent Volumes in Your Deployment

DevOps(Day-36) : Managing Persistent Volumes in Your Deployment

TABLE OF CONTENTS

What are Persistent Volumes in k8s?

Kubernetes persistent volumes are administrator-provided volumes. They have predefined properties including file system, size, and identifiers like volume ID and name.

Persistent volumes are independent of the lifecycle of the pod that uses it, meaning that even if the pod shuts down, the data in the volume is not erased. They are defined by an API object, which captures the implementation details of storage such as NFS file shares, or specific cloud storage systems.

For a Pod to start using these volumes, it must request a volume by issuing a persistent volume claim (PVC). PVCs describe the storage capacity and characteristics a pod requires, and the cluster attempts to match the request and provision the desired persistent volume.

Task-1: Add a Persistent Volume to a deployed application.

  1. Create Persistent volume in your AWS EC2 instance machine.

  2. Run the persistent volume file in the server using kubectl command.

  3. Now, create a Persistent Volume Claim file with all the required configurations.

  4. Run the Persistent Volume claim file in the server.

  5. Make changes in the deployment file to include all the configuration requirements to attach the persistent volume.

  6. Run the Persistent Volume claim file in the server.

  7. You can now check the Pods running in the instance.

  8. Check the persistent volume running on the server.

    Task-2: Accessing data in the Persistent Volume

    1. Navigate to the inside of one of the Pods and create a file in the Pod.

    2. Now, delete that pod, by deleting the deployment and check if the file in the new pod is created after applying the deployment again in the server.

    3. You can see the file remains intact, that's the beauty of volume. Even if the pod gets deleted somehow or in case of any mishap the data persists.

Thanks for reading my article. Have a nice day.

WRITTEN BY Biswaraj Sahoo --AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes

Empowering communities via open source and education. Connect with me over linktree: linktr.ee/biswaraj333