OpenShift CNSでgluster-blockを有効化する
OpenShiftではAnsibleのインベントリにglusterfsグループを定義するとCNSをセットアップしてくれる。
[glusterfs] node[01:03].example.com glusterfs_devices='[ "/dev/sda" ]'
しかしこの記述でセットアップされるのは普通のglusterfsファイルシステムマウントのみで、ブロックデバイスを提供するgluster-blockはprovisionerのみセットアップされるようだ。nodeホストのセットアップは行われないので、別に実行する必要がある。
CNSのドキュメントをみながらセットアップしてみる。
$ ansible nodes -b -a "yum install iscsi-initiator-utils device-mapper-multipath rpcdind -y" $ cat << EOF > multipath.conf device { vendor "LIO-ORG" user_friendly_names "yes" # names like mpatha path_grouping_policy "failover" # one path per group path_selector "round-robin 0" failback immediate path_checker "tur" prio "const" no_path_retry 120 rr_weight "uniform" } EOF $ ansible nodes -b -m copy -a "src=./multipath.conf dest=/etc/multipath.conf" $ ansible nodes -b -a "mpathconf --enable" $ ansible nodes -b -a "systemctl restart multipathd rpcbind" $ ansible nodes -b -a "systemctl enable multipathd rpcbind" $ oc project glusterfs $ oc delete pod --all
きちんと設定できていれば、DaemonSetのglusterfs pod内でgluster-blockdが起動する。oc rsh
してsystemctl status gluster-blockd
を確認すれば良い。
gluster-blockのstorageclassとsecretを定義する。secretはglusterfsで既に設定されているheketi-storage-admin-secretの値をそのまま流用した。
$ oc project glusterfs $ oc export secret heketi-storage-admin-secret > heketi-storage-admin-secret.yaml $ cp -a heketi-storage-admin-secret.yaml gluster-block-secret.yaml $ vi gluster-block-secret.yaml # change name and type $ diff heketi-storage-admin-secret.yaml gluster-block-secret.yaml 7,8c7,8 < name: heketi-storage-admin-secret < type: kubernetes.io/glusterfs --- > name: gluster-block-secret > type: gluster.org/glusterblock $ cat << EOF > gluster-block.yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: gluster-block parameters: resturl: http://heketi-storage-glusterfs.apps.s.nekop.io restuser: admin restsecretname: gluster-block-secret restsecretnamespace: glusterfs provisioner: gluster.org/glusterblock reclaimPolicy: Delete EOF $ oc create -f gluster-block-secret.yaml $ oc create -f gluster-block.yaml
PVCを作ってPVできればOK。できない場合はglusterfsプロジェクトのglusterblock-storage-provisioner-dc podのログを確認。
oc run sleep --image=registry.access.redhat.com/rhel7 -- tail -f /dev/null oc volume dc/sleep --add -t pvc --name=rwo-block --claim-name=rwo-block --mount-path=/rwo-block --claim-size=1Gi --claim-mode=ReadWriteOnce --claim-class=gluster-block oc get pvc -w