Manually Provision Persistent Volumes
In a Kubernetes cluster where Persistent Volumes (PV) need to be provisioned manually, you can use a single node or distribute them among different Kubernetes nodes. You need to create the folder(s) in the designated node, and the associated PV should have the affinity configured to match the selected node name.
Create local folders. The following script assumes
/data
as the local folder where volumes will be created (distribute them among nodes as needed):#!/bin/bash sudo mkdir -p /data/agility-db-a1-pgdata sudo mkdir -p /data/agility-db-a1-pgwal sudo mkdir -p /data/agility-db-repo1 sudo mkdir -p /data/agility-minio sudo mkdir -p /data/data-0-agility-kafka-kafka-0 sudo mkdir -p /data/data-agility-kafka-zookeeper-0 sudo mkdir -p /data/data-agility-kafka-zookeeper-1 sudo mkdir -p /data/data-agility-kafka-zookeeper-2
Create the PV objects using the provided YAML manifests:
Ensure that you have the correct
storageClassName
,capacity
,accessModes
,hostPath
, andnodeAffinity
configured for each PV.Make sure to replace
NODE_NAME_HERE
with the actual node nameIf you have more than one Kubernetes node, create the necessary folders on each node and update the node affinity accordingly.
If different PV sizes were used in the overrides files, adjust the storage size as needed for each PV.
--- apiVersion: v1 kind: PersistentVolume metadata: name: agility-db-a1-pgdata labels: type: local spec: storageClassName: local-storage capacity: storage: 50Gi accessModes: - ReadWriteOnce hostPath: path: /data/agility-db-a1-pgdata nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: agility-db-a1-pgwal labels: type: local spec: storageClassName: local-storage capacity: storage: 50Gi accessModes: - ReadWriteOnce hostPath: path: /data/agility-db-a1-pgwal nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: agility-db-repo1 labels: type: local spec: storageClassName: local-storage capacity: storage: 50Gi accessModes: - ReadWriteOnce hostPath: path: /data/agility-db-repo1 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: agility-minio labels: type: local spec: storageClassName: local-storage capacity: storage: 50Gi accessModes: - ReadWriteOnce hostPath: path: /data/agility-minio nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: data-0-agility-kafka-kafka-0 labels: type: local spec: storageClassName: local-storage capacity: storage: 1Gi accessModes: - ReadWriteOnce hostPath: path: /data/data-0-agility-kafka-kafka-0 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: data-agility-kafka-zookeeper-0 labels: type: local spec: storageClassName: local-storage capacity: storage: 1Gi accessModes: - ReadWriteOnce hostPath: path: /data/data-agility-kafka-zookeeper-0 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: data-agility-kafka-zookeeper-1 labels: type: local spec: storageClassName: local-storage capacity: storage: 1Gi accessModes: - ReadWriteOnce hostPath: path: /data/data-agility-kafka-zookeeper-1 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE --- apiVersion: v1 kind: PersistentVolume metadata: name: data-agility-kafka-zookeeper-2 labels: type: local spec: storageClassName: local-storage capacity: storage: 1Gi accessModes: - ReadWriteOnce hostPath: path: /data/data-agility-kafka-zookeeper-2 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - NODE_NAME_HERE
Please refer to the Kubernetes documentation for more information on persistent volumes and configuring the PV objects.