The NetApp® Astra™ Trident storage orchestrator has long been meeting storage demands that arise in the Kubernetes world. As applications grow in complexity and organizations adapt to emerging DevOps trends, developers are forced to think outside the box. This creative thinking is necessary to solve the challenges that modern containerized workloads bring with them. Sharing PersistentVolumeClaims (PVCs) between Kubernetes namespaces is one such hurdle; the latest release of Astra Trident easily overcomes it.
Many Kubernetes resources are restricted to the namespace that they belong to. This limitation is true for PVCs, and for apps that are built based on the concept of shared resources, it poses a challenge. PersistentVolumes (PVs) that back PVCs, on the other hand, are cluster-scoped resources.
What apps can those be, you ask? Here are some examples:
Many approaches exist today, of which two are worth mentioning:
To summarize, the approaches detailed above lack some key requirements:
The latest Astra Trident release (v22.10) introduces a new feature that allows volumes to be shared across namespaces present in a Kubernetes cluster. Users can dynamically create a volume in a primary namespace and share it in one or more secondary namespaces, all through actions that are performed on Kubernetes. What is novel about the Trident approach is that it doesn’t require any additional intervention from a non-Kubernetes persona. Check out the following architectural diagram:
Read on to learn how it works.
To specify the namespace that a volume can be shared with, Trident uses annotations (provided in the PVC definition). Here’s an example:
Kind: PersistentVolumeClaim
apiVersion: v1
metadata:
annotations :
trident.netapp.io/shareToNamespace: secondary
name: primary-pvc
namespace: primary
spec:
accessModes:
- ReadWriteMany
storageClassName: trident
resources:
requests:
storage: 100Gi
Primary PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
annotations:
trident.netapp.io/shareFromPVC: primary/primary-pvc
name: secondary-pvc
namespace: secondary
spec:
accessModes:
- ReadWriteMany
storageClassName: trident
resources:
requests:
storage: 100Gi
Secondary PVC
The latest Trident release also introduces TridentVolumeReference (TVR), a Kubernetes Custom resource, for access control. A TVR must be created in the secondary namespace where a volume needs to be shared. Kubernetes administrators can restrict create privileges for the TVR resource, which enables admins to define a potentially narrow list of Kubernetes users who can create TVRs and share volumes.
The following example shows what a TVR looks like:
apiVersion: trident.netapp.io/v1
kind: TridentVolumeReference
metadata:
name: tvr-secondary-to-primary
namespace: secondary
spec:
pvcName: primary
pvcNamespace: primary
TridentVolumeReference
Give it a try today with the manifests provided here!
What happens when a parent volume is deleted and is shared across namespaces?
When secondary or subordinate volumes exist, parent volumes are “soft-deleted” (marked for deletion but not removed). The following example explains:
Thanks to annotations, it is easy and efficient to update existing multi-namespace manifests. Sharing of volumes still requires the following personas to coordinate, however: the primary volume owner (PVC annotations), the secondary data consumer (PVC annotations), and the Kubernetes cluster admin (authorization of TVR creation).
Check out the new features of Trident for yourself. Download Astra Trident and see what it can do. You can also view a demo of the feature here.