In Azure Kubernetes Service, the number of Azure Disks you can attach to a Node depends on the VM size. Eg. https://learn.microsoft.com/en-us/azure/virtual-machines/dv4-dsv4-series. See the data disks column.
I have pods that attach a disk using the disk.csi.azure.com
provisioner.
This works as long as there are less then 4 concurrent pods like that.
The fifth stalls and errors out, because the VM size we use only supports 4 disks.
How can I schedule pods with the disk limit in mind, such that the auto scaler scales up the cluster when the disk limit is reached on all the nodes?
Based on this I hoped AKS would expose this limit as an extended resource, but there is no hint of it in the capacity
status of the nodes.
Affinities seem to be binary rules for putting pods on the node; I see no way to model "at most x pods that do y can go to a node".
Edit for context: The pods are CI jobs generated by gitlab-runner. I want to use persistent volumes as build areas to avoid having to clone the entire project from scratch in every job. From the point of view of Kubenernetes this looks like dynamically generated Pods, each of which requests to mount one of a previously defined set of Persistent Volume Claims. The PVC:s are fungible (they cache the same clone), but the configuration forces us to request one by some specific name for each pod.
2
Answers
You will probably need to create a custom solution because AKS does not come with this capabilities by default.
In order to manage storage and disc attachment limits in the Azure Kubernetes Service, you can make use of Kubernetes Persistent Volumes and Persistent Volume Claims. These tools will help you manage storage in a more dynamic and abstracted manner.
Persistent Volume: A PV is a storage unit in the cluster that has either been provided statically using Storage Classes or by an administrator. The same as nodes and pods, PVs are resources in the cluster.
Continuous Volume Claim: A PVC is a user’s request for storage. It is comparable to a pod asking for CPU and memory. PVCs are utilised by pods and utilise PV resources.
If you use dynamic storage provisioning, create storage classes that outline the different "classes" of storage you want to provide. The type of underlying storage characteristics may be specified by a storage class.
Example of a Storage Class for AKS:
Apply the Storage Class to your cluster:
To request the storage you require, include PVCs in your Kubernetes pod setups. Your pods are connected to the underlying PVs by PVCs.
Example PVC :
4. Attach PVCs to Pods:
Refer to the PVCs you’ve defined in your pod setups. It connects the pod to the storage that was mentioned in the PVC.
Apply the pod to your cluster:
Here, the PVC called "my-pvc" is being used by the pod "my-pod" to request and access storage. The storage is mounted inside the pod at the path ‘/data’.
5. Scaling Pods :
Now, if you choose dynamic provisioning, Kubernetes will automatically provision extra PVs and connect them to the new pods through PVCs when you need to scale your application by adding more pods. As a result, you may manage storage dynamically without being concerned about node-specific disc attachment restrictions.
PODs auto scaling automatically when load increase.
Load Increase:
You can think about using S3 buckets instead of attached disks, they may be even better suited for high (unknown) number of pods requiring storage with pod-specific naming conventions.
Another possibility is to try out a topology spread constraint of the
topologyKey
"node", e.g.https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/#example-one-topologyspreadconstraint