How to create Local Persistent Volumes in Kubernetes Cluster

Step 1: create mount path on all worker nodes

Step 2: adjust the permissions of those mount directories

Step 3: create the persistent volume with this mount directory


create mount path on all worker nodes


DIRNAME="postgres"

mkdir -p /mnt/$DIRNAME


adjust the permissions of the mount directory


chcon -R unconfined_u:object_r:svirt_sandbox_file_t:s0 /mnt

chmod 777 /mnt/$DIRNAME


create the persistent volume with this mount directory


apiVersion: v1

kind: PersistentVolume

metadata:

name: postgres-pv

spec:

capacity:

storage: 2Gi

volumeMode: Filesystem

accessModes:

- ReadWriteOnce

persistentVolumeReclaimPolicy: Retain

storageClassName: local-storage

local:

# the directory path we created in step 1

path: /mnt/postgres

nodeAffinity:

required:

nodeSelectorTerms:

- matchExpressions:

- key: kubernetes.io/hostname

operator: In

values:

- {worker-node-host-name}



Nicole Hiller  |  Nana Janashia

Mail: info@nnsoftware.at

©2018 by nnSoftware

This site was designed with the
.com
website builder. Create your website today.
Start Now