PostgreSQL PVC
Location:postgres-db/pvc.yml
Configuration Details
Metadata:- Name:
postgres-pvc- Referenced in PostgreSQL Deployment
- Access Mode:
ReadWriteOnce- Single node read/write access - Storage: 5Gi - Five gigabytes of persistent storage
- Storage Class:
standard-rwo- Uses standard storage class with RWO support - Volume Mode:
Filesystem- Mounted as a filesystem (default)
Usage in Deployment
Frompostgres-db/deployment.yml (reference/deployments.mdx:36-43):
- Mount Path:
/var/lib/postgresql/data- PostgreSQL data directory - SubPath:
postgres-data- Isolates data within PVC - Volume Name:
postgres-storage- Internal reference name
Redis PVC
Location:redis/pvc.yml
Configuration Details
Metadata:- Name:
redis-pvc- Referenced in Redis Deployment
- Access Mode:
ReadWriteOnce- Single node read/write access - Storage: 5Gi - Five gigabytes of persistent storage
- Storage Class:
standard-rwo- Uses standard storage class with RWO support - Volume Mode:
Filesystem- Mounted as a filesystem
Usage in Deployment
Fromredis/deployment.yml (reference/deployments.mdx:20-27):
- Mount Path:
/data- Redis data directory - SubPath:
redis-data- Isolates data within PVC - Volume Name:
redis-storage- Internal reference name
Access Modes
ReadWriteOnce (RWO)
- Volume can be mounted as read-write by a single node
- Most common access mode for databases
- Best performance for single-instance stateful applications
- Supported by most storage providers
- Databases (PostgreSQL, MySQL)
- Key-value stores (Redis)
- Single-instance applications
- Local development
Alternative Access Modes
ReadOnlyMany (ROX):- Volume can be mounted read-only by many nodes
- Use for shared read-only data
- Static assets, configuration files
- Volume can be mounted read-write by many nodes
- Requires NFS or similar shared filesystem
- Use for shared writable data
- More expensive and complex
Storage Classes
standard-rwo
standard-rwo storage class:
Characteristics:
- Type: Standard persistent disk (HDD or SSD depending on provider)
- Access Mode: ReadWriteOnce support
- Performance: Good for general workloads
- Cost: Moderate pricing
- Availability: Zonal (tied to specific zone)
Cloud Provider Storage Classes
Google Kubernetes Engine (GKE):List Available Storage Classes
Volume Binding Mode
Storage classes define when volumes are provisioned:WaitForFirstConsumer
- Volume provisioned when pod is scheduled
- Ensures volume is created in same zone as pod
- Prevents zone mismatch issues
- Recommended for production
Immediate
- Volume provisioned immediately when PVC is created
- May be in different zone than pod
- Can cause pod scheduling failures
- Faster for testing
Storage Sizing
Current Configuration
Both PVCs request 5Gi:Sizing Recommendations
PostgreSQL:- Small Database: 5-10Gi (current setting)
- Medium Database: 20-50Gi
- Large Database: 100Gi+
- Formula: (Rows × Row Size × 1.5) + Indexes + WAL
- Cache Only: 1-5Gi (current setting)
- Persistence: 5-20Gi
- Large Dataset: 50Gi+
- Formula: Dataset Size × 2 (for snapshots)
Resize PVC
Expand storage without downtime:Volume Mode
Filesystem
- Default mode
- Volume formatted with filesystem (ext4, xfs, etc.)
- Mounted as directory in container
- Standard for most applications
- Databases
- Application data
- Log files
- Configuration storage
Block
- Raw block device (no filesystem)
- Higher performance
- Application manages data layout
- Less common
- Custom databases
- Performance-critical applications
- Direct disk access requirements
Reclaim Policy
Defined in StorageClass, determines what happens to PV after PVC deletion:Delete (Default)
- PersistentVolume deleted when PVC is deleted
- Underlying storage (disk) also deleted
- Data is permanently lost
- Cost-effective for ephemeral data
Retain
- PersistentVolume kept when PVC is deleted
- Underlying storage preserved
- Manual cleanup required
- Data can be recovered
SubPath Usage
Both PVCs use subPath in volume mounts: PostgreSQL:Why Use SubPath?
- Isolation: Separates data from mount point metadata
- PostgreSQL Requirement: PostgreSQL won’t start if data dir contains lost+found
- Clean Structure: Organizes data within volume
- Multiple Mounts: Allow multiple subPaths from same PVC (if needed)
Directory Structure
Without subPath:PVC Lifecycle
Creation
- Pending: Waiting for provisioning
- Bound: Successfully bound to PersistentVolume
- Lost: PV reference lost
Binding
PVC binds to PersistentVolume:Expansion
Deletion
PVC Operations
View PVCs
View Bound PersistentVolumes
Check Storage Usage
Backup PVC Data
Troubleshooting
PVC Stuck in Pending
Pod Can’t Mount PVC
Data Loss After Deletion
Prevention:Best Practices
- Size Appropriately: Estimate growth, add buffer (2x recommended)
- Use SubPath: Especially for PostgreSQL to avoid lost+found issues
- Enable Backups: Regular snapshots or external backups
- Monitor Usage: Alert when storage reaches 80% capacity
- Test Restore: Regularly test backup/restore procedures
- Use Retain Policy: For production data, consider Retain reclaim policy
- Document Dependencies: Track which pods use which PVCs
- Plan for Expansion: Choose storage class that supports expansion
Storage Costs
Cost Comparison (Example: GCP)
| Storage Type | Cost per GB/month | Performance |
|---|---|---|
| standard-rwo | $0.04 | Standard HDD |
| balanced-rwo | $0.10 | Balanced SSD |
| premium-rwo | $0.17 | Premium SSD |
- PostgreSQL: 5Gi × 0.20/month
- Redis: 5Gi × 0.20/month
- Total: $0.40/month
Performance Optimization
Storage Class Selection
For Databases:IOPS Tuning
For cloud providers with provisioned IOPS:Related Resources
- Deployments - Pods that use these PVCs
- Services - Service endpoints for stateful applications
- Kubernetes PVC Documentation
- Storage Classes Documentation

