100-Days-Of-DevOps-Challenge-KodeKloud

Kubernetes Shared Volumes

We are working on an application that will be deployed on multiple containers within a pod on Kubernetes cluster. There is a requirement to share a volume among the containers to save some temporary data. The Nautilus DevOps team is developing a similar template to replicate the scenario. Below you can find more details about it.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.

Steps

  1. Let’s create the k3s-pod.yml file using the contnets

  2. Create the pod

     kubectl apply -f k3s-pod.yml
    
  3. Execute the first container

     kubectl exec -it volume-share-nautilus -c volume-container-nautilus-1 /bin/sh
    

    Create news.txt file

     touch /tmp/news/news.txt
    
  4. Execute the 2nd container

     kubectl exec -it volume-share-nautilus -c volume-container-nautilus-2 /bin/sh
    

    Verify the created files under shared directory

     ls /tmp/demo
    

Good to Know?

Shared Volumes

Volume Types

Multi-Container Use Cases

Container Communication