Juju operator storage

What is operator storage

Juju creates a so-called operator pod for each deployed application. The operator pod is responsible for running the charm hooks for each deployed unit’s charm. Each charm needs persistent storage so that charm state, resources etc can be preserved if the pod restarts.

Operator storage is mandatory

Juju must be able to allocate operator storage, but will use a suitable storage class already created on the cluster if one is available.

The easy way

Using existing storage class
Juju can use any storage class already created, according to a specified selection criteria. In order, Juju will look for a storage class:

  • with the label juju-storage=<appname>-operator-storage
  • with the label juju-storage=<modelname>-operator-storage
  • with the label juju-storage=default
  • with the annotation storageclass.kubernetes.io/is-default-class=true ie the cluster default

Bespoke Operator Storage Configuration

You can create a Juju storage pool called operator-storage with the provider type kubernetes, which will be used in preference to searching for an pre-existing storage class as outlined above. You may want to do this to provided customised storage for the operators.

AWS using EBS volumes

juju create-storage-pool operator-storage kubernetes storage-class=juju-operator-storage storage-provisioner=kubernetes.io/aws-ebs parameters.type=gp2

GKE using Persistent Disk

juju create-storage-pool operator-storage kubernetes storage-class=juju-operator-storage storage-provisioner=kubernetes.io/gce-pd parameters.type=pd-standard

AKS using Azure Disk

juju create-storage-pool operator-storage kubernetes storage-class=juju-operator-storage storage-provisioner=kubernetes.io/azure-disk parameters.storageaccounttype=Standard_LRS parameters.kind=Managed

microk8s using built-in hostPath storage

juju create-storage-pool operator-storage kubernetes storage-class=microk8s-hostpath

Any storage provisioner may be used. The only requirement is that the storage pool be named operator-storage.

1 Like

This is mainly to try and flesh out some details in the above post…

So if I have a default storage class setup on my Kubernetes cluster am I good to go here? Can I make a storage class in Kubernetes called operator-storage? If I have a bare metal MaaS deployment, how would I create a storage pool in Juju to use here?

Note that I am coming at this from the Kubernetes side and haven’t used Juju storage much, but it’s very possible that others would in the same boat. Maybe some links to Juju storage docs?

Juju can make use of existing storage classes set up in Kubernetes, but the preferred approach is to model things with Juju via storage pools. For MAAS, or any other substrate, you set the storage-provisioner attribute of the Juju storage pool to be that of the provisioner value you’d use with a Kubernetes storage class. So this storage pool:

juju create-storage-pool k8s-ebs kubernetes storage-class=juju-ebs storage-provisioner=kubernetes.io/aws-ebs parameters.type=gp2

Will result in Juju creating a storage class similar to:

kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
  name: k8s-ebs
provisioner: kubernetes.io/aws-ebs
  type: gp2

If you do want to set up a storage class outside of Juju, Juju can use that too. If you mark a storage pool as the default for the whole cluster, via the _storageclass.kubernetes.io/is_default_class_ annotation, that will be used. You can also use labels to tell Juju to use a particular storage class.

Juju will look for an existing storage class with the following characteristics and pick the first one it finds:

  1. storage class called “juju-operator-storage”
  2. storage class with label “juju-storage”, one of:
    • <app>-operator-storage
    • <model>
    • "default"
  3. storageclass.kubernetes.io/is-default-class

The above is for operator storage. For Juju units themselves, it’s similar.

  1. storage class called “juju-unit-storage”
  2. storage class with label “juju-storage”, one of:
    • <app>-unit-storage
    • <model>
    • "default"
  3. storageclass.kubernetes.io/is-default-class

Some general Juju storage doc is here. But it’s being migrated to discourse.

1 Like

Maybe it’s best to add the “static storage” option here. This is the place I went looking when I got the error in this post: Operator-storage for dev environment on kubernetes-core