NFS from AzureFile to OCP, usage in STS
working
Azure Storage Account
Follow steps on Azure and enable NFS on storageAccount
With NFS server enabled we need a provisioner, Openshift has no dynamic NFS provisioner (-OMG-).
For now I will step further and skip dynamic Persistence store definition and all PV will be created in advance.
BASE usage
[ openshift/PERSISTENCE/yaml/pv.yaml ]
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv0001
spec:
storageClassName: ""
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
nfs:
path: //xxxnfsxxx/pokusnynfsshare
server: xxxnfsxxx.file.core.windows.net
persistentVolumeReclaimPolicy: Retain
[ openshift/PERSISTENCE/yaml/pvc.yaml ]
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-claim1
spec:
storageClassName: ""
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
volumeName: nfs-pv0001
STS usage
STS is little tricky.
StatefulSet will create it’s own PersistentVolumeClaim for each pod so you don’t have to create one yourself. A PersistentVolume and a PersistentVolumeClaim will bind exclusively one to one. Your PVC is binding to your volume so any PVCs created by the StatefulSet can’t bind to your volume so it won’t be used.
In your case your PersistentVolume and the StatefulSet below should do the trick. Make sure to delete the PersistentVolumeClaim you created so that it’s not bound to your PersistentVolume. Also, make sure the storage class name is set properly below on your PV and in volumeClaimTemplates on your StatefulSet below or the PVC made by the StatefulSet may not bind to your volume.
[ openshift/PERSISTENCE/yaml/storageclass.yaml ]
# dummy storage class, NFS store must be created manualy
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: nfs-manualprovisioning
provisioner: nfsAzurefile
[ openshift/PERSISTENCE/yaml/sts-pv.yaml ]
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-testsub001
labels:
app: testsub
spec:
storageClassName: "nfs"
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
nfs:
path: //xxxnfsxxx/nfs-testsub001
server: xxxnfsxxx.file.core.windows.net
mountOptions:
- nolock
persistentVolumeReclaimPolicy: Delete
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-testsub002
labels:
app: testsub
spec:
storageClassName: "nfs"
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
nfs:
path: //xxxnfsxxx/nfs-testsub002
server: xxxnfsxxx.file.core.windows.net
mountOptions:
- nolock
persistentVolumeReclaimPolicy: Delete
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-testsub003
labels:
app: testsub
spec:
storageClassName: "nfs"
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
nfs:
path: //xxxnfsxxx/nfs-testsub003
server: xxxnfsxxx.file.core.windows.net
mountOptions:
- nolock
persistentVolumeReclaimPolicy: Delete
[ openshift/PERSISTENCE/yaml/sts.yaml ]
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: testsub
spec:
selector:
matchLabels:
app: testsub
replicas: 3
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: testsub
spec:
containers:
- name: testsub
image: busybox:latest
command: ["/bin/sh", "-c", "--"]
args: ["while true; do sleep 30;done;"]
volumeMounts:
- name: "data"
mountPath: /opt/nifi/data
subPath: data
- name: "data"
mountPath: /opt/nifi/nifi-current/auth-conf/
subPath: "auth-conf/bujaka"
- name: "data"
mountPath: /opt/nifi/flowfile_repository
subPath: "flowfile_repository"
- name: "data"
mountPath: /opt/nifi/content_repository
subPath: "content_repository"
- name: "data"
mountPath: /opt/nifi/provenance_repository
subPath: "provenance_repository"
- name: "data"
mountPath: /opt/nifi/nifi-current/logs
subPath: "logs"
- name: "data"
mountPath: /all
volumeClaimTemplates:
- metadata:
name: data
spec:
selector:
matchLabels:
app: testsub
accessModes: [ "ReadWriteOnce" ]
storageClassName: "nfs"
resources:
requests:
storage: 5G