Storage Configuration

This guide covers persistent storage configuration in Krutrim Kubernetes Service using Container Storage Interface (CSI) drivers.

Understanding Storage in Kubernetes

Kubernetes provides several storage abstractions:

  • Volumes: Temporary storage tied to pod lifecycle

  • PersistentVolumes (PV): Cluster-level storage resources

  • PersistentVolumeClaims (PVC): User requests for storage

  • StorageClass: Dynamic provisioning configuration

CSI Add-on Overview

The Container Storage Interface (CSI) driver enables dynamic storage provisioning in your cluster.

What is CSI?

CSI is a standard interface for exposing block and file storage systems to containerized workloads on Kubernetes.

Benefits:

  • ✅ Dynamic volume provisioning

  • ✅ Automatic volume creation

  • ✅ Volume snapshots

  • ✅ Volume expansion

  • ✅ Integration with cloud storage

Critical: CSI Add-on Requirement

Installing CSI Add-on

Install the CSI add-on to enable persistent storage in your cluster.

Configuring Persistent Storage

Prerequisites

Before configuring storage, ensure:

  • CSI Node Plugin Installed:

    • CSI Node Plugin add-on: ACTIVE

Verify Installation

Understanding Storage Classes

Available Storage Classes

Once the CSI add-on is installed, a default storage class is automatically configured for your cluster.

Default Storage Class

After CSI installation, the default storage class is automatically created:

Storage Class Parameters

Provisioner: cinder.csi.openstack.org

  • Uses OpenStack Cinder for block storage

  • Provides persistent volumes backed by cloud storage

Reclaim Policy: Delete

  • Volumes are deleted when PVC is deleted

  • Data is permanently removed

  • Use caution with production data

Volume Binding Mode: Immediate

  • Volume is created immediately when PVC is created

  • Does not wait for pod to be scheduled

  • Volume may be created in different zone than pod

Allow Volume Expansion: true

  • Volumes can be resized after creation

  • Requires PVC and pod restart

Using Persistent Storage

Creating a PersistentVolumeClaim

Basic PVC

Apply PVC:

Check PVC Status:

Access Modes

ReadWriteOnce (RWO):

  • Volume can be mounted read-write by a single node

  • Most common mode

  • Supported by default storage class

ReadOnlyMany (ROX):

  • Volume can be mounted read-only by multiple nodes

  • Less common

  • Check if supported

ReadWriteMany (RWX):

  • Volume can be mounted read-write by multiple nodes

  • Requires special storage types (not block storage)

  • Not supported by default Cinder CSI

Using PVC in Pods

Pod with Volume Mount

StatefulSet with Volume Claim Template

Benefits of VolumeClaimTemplates:

  • Each pod gets its own PVC

  • PVC name includes pod name (data-database-0, data-database-1, etc.)

  • Automatic creation and management

Common Storage Scenarios

Scenario 1: Web Application with User Uploads

Scenario 2: Database with Persistent Storage

Scenario 3: Shared Configuration Files

Note: Use ConfigMap for configuration, PVC for data

Scenario 4: Multiple Containers Sharing Data

Managing Storage

Viewing Storage Resources

Expanding Volumes

The default storage class supports volume expansion.

Step: Edit PVC

Step: Increase Size (example)

Step: Restart Pod

Verification:

Important notes:

  • Can only increase size, not decrease

  • Pod must be restarted for filesystem resize

  • Some storage backends may take time to expand

Deleting Storage

Delete PVC:

What happens:

  • PVC is deleted

  • PV is deleted (due to Delete reclaim policy)

  • Underlying storage is removed

  • Data is permanently lost

Warning: Deleting PVC deletes data permanently!

Protecting Important Data:

  • Option 1: Change Reclaim Policy

  • Option 2: Backup Before Deletion

  • Option 3: Don't Delete PVC

    • Keep PVC even if not in use

    • PVC doesn't cost money, storage does

    • Reattach to new pods when needed

Storage Best Practices

1

Size Appropriately

  • Start with reasonable size

  • Plan for growth (can expand later)

  • Monitor usage regularly

2

Use Appropriate Access Modes

  • ReadWriteOnce for most applications

  • ReadOnlyMany for shared read-only data

  • Understand access mode limitations

3

Plan for Data Persistence

  • Important data: Use PVCs

  • Temporary data: Use emptyDir

  • Configuration: Use ConfigMaps/Secrets

4

Monitor Storage Usage

5

Backup Critical Data

  • Regular backups of databases

  • Export important data

  • Test restore procedures

6

Use StatefulSets for Stateful Apps

  • Databases, queues, caches

  • Automatic PVC management

  • Stable network identities

Anti-Patterns / Don'ts

1

Don't Use ReadWriteOnce for Multi-Replica Apps

2

Don't Delete PVC Without Backup

  • Always backup important data first

  • Verify backups are restorable

  • Document data recovery procedures

3

Don't Overprovision Storage

  • Start reasonable, expand as needed

  • Storage costs money

  • Monitor actual usage

4

Don't Ignore Disk Full Errors

  • Monitor disk usage

  • Set up alerts at 80% usage

  • Expand or clean up before full

5

Don't Store Secrets in Volumes

  • Use Kubernetes Secrets

  • Use proper secret management

  • Don't write passwords to persistent storage

Troubleshooting Storage

PVC Stuck in Pending

Symptoms:

  • PVC status remains Pending

  • No PV created

Possible Causes:

  1. CSI add-on not installed

  2. Storage provisioning in progress

  3. Storage quota exceeded

Solution:

Pod Cannot Mount Volume

Symptoms:

  • Pod in ContainerCreating state

  • Events show volume mount errors

Possible Causes:

  1. PVC not bound

  2. Node doesn't have CSI driver

  3. Volume in use by another pod (RWO)

Solution:

Volume Out of Space

Symptoms:

  • Application errors writing to disk

  • Pod logs show "no space left on device"

Solution:

Storage Class Not Found

Symptoms:

  • PVC pending with "no storage class found"

  • kubectl get storageclass shows nothing

Solution:

Storage Sizing Guidelines

Application Types

Small Applications / Development:

Medium Applications / Production:

Databases:

File Storage / Media:

Monitoring / Logging:

Additional Resources

  • Installing Add-ons - Install CSI add-ons

  • Best Practices - Storage optimization tips

  • Troubleshooting Guide - Common storage issues

Last updated

Was this helpful?