Access Modes in Azure Kubernetes Service (AKS)

Access Modes in Azure Kubernetes Service (AKS)

AKS supports four types of access modes:

  1. ReadWriteOnce (RWO)
  2. ReadWriteMany (RWX)
  3. ReadOnlyMany (ROX)
  4. ReadWriteOncePod (RWOP) (Kubernetes 1.21 and later)

1. ReadWriteOnce (RWO)

A volume with ReadWriteOnce access mode can be mounted as read-write by only one node at a time.

Use Case: This is often used for storage directly attached to a single node, such as an Azure Managed Disk or AWS EBS volume, which can only be attached to a single VM (node) at a time.
Example:

Suppose you have a volume with ReadWriteOnce access mode and you attach it to node1 in an AKS cluster:

  • Pod on Node 1: You can mount this volume in one or more pods running on node1. These pods can read from and write to the volume as needed.
  • Pod on Node 2: If a pod on node2 tries to mount the same volume, it won’t be able to, as it’s already in use on node1.

Use Case Example

For instance, a logging application running as a single pod on node1 needs to write logs to persistent storage. ReadWriteOnce works perfectly here as only one pod requires access.

If no pod on Node 1 is using the volume, it can be mounted on Node 2. This aligns with the "ReadWriteOnce" access mode, which allows a volume to be mounted as read-write by a single node at a time.

In Kubernetes, using Azure Disk or similar storage with node affinity supports this behavior. When a pod on Node 1 is terminated, the volume detaches from Node 1 and can attach to Node 2, allowing a pod on Node 2 to mount it. However, there might be a short delay in detaching and reattaching the volume, managed by Kubernetes with specified pod affinity rules and scheduling policies.

  • RWO: Ideal for single-instance applications needing exclusive access to storage.

2. ReadWriteMany (RWX)

A volume with ReadWriteMany access mode can be mounted as read-write by multiple nodes at the same time. This enables multiple pods on different nodes to read from and write to the same volume simultaneously.

Use Case: Useful for shared file systems, such as Azure Files or NFS, where multiple application instances require access to the same storage.

Example

Suppose you have a volume with ReadWriteMany access mode, attached to both node1 and node2:

  • Pod on Node 1: A pod running on node1 can mount this volume, reading and writing to it.
  • Pod on Node 2: A pod running on node2 can simultaneously mount the same volume and also read and write to it.

Use Case Example

A web application running in a cluster with multiple replicas on different nodes can share uploaded files, like user images or documents. With ReadWriteMany, each pod has access to the same storage volume, making it easier for them to view and update shared files.

  • RWX: Useful for applications with multiple instances across nodes that require shared storage access.

Comments

Popular posts from this blog

How to Create a PVC from Azure Files for Use in AKS

Deploy Apache Web Server Using Docker: A Step-by-Step Guide