Name
Last commit
Last update
..
.gitkeep k8s migration init
README.md k8s,swarm storage update

logo

Storage 구조에 대한 비교 및 검토

Docker Swarm과 K8s의 스토리지 구성을 비교하고, 도입 및 적용(NFS 스토리지)을 검토한다.

Docker Swarm

Swarm은 단순하게 다음과 같이 volume을 명시해주고, Stack을 실행하면 된다.

# cat docker-compose.yml
version: '3'
services:
  hongsnet:
       image: registry.hongsnet.net/joohan.hong/docker/hongsnet:latest
       volumes:
        - HOME:/home
        - EDU_DATA:/home/edu/public_html/HongsBoard/Data
        - EDU_EDITOR:/home/edu/public_html/HongsBoard/Web_editor/EDU"
        - EDU_FILE:/home/edu/public_html/HongsBoard/Web_editor/FILE"
        - HONGS_DATA:/home/hongsnet/public_html/Data"
        - HONGS_EDITOR:/home/hongsnet/public_html/Web_editor/FILE"
        - NEWSYSTEM_DATA:/home/newhongsystem/public_html/Data"
        - NEWSYSTEM_EDITOR:/home/newhongsystem/public_html/Web_editor/FILE"
       ports:
        - "80:80"
       deploy:
        mode: global
        placement:
          constraints: [node.hostname != TB2-DOCKER]
        update_config:
          parallelism: 5
          delay: 10s
        restart_policy:
          condition: on-failure
          max_attempts: 3
          window: 120s

volumes:
  HOME:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_SRC/home"
  EDU_DATA:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/EDU/Data"
  EDU_EDITOR:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/EDU/Web_editor/EDU"
  EDU_FILE:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/EDU/Web_editor/FILE"
  HONGS_DATA:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/HONGSNET/Data"
  HONGS_EDITOR:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/HONGSNET/Web_editor/FILE"
  NEWSYSTEM_DATA:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/NEWHONGSYSTEM/Data"
  NEWSYSTEM_EDITOR:
   driver_opts:
     type: "nfs"
     o: "addr=192.192.0.254,nolock,soft,rw"
     device: ":/WEB_DATA/NEWHONGSYSTEM/Web_editor/FILE"
# docker stack deploy --compose-file=docker-compose.yml web

K8s

K8s는 Swarm과 다르게, 다음과 같이 PV(persistentVolume),PVC(persistentVolumeClaim)라는 Volume으로 진행해야 한다.

생성 및 적용순서는 PV -> PVC -> Bound -> Use

  • PersistentVolume, PersistentVolumeClian Object 생성

다음과 같이 Ojbect를 생성하면 된다.

# cat nfs-volume.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
  name: webdata-edu-volume
  labels:
    type: local
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  mountOptions:
    - soft
    - timeo=600
    - noatime
    - _netdev
    - retrans=3
    - rsize=65536
    - wsize=65536
  nfs:
    server: "192.192.0.254"
    path: "/WEB_DATA/EDU/Data"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: webdata-edu-volume-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
  volumeName: webdata-edu-volume

---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: webeditor-edu-volume
  labels:
    type: local
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  mountOptions:
    - soft
    - timeo=600
    - noatime
    - _netdev
    - retrans=3
    - rsize=65536
    - wsize=65536
  nfs:
    server: "192.192.0.254"
    path: "/WEB_DATA/EDU/Web_editor/EDU"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: webeditor-edu-volume-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
  volumeName: webeditor-edu-volume

---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: webeditorfile-edu-volume
  labels:
    type: local
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  mountOptions:
    - soft
    - timeo=600
    - noatime
    - _netdev
    - retrans=3
    - rsize=65536
    - wsize=65536
  nfs:
    server: "192.192.0.254"
    path: "/WEB_DATA/EDU/Web_editor/FILE"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: webeditorfile-edu-volume-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
  volumeName: webeditorfile-edu-volume

여기서는 아래에 사용중인 모든 볼륨의 Object를 표시하지않고, 위와 같은 형식으로 추가한다.

# kubectl apply -f nfs-volume.yaml

현재 홍쓰넷에서 사용중인 Volume의 상태는 다음과 같다.

# kubectl get pv,pvc
NAME                                          CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                    STORAGECLASS   REASON   AGE
persistentvolume/webdata-edu-volume           100Gi      RWX            Retain           Bound    default/webdata-edu-volume-pvc                                   7h51m
persistentvolume/webdata-hongsnet-volume      100Gi      RWX            Retain           Bound    default/webdata-hongsnet-volume-pvc                              7h51m
persistentvolume/webdata-newsystem-volume     100Gi      RWX            Retain           Bound    default/webdata-newsystem-volume-pvc                             7h51m
persistentvolume/webeditor-edu-volume         100Gi      RWX            Retain           Bound    default/webeditor-edu-volume-pvc                                 7h51m
persistentvolume/webeditor-hongsnet-volume    100Gi      RWX            Retain           Bound    default/webeditor-hongsnet-volume-pvc                            7h51m
persistentvolume/webeditor-newsystem-volume   100Gi      RWX            Retain           Bound    default/webeditor-newsystem-volume-pvc                           7h51m
persistentvolume/webeditorfile-edu-volume     100Gi      RWX            Retain           Bound    default/webeditorfile-edu-volume-pvc                             7h51m
persistentvolume/websrc-home-volume           100Gi      RWX            Retain           Bound    default/websrc-home-volume-pvc                                   7h51m

NAME                                                   STATUS   VOLUME                       CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/webdata-edu-volume-pvc           Bound    webdata-edu-volume           100Gi      RWX                           7h51m
persistentvolumeclaim/webdata-hongsnet-volume-pvc      Bound    webdata-hongsnet-volume      100Gi      RWX                           7h51m
persistentvolumeclaim/webdata-newsystem-volume-pvc     Bound    webdata-newsystem-volume     100Gi      RWX                           7h51m
persistentvolumeclaim/webeditor-edu-volume-pvc         Bound    webeditor-edu-volume         100Gi      RWX                           7h51m
persistentvolumeclaim/webeditor-hongsnet-volume-pvc    Bound    webeditor-hongsnet-volume    100Gi      RWX                           7h51m
persistentvolumeclaim/webeditor-newsystem-volume-pvc   Bound    webeditor-newsystem-volume   100Gi      RWX                           7h51m
persistentvolumeclaim/webeditorfile-edu-volume-pvc     Bound    webeditorfile-edu-volume     100Gi      RWX                           7h51m
persistentvolumeclaim/websrc-home-volume-pvc           Bound    websrc-home-volume           100Gi      RWX                           7h51m