Use UFS in UK8S
This document introduces how to use UFS as the underlying storage support for K8S in UK8S clusters. UFS is shared storage and can serve multiple Pods at the same time.
Prerequisites
-
Purchase a UFS instance and set up the mount point on the UFS product page. After the operation is completed, you will get the UFS mount address and directory, similar to 10.19.255.192:/ .
-
Cluster nodes install nfs-utils, using the command ”yum install -y nfs-utils”. UK8S nodes after May 1, 2019 are installed with nfs-utils by default.
-
UFS and UK8S clusters must be in the same VPC, otherwise the file system cannot be successfully mounted.
Create PV
You need to manually create persistent storage volumes within the cluster. There are two types of yaml examples as follows:
UFS Capacity
apiVersion: v1
kind: PersistentVolume
metadata:
name: ufspv4
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
path: /
server: 10.19.255.12 # Please modify to your UFS mount address
mountOptions:
- nolock
- nfsvers=4.0 # Must be consistent with the UFS protocol created
UFS SSD Performance
apiVersion: v1
kind: PersistentVolume
metadata:
name: ufspv4
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
path: /
server: 10.9.136.11 # Please modify to your UFS mount address
mountOptions:
- nolock
- nfsvers=4.0 # Must be consistent with the UFS protocol created
yaml key fields:
spec.nfs
spec.nfs.path Fill in the path of the UFS mount point here. Create PV through NFS, do not support automatic creation of subdirectories, you can pre-create a subdirectory.
spec.nfs.server Fill in the UFS mount address here
Create pv:
# kubectl apply -f ufspv.yml
persistentvolume/ufspv created
Create PVC
yaml example is as follows:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ufsclaim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 8Gi
After creating the PVC, you can find that PV and PVC are already bound.
# kubectl get pv ufspv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
ufspv 8Gi RWX Retain Bound default/ufsclaim
Mount UFS in Pod
apiVersion: v1
kind: Pod
metadata:
name: myufspod
spec:
containers:
- name: myfrontend
image: uhub.surfercloud.com/wxyz/uk8s-helloworld:1.8
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: ufsclaim
After the Pod is created, we can use the ”kubectl exec” command to enter the container, and execute the df command to check whether the pod is mounted to the UFS.
# df -h
Filesystem Size Used Avail Use% Mounted on
...
10.19.255.192:/ufs-w4wmpkev 1.0T 0 1.0T 0% /var/lib/kubelet/pods/c800f8a7-5c38-11e9-8aae-525400fa7819/volumes/kubernetes.io~nfs/ufs
...