Skip to main content

Mount

You can mount a File Storage instance to Virtual Machine instances and the volumes of Kubernetes Engine.

Mount on Virtual Machine instance

Here's how to mount it on a Virtual Machine instance:

Connect to Virtual Machine instance

  1. Select the Virtual Machine menu in KakaoCloud Console.

  2. In the Instance menu, select the [More] icon to mount > Use SSH to connect.

  3. In the pop-up window, click the [Copy] icon to copy the command.

    Image. SSH Connection SSH connection

  4. Connect to the instance using the command. For detailed instructions on connecting to an instance using SSH, please refer to Virtual Machine > Create and connect instance.

Install NFS package

  1. After checking the OS of the instance, install the NFS package using the following command.

    CentOS
    sudo yum install -y nfs-utils
  2. Verify that the installation was completed successfully.

Mount NFS

  1. Connect to Virtual Machine instance and create an NFS mount directory.

    NFS Mount Directory
    mkdir {create mount directory name}
  2. Enter the command to check whether the mount directory is created.

    Command to check whether mount directory is created
    ls -la
  3. Confirm that the nfs-mount directory has been created as follows.

    Confirm directory creation
    drwxr-xr-x 2 deploy deploy 4096 Dec 13 06:17 nfs-mount
  4. Enter the mount information (mount point) that can be found in the instance details and the mount directory you created along with the mount command.

    Mount command
    sudo mount -t nfs {File Storage instance private IP}:/{file share name} {mount directory you created}
  5. Enter the command to check whether it is mounted.

    Mount confirmation command
    mount
  6. Verify that the mount completed successfully as follows:

    Confirm mount
    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

The NFS mount disconnect command is as follows:

NFS mount disconnect command
umount {mount directory you created}

Mount on Kubernetes Engine

Here's how to mount a File Storage instance in Kubernetes Engine:

Allow NFS access

  1. Enter the command to check the IP of the Kubernetes Engine Worker Node.

    Checking Worker Node IP
    $ kubectl --kubeconfig={kube_config} get nodes -o wide
  2. Check the IP of the Worker Node as shown below.

    image. Check Worker Node IP Check Worker Node IP

  3. Add the Worker Node’s IP using File Storage by navigating to File Storage > Instance > Network tab > Configure access control.

Create PV

  1. Create a yaml file for creating PV (Persistent Volume).

    Create yaml file
    apiVersion: v1
    kind: PersistentVolume
    metadata:
    name: pv-nfs-share-storage
    spec:
    capacity:
    storage: 1Gi
    accessModes:
    -ReadWriteMany
    nfs:
    server: enter IP
    path: /{file share name}
    storageClassName: "nfs-share-storage"
  2. Apply the created PV yaml file to Kubernetes Engine.

    Apply PV yaml file to Kubernetes Engine
    $ kubectl --kubeconfig={kube_config} apply -f nfs-pv.yaml
  3. Check whether it applies.

    Command to confirm application of PV yaml file to Kubernetes Engine
    $ kubectl --kubeconfig={kube_config} get pv
  4. You can check that it has been applied as follows.

    image. Check whether PV is applied Check whether PV is applied

Create PVC

  1. Create a Persistent Volume Claim (PVC) yaml file containing the persistent volume.

    Create PVC yaml file
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: pvc-nfs-share-storage
    spec:
    storageClassName: "nfs-share-storage"
    accessModes:
    -ReadWriteMany
    resources:
    requests:
    storage: 1Gi
  2. Apply the PVC yaml file to Kubernetes Engine.

    Apply PVC yaml file to Kubernetes Engine
    $ kubectl --kubeconfig={kube_config} apply -f nfs-pvc.yaml
  3. Enter the command to check application.

    Command to confirm application of PVC yaml file to Kubernetes Engine
    $ kubectl --kubeconfig={kube_config} get pvc
  4. You can check that it has been applied as follows.

    image. Check whether PV is applied Check whether PV is applied

Create deployment

  1. Create a deployment yaml file to mount a Persistent Volume Claim on a Pod deployed on Kubernetes Engine.

    Create Deployment yaml file
    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
  2. Apply the deployment yaml file to Kubernetes Engine.

    Apply Deployment yaml file to Kubernetes Engine
    $ kubectl --kubeconfig={kube_config} apply -f deployment.yaml
  3. Enter the command to check application.

    Command to confirm application of Deployment yaml file to Kubernetes Engine
    $ kubectl --kubeconfig={kube_config} get deployments
  4. Confirm that the following has been applied:

    Confirm Deployment yaml file applied to Kubernetes Engine
    NAME READY UP-TO-DATE AVAILABLE AGE
    nginx-demo 2/2 2 2 1d
  5. Enter the command to check the pod created by deployment.

    Pod confirmation command
    $ kubectl --kubeconfig={kube_config} get pods
  6. Check the created pod.

    Check Pod
    NAME READY STATUS RESTARTS AGE
    nginx-demo - 1/1 Running 0 1d
    nginx-demo - 1/1 Running 0 1d

Check whether it is mounted

  1. Connect to the created pod.

    Pod connection
    $ kubectl --kubeconfig={kube_config} exec -it pod name /bin/bash
  2. Enter the mount confirmation command.

    Mount confirmation command
    $ mount
  3. Confirm it is mounted.

    Confirm mount
    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)