티스토리 뷰

Cloud

GlusterFS & Heketi on Rhel7 설치 3

naleejang 2021. 1. 13. 16:17

지금까지 GlusterFS를 설치하고 Heketi를 설치하여 heketi-cli를 이용해 gluster에 볼륨이 생성되는지를 테스트해 보았다. 이는 전부 쿠버네티스를 이용하여 생성되는 컨테이너의 퍼시스턴트 볼륨으로 사용하기 위해서였다. 이번 포스팅에서는 앞에서 설치한 쿠버네티와 glusterfs 그리고 heketi를 연동하여 어떻게 컨테이너의 퍼시스턴스 볼륨으로 사용하는지에 대해 알아보겠다.

5. 쿠버네티스와 GlusterFS 연동

5.1 네트워크 연동 테스트

먼저 쿠버네티스 마스터 노드(여기서는 control 노드가 마스터 노드임)에 들어가서 heketi 서버로 통신이 되는지 ping 테스트를 먼저 해본다.

[root@control ~]# ping 192.168.0.199
PING 192.168.0.199 (192.168.0.199) 56(84) bytes of data.
64 bytes from 192.168.0.199: icmp_seq=1 ttl=64 time=0.198 ms
64 bytes from 192.168.0.199: icmp_seq=2 ttl=64 time=0.188 ms
64 bytes from 192.168.0.199: icmp_seq=3 ttl=64 time=0.245 ms
...

5.2 PV(Provision a Volume) 생성

통신 상태를 확인하고 볼륨을 생성하기 위한 pv(provision a volume)을 생성한다. pv는 스토리지 클래스를 말하며, 아래와 같이 yaml 파일을 생성할 디렉토리를 하나 만들어 그 안에서 파일을 생성하는 것이 좋다. pv를 만들때 secret를 별도로 만들어 heketi 서버의 사용자 패스워드 정보를 은닉할 수 있으나 여기서는 단순히 볼륨이 잘 만들어지는지 테스트를 할 예정이므로, 간단하게 heketi 서버 정보를 입력하여 아래와 같이 만들다.

[naleejang@rhel7 ~]$ mkdir glusterfs
[naleejang@rhel7 ~]$ cd glusterfs
[naleejang@rhel7 glusterfs]$ vi gfs-sc1.yaml 
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: "gluster-heketi"
provisioner: kubernetes.io/glusterfs
parameters:
  resturl: "http://192.168.0.199:8080"
  restuser: "admin"
  restuserkey: "keypassword"

그리고, kubectl apply 명령어를 이용하여 스토리지 클래스를 생성한다. 그리고, kubectl get sc 명령어를 이용하여 스토리지 클래스가 잘 생성되었는지 확인한다.

[naleejang@rhel7 glusterfs]$ kubectl apply -f gfs-sc1.yaml
[naleejang@rhel7 glusterfs]$ kubectl get sc
NAME             PROVISIONER               RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
gluster-heketi   kubernetes.io/glusterfs   Delete          Immediate           false                  10m
[naleejang@rhel7 glusterfs]$ 

5.3 PVC(Persistent Volume Claim) 생성

스토리지 클래스가 잘 생성되었으면 이번에는 볼륨 정보를 명시한 퍼시스턴스 볼륨 클레임을 생성한다. 여기서는 테스트이므로 1GB 의 볼륨을 생성할 예정이다.

[naleejang@rhel7 glusterfs]$ cat gfs-pvc.yml 
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: gvol-1
spec:
 storageClassName: gluster-heketi
 accessModes:
  - ReadWriteMany
 resources:
   requests:
     storage: 1Gi

볼륨 생성 정보를 명시한 pvc(persistent volume claim) yaml 파일을 생성했다면 이번에는 kubectl apply 명령어를 이용하여 볼륨 클레임을 생성한다. 그리고, kubectl get pvc 명령어를 이용하여 퍼시스턴스 볼륨 클레임이 잘 생성되었는지 확인한다.

[naleejang@rhel7 glusterfs]$ kubectl apply -f gfs-pvc.yml
[naleejang@rhel7 glusterfs]$ kubectl get pvc
NAME     STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS     AGE
gvol-1   Bound    pvc-b466a215-20a2-4e5c-a2e7-9ac1179f5007   1Gi        RWX            gluster-heketi   40m
[naleejang@rhel7 glusterfs]$

