GCP for DevOps — Filestore
Filestore
Filestore is Google Cloud’s managed NFS file storage service. It provides shared file systems that can be mounted simultaneously by multiple Compute Engine VMs and GKE pods — ideal for shared configuration, CMS content, and build caches.
Filestore Tiers
┌─────────────────────────────────────────────────────┐
│ Filestore Tiers │
├──────────────┬──────────┬──────────┬────────────────┤
│ Tier │ Min Size │ IOPS │ Use Case │
├──────────────┼──────────┼──────────┼────────────────┤
│ Basic HDD │ 1 TB │ 600 r / │ Shared config, │
│ │ │ 1,000 w │ low-throughput │
├──────────────┼──────────┼──────────┼────────────────┤
│ Basic SSD │ 2.5 TB │ 60k r / │ General shared │
│ │ │ 25k w │ workloads │
├──────────────┼──────────┼──────────┼────────────────┤
│ Zonal │ 1 TB │ Up to │ High-perf apps │
│ │ │ 480k │ within a zone │
├──────────────┼──────────┼──────────┼────────────────┤
│ Enterprise │ 1 TB │ Up to │ Mission-critical│
│ (Regional) │ │ 120k │ cross-zone HA │
└──────────────┴──────────┴──────────┴────────────────┘
Create a Filestore Instance
# Create a Basic SSD Filestore instance
$ gcloud filestore instances create shared-fs \
--zone=us-central1-a \
--tier=BASIC_SSD \
--file-share=name=vol1,capacity=2560GB \
--network=name=default
# Describe the instance (get IP address)
$ gcloud filestore instances describe shared-fs \
--zone=us-central1-a \
--format="value(networks[0].ipAddresses[0])"
10.0.0.2
# List all instances
$ gcloud filestore instances list
Mount on Compute Engine
# Install NFS client
$ sudo apt-get install -y nfs-common
# Mount the file share
$ sudo mkdir -p /mnt/shared
$ sudo mount 10.0.0.2:/vol1 /mnt/shared
# Persist across reboots
$ echo '10.0.0.2:/vol1 /mnt/shared nfs defaults 0 0' | sudo tee -a /etc/fstab
# Verify mount
$ df -h /mnt/shared
Filesystem Size Used Avail Use% Mounted on
10.0.0.2:/vol1 2.5T 0 2.5T 0% /mnt/shared
Filestore in GKE
Use the Filestore CSI driver for ReadWriteMany access across pods.
# PersistentVolume backed by Filestore
apiVersion: v1
kind: PersistentVolume
metadata:
name: shared-pv
spec:
capacity:
storage: 2560Gi
accessModes:
- ReadWriteMany
nfs:
path: /vol1
server: 10.0.0.2
---
# PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: shared-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 2560Gi
volumeName: shared-pv
---
# Deployment mounting the PVC
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
replicas: 3
selector:
matchLabels:
app: web-app
template:
metadata:
labels:
app: web-app
spec:
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html
volumes:
- name: shared-data
persistentVolumeClaim:
claimName: shared-pvc
Filestore Backups
# Create a backup
$ gcloud filestore backups create shared-fs-backup-1 \
--file-share=vol1 \
--instance=shared-fs \
--instance-zone=us-central1-a \
--region=us-central1
# List backups
$ gcloud filestore backups list --region=us-central1
# Restore from backup to a new instance
$ gcloud filestore instances restore shared-fs-restored \
--zone=us-central1-a \
--file-share=name=vol1 \
--source-backup=shared-fs-backup-1 \
--source-backup-region=us-central1
Resize Filestore
# Scale up capacity (no downtime, can only grow)
$ gcloud filestore instances update shared-fs \
--zone=us-central1-a \
--file-share=name=vol1,capacity=5120GB
Storage Comparison — When to Use What
| Feature | Cloud Storage | Persistent Disk | Filestore |
|---|---|---|---|
| Type | Object | Block | File (NFS) |
| Access | API / gsutil | Single VM (RWO) | Multi-VM (RWX) |
| Min size | 0 bytes | 10 GB | 1 TB |
| Use case | Artifacts, backups | Databases, boot | Shared files, CMS |
| Mount in GKE | Fuse (slow) | PVC (RWO) | PVC (RWX) |
| Snapshots | Versioning | Yes | Backups |
Common Mistakes
| Mistake | Why It’s Wrong | Fix |
|---|---|---|
| Using Filestore for object storage | Expensive at scale | Use Cloud Storage for artifacts/logs |
| Basic HDD for latency-sensitive apps | High latency, low IOPS | Use Basic SSD or Zonal tier |
| Not backing up Filestore | Data loss risk | Schedule regular backups |
| ReadWriteOnce for multi-pod access | Only one pod can write | Use Filestore for RWX |
| Minimum size overprovisioning | 1-2.5 TB minimum is costly | Only use Filestore when NFS is needed |
Quick Reference
| Command | Description |
|---|---|
gcloud filestore instances create F --tier=T |
Create instance |
gcloud filestore instances describe F |
Get IP and details |
sudo mount IP:/share /mnt/path |
Mount NFS share |
gcloud filestore backups create B --instance=F |
Create backup |
gcloud filestore instances update F --file-share=capacity=S |
Resize |
Next → Storage Exercises