Mount
You can mount File Storage instance to volumes of Virtual Machine instance and Kubernetes Engine.
Mount on Virtual Machine instance
Follow these steps to mount on Virtual Machine instance.
Connect to Virtual Machine instance
-
Go to KakaoCloud console > Beyond Compute Service > Virtual Machine.
-
In Instance menu, select [⋮] button of instance to mount > SSH connection.
-
In SSH connection popup, click [Copy] to copy execution command.
-
Use execution command to connect to instance. For details about SSH connection, refer to Virtual Machine > Create and connect instance.
Install NFS package
-
Check OS of instance and install NFS package using following commands.
- CentOS command
- Ubuntu command
sudo yum install -y nfs-utilssudo apt-get install nfs-commonIf NFS package is not installed, following error occurs. If error occurs, install package by referring to Install NFS package.
sudo: unable to resolve host for[Virtual Machine instance name]
mount: /home/deploy/nfs-mount: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program. -
Verify installation is completed successfully.
Mount NFS
-
Connect to Virtual Machine instance and create NFS mount directory.
mkdir {mount directory name} -
Enter command to verify directory creation.
ls -la -
Verify that nfs-mount directory is created.
drwxr-xr-x 2 deploy deploy 4096 Dec 13 06:17 nfs-mount -
Enter mount command using mount information (mount point) from instance details and created mount directory.
sudo mount -t nfs {File Storage instance private IP}:/{file share name} {created mount directory} -
Enter command to verify mount.
mount -
Verify that mount is successfully completed.
11.111.11.111:/share_storage on /home/deploy/nfs-mount type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.183.51.186,local_lock=none,addr=11.111.11.111)
Unmount NFS
Use following command to unmount NFS.
sudo umount {created mount directory}
Mount on Kubernetes Engine
Follow these steps to mount File Storage instance on Kubernetes Engine.
Allow NFS access
-
Enter command to check Worker Node IP of Kubernetes Engine.
kubectl --kubeconfig={kube_config} get nodes -o wide -
Check Worker Node IP.
Check worker node IP -
Configure Worker Node IP in File Storage access control settings.
- File Storage > Instance menu > Network tab > Configure access control to set allowed private IP addresses.
Create PV
-
Create yaml file for PV (Persistent Volume).
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-nfs-share-storage
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
nfs:
server: IP
path: /{file share name}
storageClassName: "nfs-share-storage" -
Apply PV yaml file to Kubernetes Engine.
kubectl --kubeconfig={kube_config} apply -f nfs-pv.yaml -
Verify application.
kubectl --kubeconfig={kube_config} get pv -
Verify that it is applied.
Verify PV application
Create PVC
-
Create yaml file for PVC (Persistent Volume Claim).
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-nfs-share-storage
spec:
storageClassName: "nfs-share-storage"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi -
Apply PVC yaml file to Kubernetes Engine.
kubectl --kubeconfig={kube_config} apply -f nfs-pvc.yaml -
Enter command to verify application.
kubectl --kubeconfig={kube_config} get pvc -
Verify that it is applied.
Verify PV application
Create deployment
-
Create Deployment yaml file to mount PVC to Pod.
apiVersion: apps/v1
kind: Deployment
metadata:
name: {deployment name}
spec:
selector:
matchLabels:
app: {label name}
replicas: 2
template:
metadata:
labels:
app: {label name}
spec:
containers:
- name: master
image: {user container url}
ports:
- containerPort: 77
volumeMounts:
- mountPath: /data/share-storage
name: pvc-volume
volumes:
- name: pvc-volume
persistentVolumeClaim:
claimName: pvc-nfs-share-storage -
Apply Deployment yaml file.
kubectl --kubeconfig={kube_config} apply -f deployment.yaml -
Verify application.
kubectl --kubeconfig={kube_config} get deployments -
Verify Deployment.
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-demo 2/2 2 2 1d -
Check Pods.
kubectl --kubeconfig={kube_config} get pods -
Verify Pods.
NAME READY STATUS RESTARTS AGE
nginx-demo- 1/1 Running 0 1d
nginx-demo- 1/1 Running 0 1d
Check mount status
-
Connect to Pod.
kubectl --kubeconfig={kube_config} exec -it pod name /bin/bash -
Enter command to check mount.
mount -
Verify mount is completed.
ip:/share_storage on /data/share-storage type nfs4 (rw,relatime,vers=4.2,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=ip,local_lock=none,addr=ip)