5.4 PVC를 사용한 Pod 생성 및 테스트

마지막으로 앞에서 만든 pvc를 이용하여 pod를 생성하는 deployment를 명시하는 파일을 아래와 같이 만들어보자.

[naleejang@rhel7 glusterfs]$ cat gfs-client.yml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gfs-client
spec:
  replicas: 2
  selector:
    matchLabels:
      app: ubuntu
  template:
    metadata:
      labels:
        app: ubuntu
    spec:
      containers:
      - name: ubuntu
        image: ubuntu
        volumeMounts:
        - name: gfs
          mountPath: /mnt
        command: ["/usr/bin/tail","-f","/dev/null"]
      volumes:
      - name: gfs
        persistentVolumeClaim:
          claimName: gvol-1

파드를 생성하기 위한 yml 파일을 생성했다면 이번에는 kubectl apply 명령어를 이용하여 아래와 같이 파드를 만들어보자. 그리고, kubectl get deploy,pod 명령어를 이용하여 디플로이먼트와 파드 목록을 확인한다.

[naleejang@rhel7 glusterfs]$ kubectl apply -f gfs-client.yml
[naleejang@rhel7 glusterfs]$ kubectl get deploy,pod
NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/gfs-client   2/2     2            2           31s

NAME                              READY   STATUS    RESTARTS   AGE
pod/gfs-client-6557c98dbd-2kbwv   1/1     Running   0          31s
pod/gfs-client-6557c98dbd-cvfjf   1/1     Running   0          31s
[naleejang@rhel7 glusterfs]$ 

파드가 정상적으로 잘 생성되어 STATUS가 Running 이라면 kubectl exec -ti 파드명 -- bash 명령어를 이용하여 파드안으로 들어간다. 그리고, df -h 명령어를 이용하면 볼륨에 마운트된 디렉토리 정보를 확인할 수 있다.

[naleejang@rhel7 glusterfs]$ kubectl exec -ti pod/gfs-client-6557c98dbd-2kbwv -- bash
root@gfs-client-6557c98dbd-2kbwv:/# df -h
Filesystem                                           Size  Used Avail Use% Mounted on
overlay                                               49G  3.8G   46G   8% /
tmpfs                                                3.9G     0  3.9G   0% /dev
tmpfs                                                3.9G     0  3.9G   0% /sys/fs/cgroup
192.168.0.202:vol_87615de8fccacdf5555e95fc220ed2da 1014M   43M  972M   5% /mnt
/dev/mapper/rhel-root                                 49G  3.8G   46G   8% /etc/hosts
...
root@gfs-client-6557c98dbd-2kbwv:/# 

이렇게 해서 쿠버네티스에서 퍼시스턴스 볼륨을 사용하기 위해 glusterfs를 설치하고 heketi를 설치하여 쿠버네티스에서 glusterfs에 연동하여 볼륨을 만들고 해당 볼륨이 마운트된 컨테이너를 생성해 봤다. 그리고, 지금까지 설치하면서 참조했던 문서들은 아래 사이트 주소를 남겨 놓는다. 

참조문서

https://access.redhat.com/documentation/en-us/red_hat_gluster_storage/3.5/html-single/installation_guide/index

https://access.redhat.com/documentation/en-us/red_hat_gluster_storage/3.5/html-single/administration_guide/index

https://computingforgeeks.com/setup-glusterfs-storage-with-heketi-on-centos-server/

https://computingforgeeks.com/configure-kubernetes-dynamic-volume-provisioning-with-heketi-glusterfs/

https://docs.openshift.com/container-platform/3.5/install_config/storage_examples/dedicated_gluster_dynamic_example.html

 

'Cloud' 카테고리의 다른 글

Hypervisor KVM 모니터링하기 2  (0) 2021.03.08
Hypervisor KVM 모니터링하기 1  (2) 2021.03.06
GlusterFS & Heketi on Rhel7 설치 2  (0) 2021.01.13
GlusterFS & Heketi on Rhel7 설치 1  (0) 2021.01.13
Kubernetes Cluster on Rhel7 설치 2  (1) 2020.12.31
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함