-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up Persistent Storage for the Connector Pods
To persistently store artifacts and ensure they are available even if the connector pod is down, you'll need to configure a Persistent Volume (PV) and a Persistent Volume Claim (PVC). Follow the steps below to set it up.
-
Persistent Volume (PV): A PV is a piece of storage in your cluster that has been provisioned by an administrator. It represents a physical or cloud storage resource, such as a disk or network file share. The PV provides a way to abstract storage and make it available to your applications in a Kubernetes cluster.
-
Persistent Volume Claim (PVC): A PVC is a request for storage by a user. It specifies the size and access modes of the storage required. A PVC will bind to a PV that meets its criteria, and once bound, it is used by the application. PVCs are used by pods to store data persistently, even if the pod is deleted or recreated.
Before creating the PV and PVC, you need to verify that there is enough storage available on your host machine.
-
Use the
df -h
command to view available storage:df -h
Example output:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 20G 30G 40% / /dev/sdb1 100G 10G 90G 10% /mnt/data
-
Identify a directory or disk with sufficient free space for the persistent volume (e.g.,
/mnt/data
). -
Create the directory for the PV:
sudo mkdir -p /mnt/data/ids-connector-pv sudo chmod 777 /mnt/data/ids-connector-pv
-
Create a
ids-connector-pv.yaml
file with the following content:apiVersion: v1 kind: PersistentVolume metadata: name: ids-connector-pv spec: capacity: storage: 10Gi # Size for the PV accessModes: - ReadWriteOnce # Access mode for the PV persistentVolumeReclaimPolicy: Retain # Keep the PV even if PVC is deleted hostPath: path: /mnt/data/ids-connector-pv # Path you created on the host
-
Apply the
ids-connector-pv.yaml
configuration to create the PV:microk8s kubectl apply -f ids-connector-pv.yaml
-
Create a
ids-connector-pvc.yaml
file with the following content:apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ids-connector-pvc namespace: provider-namespace # Same namespace as your connector pods spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi # Must match the PV's size volumeName: ids-connector-pv # Bind this PVC to the existing PV storageClassName: "" # This ensures it won't try to match a non-existent storage class
-
Apply the
ids-connector-pvc.yaml
configuration to create the PVC:microk8s kubectl apply -f ids-connector-pvc.yaml
-
Verify that the PV and PVC have been created and bound successfully:
microk8s kubectl get pv ids-connector-pv
Example output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE ids-connector-pv 10Gi RWO Retain Bound provider-namespace/ids-connector-pvc <unset> 126m
microk8s kubectl get pvc ids-connector-pvc -n provider-namespace
Example output:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE ids-connector-pvc Bound ids-connector-pv 10Gi RWO <unset> 69m
To reference the manually created PVC in your connector pod, update the values.yaml
file for your connector pod configuration.
-
Add/Update the
ids.persistentVolume
section invalues.yaml
:persistentVolume: name: ids-connector-pvc # Reference the manually created PVC mountPath: /resources # Path inside the container where data will be stored (default: /resources) storageSize: 10Gi # Match the PV and PVC size storageClassName: "" # Match the PV's storageClassName disableClaim: true # Prevent Helm from creating new PVCs
Note: The
mountPath
in thevalues.yaml
should point to/resources
or theids.artifacts.location
should point to themountPath
that you require. This is because the application needs to know where to put the artifacts on the disk from the perspective of the container to ensure the PVC is used. You can find more information regarding how thevalues.yaml
is written here: TSG Connector Helm Chart.
Once the pod is deployed, verify that it can correctly mount the persistent volume by checking the pod status and logs.
Also, try to add artifacts, then uninstall and re-install the connector to ensure that they still are there.