
AKS File Share with Terraform — RWX Storage for Multi-Replica Applications
- Posted by Martin Linxfeld
- Categories AKS – Azure Kubernetes Service, opentofu, terraform
- Date December 11, 2025
- Comments 0 comment
- Tags AKS File Share, AKS File Share Terraform, Azure File CSI, Azure File Share NFS, file.csi.azure.com, Kubernetes RWX, PersistentVolumes, PVC, StorageClass
When working with AKS File Share Terraform deployments, you quickly discover that many real applications need a shared filesystem — something multiple pods can mount at the same time. Upload directories, shared logs, cached assets, configuration files, WordPress media folders, backend pipelines — all require ReadWriteMany (RWX) access. In Azure, this capability comes from Azure File Share provisioned automatically through the file.csi.azure.com driver.
This article builds a complete mental model for RWX in AKS and continues the storage journey started in the previous blog.
How This Builds on the Previous Article (disk.csi.azure.com → file.csi.azure.com)
In the previous blog, we explored how AKS provisions Azure Managed Disks through the disk.csi.azure.com CSI driver.
That model provides ReadWriteOnce (RWO) semantics — perfectly suited for:
single-pod state,
caches,
index and database files,
node-local workloads.
But RWO breaks the moment your application scales horizontally.
RWX storage solves that problem.
This article introduces the second half of the AKS storage picture:
RWO = Azure Managed Disk via
disk.csi.azure.comRWX = Azure File Share via
file.csi.azure.com
Both models come together in Lesson 8 of the AKS with Terraform/OpenTofu course, where you build RWO and RWX examples in one Terraform-driven environment.
Why RWX Storage Solves a Real Problem
As soon as you deploy applications with more than one replica, you hit a limitation:
Multiple pods cannot write to the same filesystem using RWO.
This is why RWX matters.
Common RWX scenarios include:
web applications storing uploads, images, or media
multi-replica services sharing configuration files
distributed workloads needing a shared working directory
pipelines writing logs to the same path
CMS platforms like WordPress, Ghost, Strapi, etc.
Azure Files solves this by exposing a network filesystem (NFS or SMB) that:
supports ReadWriteMany,
is accessible across all nodes in an AKS cluster,
is provisioned automatically through Kubernetes.
📐 Design notes — Network & RWX intent before implementation
Before diving into the RWX architecture details, it’s worth stepping back and looking at storage and networking as architectural intent, not just Kubernetes configuration.This short Design Note explains why shared storage decisions must be aligned with network boundaries and platform design early — before manifests and Terraform are applied.
RWX Architecture at a Glance
When moving from single-replica stateful workloads to multi-replica applications, AKS requires storage that can be mounted by many pods at the same time. This is where Azure File Share, provisioned automatically through the file.csi.azure.com CSI driver, becomes essential.
Unlike the RWO disk model discussed in the previous article, RWX storage provides a true shared filesystem accessible across every node in the cluster.
Understanding this model is critical before applying Terraform and Kubernetes manifests together. In an aks file share terraform deployment, Kubernetes, not Terraform, orchestrates the provisioning workflow: your application simply requests shared storage, and AKS ensures that the correct Azure File Share is created, bound, and mounted across all replicas.
RWX provisioning in AKS follows a clean and predictable lifecycle:
A PersistentVolumeClaim requests RWX storage.
A StorageClass using
file.csi.azure.comprovisions (or references) an Azure File Share.A PersistentVolume binds the File Share to the PVC.
All replicas mount the volume at the same path (e.g.,
/mnt/azurefile).The backing Azure resource is a File Share inside a Storage Account.
This is the core workflow behind any aks file share terraform deployment — Kubernetes automates the provisioning while Terraform focuses on the surrounding infrastructure.
What the CSI Driver Actually Does
When the PVC appears, the file.csi.azure.com driver automatically:
creates (or uses) a Storage Account,
provisions an Azure File Share,
manages access keys and mount credentials,
configures the NFS or SMB protocol,
mounts the share on every node running your pods.
This is fundamentally different from the Terraform-first approach:
Terraform-first provisioning (outside AKS):
Uses resources like:
azurerm_storage_accountazurerm_storage_shareazurerm_private_endpoint
Kubernetes-first provisioning (inside AKS):
Uses:
StorageClass
PVC
PV
file.csi.azure.com
Kubernetes becomes the orchestrator — you no longer create File Shares manually with Terraform.
Terraform in the RWX Workflow (High-Level Only)
The AKS storage examples in Lesson 8 rely on Terraform only to:
deploy the AKS cluster,
render StorageClass + PVC YAML manifests,
run a Deployment that mounts the RWX volume.
Terraform triggers the workflow, but the CSI driver provisions the real storage.
A simplified snippet from the Deployment manifest:
volumeMounts:
- name: azurefile
mountPath: /mnt/azurefile
volumes:
- name: azurefile
persistentVolumeClaim:
claimName: fk-azurefile-pvc
Pods simply mount the RWX volume — no manual File Share resource creation required.
Common Pitfalls When Deploying RWX
❌ Using SMB instead of NFS for Linux apps
SMB is slower and often causes permission issues.
❌ Forgetting ReadWriteMany in the PVC
PVC defaults to RWO if not specified.
❌ Network restrictions blocking nodes from the Storage Account
Private Endpoints + strict firewalls easily break RWX.
❌ Too small File Share quota
Resize early — CSI will not do it for you.
Read More
These earlier articles give important infrastructure-side context before moving to AKS-native provisioning:
🔗 Azure File Storage + NFS with Terraform
Shows how Azure Files work outside AKS. Understanding shares, NFS, and private endpoints helps you reason about what the CSI driver automates.
🔗 Azure Managed Disk with Terraform
Demonstrates RWO storage at the infrastructure layer — useful background before exploring RWX.
What's Next?
In the next article we will put everything together:
final RWX YAML manifests,
full Terraform workflow,
multi-replica Deployment test,
validation inside AKS Portal and via
kubectl,troubleshooting patterns.
This closes the two-part storage chapter used in Lesson 8 of the AKS Terraform course.
⭐ Ready to Go Deeper?
RWX storage is only one part of Lesson 8 in the
Azure AKS with Terraform/OpenTofu — Hands-On Fundamentals (2025 Edition).
Inside the course you’ll find:
both RWO + RWX implementations,
full Terraform code,
StorageClass design,
CSI deep dive,
real multi-replica examples.

Master AKS Shared Storage (NFS/RWX) with Terraform/OpenTofu
Learn how to deploy shared, multi-replica storage in AKS using Azure File Share (NFS), PVCs, StorageClasses, and the file.csi.azure.com CSI driver — including end-to-end Terraform automation and real application examples.
🔒 Lifetime • ⏱️ Self-paced • 🧪 Real labs
