Is Kubernetes local/csi PV content synced into a new node?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Kubernetes has revolutionized the way we manage and orchestrate containers. One of its core features is the way it manages storage with Persistent Volumes (PVs). There is often some confusion and curiosity about how PV content is handled, especially in relation to local and Container Storage Interface (CSI) volumes. This article delves into whether content within these PVs remains synced when a new node is introduced in a Kubernetes cluster.
Understanding Persistent Volumes and Local/CSI Storage
Persistent Volumes in Kubernetes provide a mechanism for storage that spans beyond the lifecycle of individual pods. They can be backed by various storage solutions, from cloud providers like AWS EBS to on-premises NFS servers. Two notable types of PVs are:
- Local Volumes: These are disks physically attached to the node. They provide high performance, but their data is confined to the node they are attached to.
- CSI Volumes: These are managed by the Container Storage Interface, an open standard for exposing storage systems to containerized workloads on Kubernetes.
How Kubernetes Handles PV Content
Local Volumes:
Local volumes are node-bound by their nature. The content is not inherently replicated or synchronized across nodes. When a pod using a local PV is rescheduled due to node failure, access to the data is lost unless specific measures are taken. For high availability, solutions like distributed storage systems (e.g., Ceph or GlusterFS) that work with local PVs might be employed.
Example:
- ReadWriteOnce
- matchExpressions:
- key: kubernetes.io/hostname
- node1
- Local Volumes: No automatic sync to the new node. The storage is physically tied to the initial node. Manual intervention or additional steps are required for data migration if necessary.
- CSI Volumes: Varies with implementation. Some CSI provisions like Rook/Ceph or OpenEBS can replicate data across nodes, making it accessible to new nodes without manual sync.
- ReadWriteOnce
- Backup and Disaster Recovery: Always maintain a robust backup and DR strategy. External tools or cloud provider solutions can be used to ensure data safety.
- Storage Performance: Local storage often provides high performance, but at the cost of redundancy. Consider usage scenarios and performance requirements when choosing between local and networked storage.
- CSI Drivers and Features: Evaluate the CSI driver's documentation and features. Determining factors should include support for replication, snapshots, and cross-node data access.
Related reading
- Is there a concept of inheritance for Kubernetes deployments?
- Is there a 'max-retries' for Kubernetes Jobs?
- Is there a way in kubectl patch to delete a specific object in an array without specifying the index?
- Is there a way in Kubernetes to check when hpa happened?
- Is there a way to add arbitrary records to kube-dns?
- Is there a way to assign pod-network-cidr in kubeadm after initialization?
- Is there a way to configure Istio to route traffic to a POD which is in the terminating state?
- Is there a way to create a token for a normal user in Kubernetes?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.