티스토리 뷰

Storage/System&Tools

Ceph-csi

Jacob_baek 2020. 4. 21. 22:16

Install 방법

기존 Ceph와 kubernetes가 존재한다는 가정하에 다음과 같은 과정을 거친다.
kubernetes는 v1.15.6 기반으로 진행했다.

Ceph에서 작업

우선 ceph node로 이동하여 ceph mon dump 명령을 통해 fsid와 mon ip들을 확인한다.

[root@ceph001 centos]# ceph mon dump
dumped monmap epoch 1
epoch 1
fsid 5369a8de-d612-49bc-a3ed-ab587ee403db
last_changed 2020-04-09 12:36:54.055450
created 2020-04-09 12:36:54.055450
min_mon_release 14 (nautilus)
0: [v2:10.10.210.220:3300/0,v1:10.10.210.220:6789/0] mon.ceph001
1: [v2:10.10.210.221:3300/0,v1:10.10.210.221:6789/0] mon.ceph002
2: [v2:10.10.210.222:3300/0,v1:10.10.210.222:6789/0] mon.ceph003

pool 생성

[root@ceph001 centos]# ceph osd pool create kubernetes 64
pool 'kubernetes' created
[root@ceph001 centos]# rbd pool init kubernetes
[root@ceph001 centos]# ceph auth get-or-create client.kubernetes mon 'profile rbd' osd 'profile rbd pool=kubernetes'
[client.kubernetes]
    key = AQBpuZ5eBGswKxAAtBmbiEsHwN3qj5T/uw7vtg==

kubernetes 에서 작업

이제 연동할 ceph-csi 를 가져온다.

[root@node1 ~]# git clone https://github.com/ceph/ceph-csi.git
[root@node1 ~]# cd ceph-csi
[root@node1 ceph-csi]# git checkout release-v2.1

아래 세가지 파일의 설정 변경이 필요하다.

  • csi-config-map.yaml

  • secret.yaml

  • storageclass.yaml

    파일의 경로는 아래 예제 코드에서 확인할수 있다.

csi-config-map.yaml는 ceph mon dump에서 출력되었던 fsid와 monitor ip:port정보를 기입한다.

[root@node1 ceph-csi]# cat deploy/rbd/kubernetes/csi-config-map.yaml 
---
apiVersion: v1
kind: ConfigMap
data:
  config.json: |-
    [
      {
        "clusterID": "5369a8de-d612-49bc-a3ed-ab587ee403db",
        "monitors": [
          "10.10.210.220:6789",
          "10.10.210.221:6789",
          "10.10.210.222:6789"
        ]
      }
    ]
metadata:
  name: ceph-csi-config

secret.yaml을 변경한다. 아래 정보는 앞서 ceph에서 생성했던 kubernetes ID와 그에 맞는 key를 추가한다.

[root@node1 ceph-csi]# cat example/rbd/secret.yaml
---
apiVersion: v1
kind: Secret
metadata:
  name: csi-rbd-secret
  namespace: default
stringData:
  # Key values correspond to a user name and its key, as defined in the
  # ceph cluster. User ID should have required access to the 'pool'
  # specified in the storage class
  userID: kubernetes
  userKey: AQBpuZ5eBGswKxAAtBmbiEsHwN3qj5T/uw7vtg==

  # Encryption passphrase
  encryptionPassphrase: test_passphrase

storageclass.yaml를 아래와 같이 수정한다. pool은 앞서 생성한 pool의 이름으로, clusterID는 ceph fsid를 입력한다.

[root@node1 ceph-csi]# cat examples/rbd/storageclass.yaml 
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: csi-rbd-sc
provisioner: rbd.csi.ceph.com
parameters:
   clusterID: 5369a8de-d612-49bc-a3ed-ab587ee403db
   pool: kubernetes

마지막으로 ceph-csi가 vault를 이용한 키관리를 하도록 변경되어 이 부분도 추가해야한다.
kms라 명명되어 있는 부분이며 기본 값을 그대로 사용해도 무방하기에 아래와 같이 생성을 진행한다.

[root@node1 ceph-csi]# kubectl create -f examples/kms/vault/kms-config.yaml 
configmap/ceph-csi-encryption-kms-config created

이제 앞서 수정했던 secret과 storageclass를 생성한다.

[root@node1 ceph-csi]# kubectl create -f examples/rbd/secret.yaml 
secret/csi-rbd-secret created
[root@node1 ceph-csi]# kubectl create -f examples/rbd/storageclass.yaml 
storageclass.storage.k8s.io/csi-rbd-sc created

이제 plugin-deploy.sh 스크립을 통해 ceph-csi 를 배포한다.

[root@node1 ceph-csi]# cd examples/rbd/
[root@node1 rbd]# ./plugin-deploy.sh

