What asks for a default StorageClass
Kubernetes gives a claim that names no class the cluster’s default StorageClass. When the cluster has none, the claim’s
storageClassName stays unset until a default exists; see Default StorageClass in the Kubernetes documentation.
Before you start
- The cluster is connected and its agent is online. See Import a cluster.
- A storage driver for your infrastructure is installed in the cluster, such as your cloud’s CSI driver, or a storage system you run yourself. Ankra does not install one on a cluster you connect. You can install the driver’s chart as an add-on in a Stack so Ankra deploys and tracks it.
- The Ankra CLI, logged in to the right organisation. Creating a StorageClass needs
kubernetes.writeon the cluster.
Set the default
1
See what the cluster has
- Portal
- CLI
Open Infrastructure → Clusters → <your cluster> → Kubernetes → Storage Classes (
/next/clusters/<cluster-id>/kubernetes/storage/storage-classes). The list shows each class with its Provisioner, Reclaim policy and Volume binding. CSI Drivers, in the same Storage group, shows the drivers installed.The list has no column for the default class. Use the CLI to see which class carries the default annotation.2
Create a class if the cluster has none
Name the CSI driver that cuts the volumes with
--provisioner, and pass its own settings with --parameter. The driver’s documentation names both.--default marks the new class as the cluster’s default. Without --reclaim-policy, a class uses Delete, which destroys a volume’s data when its claim is deleted. See ankra cluster storage-classes create for every flag; --dry-run shows what would be created.Check: ankra cluster get storageclasses --cluster my-cluster lists the class with the provisioner you named.3
Or mark an existing class as the default
The default is one annotation on the StorageClass. Save this patch as Apply it to the class you want as the default, with the CLI or with your own Kubernetes tooling:If another class is already the default, set its annotation to
default-class.yaml:"false" the same way, so the cluster keeps one default. Kubernetes allows several, and then gives a claim with no class the most recently created default; see Change the default StorageClass.To keep the class in Git, declare the StorageClass with its annotation as a manifest in one of the cluster’s Stacks instead; see ImportCluster YAML Schema.Check: the YAML from the first step shows the annotation with "true" on exactly one class.4
Verify claims bind
WaitForFirstConsumer provisions a volume only once a pod uses the claim, so a claim with no pod yet stays Pending; see Volume binding mode.Check: the claims your add-ons and services created read Bound.Node-local volumes on one node and on many
Some provisioners keep each volume as a directory or a logical volume on the disk of the node the pod ran on. Ankra treats these as node-local:rancher.io/local-path, openebs.io/local, local.csi.openebs.io, topolvm.io, hostpath.csi.k8s.io, kubernetes.io/no-provisioner and similar. Check the Provisioner of your default class against them.
- On a single-node cluster, every volume lives on that one node’s disk. Losing the node or its disk loses the data. That suits a trial or a development cluster.
- On a cluster with several nodes, a volume stays on the node where its pod first ran, and the pod can only be scheduled on that node again. Draining, replacing or losing that node takes the data with it, and the pod waits for a node that no longer exists. See local volumes in the Kubernetes documentation.
What can go wrong
- A claim stays Pending. Read why with
ankra cluster get events --for persistentvolumeclaim/<claim-name> -n <namespace> --cluster my-cluster. With no default class, the claim names no class and nothing provisions it: set a default as above. - A claim named a class that does not exist. It stays Pending until a class of that name exists. Create the class with that name, or change the claim.
- Pipeline steps report
cache_volume_fallback. The pipeline cluster has no usable class for caches. Give it a default StorageClass, or name a class withankra cluster agent ci set --storage-class <class-name>. Runs from forks and tags never share caches, whatever the storage. - Two classes are marked default. New claims get the most recently created one. Set the annotation to
"false"on the class you do not want.
Where to go next
- Set up a managed service on the cluster now that it has a default StorageClass.
- Ankra Pipelines for the pipeline storage class and caches.
- Backups to protect the stateful Stacks on the cluster.