# Volumes in Kubernetes

In 
Published 2022-12-03

This tutorial explains what the volumes are in Kubernetes.

A Volume in Kubernetes represents a directory with data that is accessible across multiple containers in a Pod. Volumes provide a plug-in mechanism to connect ephemeral containers with persistent data stores elsewhere.

Types of Kubernetes Volumes:

  • Ephemeral Volumes: lives as long as the pod lives
    • emptyDir: empty at Pod startup and uses the node storage or the RAM. Once the Pod is removed from the node, the data in the emptyDir is erased. This type of volume is suitable for temporary data storage.
    • configMap : a mount directory which keeps the configMap data
    • downwardAPI : mount the information about the pod into the container as a special volume
    • secret: the same as for configMap volumes, but the data is not in clear text.
    • generic ephemeral volumes : which can be provided by all storage drivers that also support persistent volumes
  • Durable Volumes : when pods and volumes lifecycles are independent

    • hostPath : mounts a file or directory from the host node’s filesystem into your pod.

    • PersistentVolume (PV) : is a Kubernetes resource that is created by an administrator or dynamically using Storage Classes independently of the Pod.

    • PersistentVolumeClaim (PVC) : claims the space to be referenced in a pod. A PersistentVolumeClaim is created by specifying the minimum size and the access mode they require from the PersistentVolume. A PVC is a storage request made by a user. If the storage is not available (ex. you have 2 PV of 50Gb each, and you have a PVC of 70Gb) the pod will not be able to use that storage claimed using a PVC.

    • gcePersistentDisk : mounts a Google Cloud Persistent Disk into your Pod.

    • awsElasticBlockStore : mounts an Amazon Web Services (AWS) Elastic Block Store into your Pod.

    • azureDiskVolume : mounts a Microsoft Azure Data Disk into a Pod.

    • gitRepo : mounts an empty directory and clones a git repository into it for your pod to use.