NOTE
참고로 plugin-deploy.sh는 deploy/rbd/kubernetes directory내 yaml 파일들을 배포한다.
만약 namespace를 추가로 하고자한다면 해당 yaml중 ClusterRole, ClusterRoleBinding와 같은 namespace를 가지지 않는 resource
생성과정이 있어 이에 대한 namespace를 분리하는 작업을 해야 한다.
하여 가능하면 default로 사용하는것을 권장한다.

배포가 완료되면 다음과 같은 pod가 확인된다.

[root@node1 ceph-csi]# kubectl get po
NAME                                         READY   STATUS    RESTARTS   AGE
csi-rbdplugin-748g6                          3/3     Running   0          33m
csi-rbdplugin-78nmv                          3/3     Running   0          33m
csi-rbdplugin-7rdms                          3/3     Running   0          33m
csi-rbdplugin-g5bns                          3/3     Running   0          33m
csi-rbdplugin-provisioner-5b55f4cf9f-5g98v   6/6     Running   0          33m
csi-rbdplugin-provisioner-5b55f4cf9f-h8hx4   6/6     Running   0          33m
csi-rbdplugin-provisioner-5b55f4cf9f-q5ddh   6/6     Running   0          33m
[root@node1 ceph-csi]# kubectl get sc
NAME         PROVISIONER        AGE
csi-rbd-sc   rbd.csi.ceph.com   27m
[root@node1 ceph-csi]# kubectl get secret
NAME                              TYPE                                  DATA   AGE
csi-rbd-secret                    Opaque                                3      29m
default-token-vr7rh               kubernetes.io/service-account-token   3      8d
rbd-csi-nodeplugin-token-xv2v9    kubernetes.io/service-account-token   3      35m
rbd-csi-provisioner-token-pvtzb   kubernetes.io/service-account-token   3      35m
[root@node1 ceph-csi]# kubectl get cm
NAME                             DATA   AGE
ceph-csi-config                  1      33m
ceph-csi-encryption-kms-config   1      38m

실제 배포방법을 정리해보면 다음과 같이 수행될수 있다.

# ceph-csi 를 clone 받은 경로라 가정
# 아래 file들 ceph 설정에 맞게 변경
# - deploy/rbd/kubernetes/csi-config-map.yaml
# - examples/rbd/storageclass.yaml
# - examples/rbd/secret.yaml
# deploy directory 하단의 yaml파일들은 plugin-deploy.sh가 create 수행

### create resources
kubectl create -f examples/kms/vault/kms-config.yaml
kubectl create -f examples/rbd/secret.yaml
kubectl create -f examples/rbd/storageclass.yaml

cd examples/rbd/
./plugin-deploy.sh


### delete resources
kubectl delete -f examples/rbd/storageclass.yaml
kubectl delete -f examples/rbd/secret.yaml
kubectl delete -f examples/kms/vault/kms-config.yaml

cd examples/rbd/
./plugin-teardown.sh

Test

실제 storage class를 이용한 pv 생성이 이루어지는지 확인해보자.

[root@node1 ceph-csi]# kubectl create -f example/rbd/pvc.yaml 
persistentvolumeclaim/rbd-pvc created
[root@node1 ceph-csi]# kubectl get pvc
NAME      STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
rbd-pvc   Bound    pvc-fb2a0315-802e-4e5f-a27e-8a280e20be59   1Gi        RWO            csi-rbd-sc     26m
[root@node1 ceph-csi]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM             STORAGECLASS   REASON   AGE
pvc-fb2a0315-802e-4e5f-a27e-8a280e20be59   1Gi        RWO            Delete           Bound    default/rbd-pvc   csi-rbd-sc              27m

NOTE
마지막으로 helm chart를 사용해서 배포하려할때 pvc에서 아래와 같이 storage class가 설정되어 있지 않다고 에러가 나는 경우가 있다.

no persistent volumes available for this claim and no storage class is set

이와 같은 경우는 ceph-csi 설정 당시 default로 구성하지 않은 경우 발생될수 있어 아래와 같이 default 설정을 추가하면 해결된다.

jacob@jacob-laptop:~/workspaces/manifest/spinnaker$ kubectl get sc
NAME         PROVISIONER        AGE
csi-rbd-sc   rbd.csi.ceph.com   22h
jacob@jacob-laptop:~/workspaces/manifest/spinnaker$ kubectl patch storageclass csi-rbd-sc  -p '{"metadata": { "annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
storageclass.storage.k8s.io/csi-rbd-sc patched
jacob@jacob-laptop:~/workspaces/manifest/spinnaker$ kubectl get sc
NAME                   PROVISIONER        AGE
csi-rbd-sc (default)   rbd.csi.ceph.com   22h

혹은 아래와 같은 line을 storageclass에 edit 하여 추가한다.

metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"

'Storage > System&Tools' 카테고리의 다른 글

Object Gateway with radosgw  (0) 2020.11.29
Ceph benchmark Test  (0) 2020.10.13
Ceph  (0) 2017.03.10
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
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
31
글 보관함