Skip to main content

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

  1. Go to KakaoCloud console > Beyond Compute Service > Virtual Machine.

  2. In Instance menu, select [⋮] button of instance to mount > SSH connection.

  3. In SSH connection popup, click [Copy] to copy execution command.

  4. Use execution command to connect to instance. For details about SSH connection, refer to Virtual Machine > Create and connect instance.

Install NFS package

  1. Check OS of instance and install NFS package using following commands.

    sudo yum install -y nfs-utils
  2. Verify installation is completed successfully.

Mount NFS

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

    mkdir {mount directory name}
  2. Enter command to verify directory creation.

    ls -la
  3. Verify that nfs-mount directory is created.

    drwxr-xr-x 2 deploy deploy 4096 Dec 13 06:17 nfs-mount
  4. 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}
  5. Enter command to verify mount.

    mount
  6. 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

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

    kubectl --kubeconfig={kube_config} get nodes -o wide
  2. Check Worker Node IP.

    image. Check worker node IP Check worker node IP

  3. Configure Worker Node IP in File Storage access control settings.

Create PV

  1. 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"
  2. Apply PV yaml file to Kubernetes Engine.

    kubectl --kubeconfig={kube_config} apply -f nfs-pv.yaml
  3. Verify application.

    kubectl --kubeconfig={kube_config} get pv
  4. Verify that it is applied.

    image. Verify PV application Verify PV application

Create PVC

  1. 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
  2. Apply PVC yaml file to Kubernetes Engine.

    kubectl --kubeconfig={kube_config} apply -f nfs-pvc.yaml
  3. Enter command to verify application.

    kubectl --kubeconfig={kube_config} get pvc
  4. Verify that it is applied.

    image. Verify PV application Verify PV application

Create deployment

  1. 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
  2. Apply Deployment yaml file.

    kubectl --kubeconfig={kube_config} apply -f deployment.yaml
  3. Verify application.

    kubectl --kubeconfig={kube_config} get deployments
  4. Verify Deployment.

    NAME         READY   UP-TO-DATE   AVAILABLE   AGE
    nginx-demo 2/2 2 2 1d
  5. Check Pods.

    kubectl --kubeconfig={kube_config} get pods
  6. Verify Pods.

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

Check mount status

  1. Connect to Pod.

    kubectl --kubeconfig={kube_config} exec -it pod name /bin/bash
  2. Enter command to check mount.

    mount
  3. 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)