Using Storage
KD clusters with storage
Some of the YAML file basenames in the deploy/example_clusters/
have a -stor
suffix. This is just a convention used among these example files to indicate that the virtual cluster spec requests persistent storage. Several of the examples have both persistent and non-persistent variants.
Note that if you are using persistent storage, you may wish to create a KubeDirectorConfig
object (as described in the next section configuring KD), for declaring a specific defaultStorageClassName
value.
Alternately, you can declare a storageClassName
in the persistent storage spec section of each virtual cluster spec. If no storage class value is declared in either the KubeDirectorConfig or the virtual cluster, then the K8s default storage class will be used.
Explore lab environment
Let's explore the lab environment, first StorageClasses
:
Next check if that are any PersistentVolumes
:
Finally, check for PersistentVolumeClaims
:
Deploy a cluster with default storage
We will deploy a ubuntu18.04 cluster with storage.
First we will change the configuration to support our lab environment.
- Edit
deploy/example_clusters/cr-cluster-ubuntu18.04-stor.yaml
- change both instances of
memory: "4Gi"
tomemory: "1Gi"
- change both instances of
CPU: "2"
toCPU: "1"
- change both instances of
Now deploy the cluster:
Let's take a look at the PersistentVolumes:
If we describe
the pv created for our Ubuntu 18.04 instance, we can find the storage location:
Finally, we can check the host folder contents:
We can see that the cluster's etc
and home
folders are persistent.
Deploy a cluster with custom storage
You can declare a
storageClassName
in the persistent storage spec section of each virtual cluster spec.
Here is the spec for deploy/example_clusters/cr-cluster-ubuntu18.04-stor.yaml
:
The KubeDirectorCluster spec has a definition for PersistentStorageSpec
. Inside that element, are the fields size
and storageClassName
.
It would appear that we can modify deploy/example_clusters/cr-cluster-ubuntu18.04-stor.yaml
to add the storageClassName as follows: