このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
06_virtualization:05_container:16_kubernetes_linstor [2022/04/17 06:28] – matsui | 06_virtualization:05_container:16_kubernetes_linstor [2022/07/07 23:06] (現在) – [3. Linstorインストール] matsui | ||
---|---|---|---|
行 35: | 行 35: | ||
</ | </ | ||
- | ====== 3. Linstorインストール ====== | + | ====== 3. LINSTORインストール ====== |
今回は3台でlinstor-controllerを冗長化するので、3台とも全部インストール | 今回は3台でlinstor-controllerを冗長化するので、3台とも全部インストール | ||
行 45: | 行 45: | ||
systemctl disable linstor-controller | systemctl disable linstor-controller | ||
+ | |||
+ | ===== 自動補完 ===== | ||
+ | |||
+ | # source / | ||
+ | # source / | ||
====== 4. Linstor初期化 ====== | ====== 4. Linstor初期化 ====== | ||
行 85: | 行 90: | ||
</ | </ | ||
- | ===== 確認 ===== | + | ===== storage-pool確認 ===== |
行 99: | 行 104: | ||
| linstor-pool | | linstor-pool | ||
+-----------------------------------------------------------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------------------------------+ | ||
+ | |||
+ | ===== 1つVolumeを作ってみる ===== | ||
+ | |||
+ | === TestVol01を作成 === | ||
+ | |||
+ | 流れは | ||
+ | - リソース定義を作成 | ||
+ | - ボリューム定義を作成 | ||
+ | - リソースを作成 | ||
+ | |||
+ | linstor resource-definition create TestVol01 | ||
+ | linstor volume-definition create TestVol01 1G | ||
+ | linstor resource create TestVol01 -s linstor-pool --auto-place 3 | ||
+ | |||
+ | たとえば、node2, | ||
+ | linstor resource create node2 node3 TestVol01 -s linstor-pool | ||
+ | linstor resource create node1 TestVol01 --diskless | ||
+ | |||
+ | === 確認 === | ||
+ | |||
+ | # linstor volume list -r TestVol01 | ||
+ | +----------------------------------------------------------------------------------------------------+ | ||
+ | | Node | Resource | ||
+ | |====================================================================================================| | ||
+ | | node1 | TestVol01 | linstor-pool | 0 | 1002 | / | ||
+ | | node2 | TestVol01 | linstor-pool | 0 | 1002 | / | ||
+ | | node3 | TestVol01 | linstor-pool | 0 | 1002 | / | ||
+ | +----------------------------------------------------------------------------------------------------+ | ||
+ | |||
+ | === ディスクを使ってみる === | ||
+ | |||
+ | mkfs.xfs / | ||
+ | mount / | ||
+ | # df /mnt | ||
+ | Filesystem | ||
+ | / | ||
+ | |||
+ | |||
+ | === マウントしているnode1のInUseがInUseに変更して、ディスクを利用している事が分かる === | ||
+ | |||
+ | # linstor volume list -r TestVol01 | sed ' | ||
+ | +----------------------------------------------------------------------------------------------------+ | ||
+ | | Node | Resource | ||
+ | |====================================================================================================| | ||
+ | | node1 | TestVol01 | linstor-pool | 0 | 1002 | / | ||
+ | | node2 | TestVol01 | linstor-pool | 0 | 1002 | / | ||
+ | | node3 | TestVol01 | linstor-pool | 0 | 1002 | / | ||
+ | +----------------------------------------------------------------------------------------------------+ | ||
+ | |||
+ | === 削除 === | ||
+ | |||
+ | umount /mnt | ||
+ | linstor volume-definition delete TestVol01 0 | ||
+ | linstor resource-definition delete TestVol01 | ||
+ | |||
+ | |||
+ | ====== 6.冗長化構成 ====== | ||
+ | |||
+ | linstorの情報は、/ | ||
+ | |||
+ | drbd-reactor で/ | ||
+ | |||
+ | これで、3つのノードどれかで、linstore-controllerが起動して、その他のlinstore-controllerは起動しないという設定が可能となります。 | ||
+ | |||
+ | ===== linstor_dbボリュームの用意 ===== | ||
+ | |||
+ | linstor resource-definition create linstor_db | ||
+ | linstor resource-definition drbd-options --on-no-quorum=io-error linstor_db | ||
+ | linstor resource-definition drbd-options --auto-promote=no linstor_db | ||
+ | linstor volume-definition create linstor_db 200M | ||
+ | linstor resource create linstor_db -s linstor-pool --auto-place 3 | ||
+ | |||
+ | ==== もしlinstor-controllerが動いている場合は、disableにして停止 ==== | ||
+ | |||
+ | systemctl disable --now linstor-controller | ||
+ | |||
+ | ==== linstore_dbマウントするsystemd用意 ==== | ||
+ | |||
+ | < | ||
+ | cat << EOF > / | ||
+ | [Unit] | ||
+ | Description=Filesystem for the LINSTOR controller | ||
+ | |||
+ | [Mount] | ||
+ | # you can use the minor like /dev/drbdX or the udev symlink | ||
+ | What=/ | ||
+ | Where=/ | ||
+ | EOF | ||
+ | </ | ||
+ | |||
+ | ==== linstor_dbをマウントしてlinstor-controller起動 ==== | ||
+ | |||
+ | < | ||
+ | mv / | ||
+ | mkdir / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | cp -r / | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== drbd-reactor用意 ===== | ||
+ | ※下記の手順は全てのノードで実行する。 | ||
+ | |||
+ | ==== install ==== | ||
+ | |||
+ | apt install drbd-reactor | ||
+ | |||
+ | ==== 起動順のファイル作成 ==== | ||
+ | |||
+ | < | ||
+ | cat << EOF > / | ||
+ | [[promoter]] | ||
+ | id = " | ||
+ | [promoter.resources.linstor_db] | ||
+ | start = [" | ||
+ | EOF | ||
+ | </ | ||
+ | |||
+ | ==== 一度drbd-reactor再起動 ==== | ||
+ | |||
+ | systemctl restart drbd-reactor | ||
+ | systemctl enable drbd-reactor | ||
+ | |||
+ | ===== linstor-satellite修正 ===== | ||
+ | |||
+ | linstor_dbボリュームに変更を加えないように設定変更 | ||
+ | |||
+ | < | ||
+ | # systemctl edit linstor-satellite | ||
+ | [Service] | ||
+ | Environment=LS_KEEP_RES=linstor_db | ||
+ | </ | ||
+ | |||
+ | ===== linstor-client.conf修正 ===== | ||
+ | |||
+ | どのノードでlinstor-controllerが動いていても良いように、linstor-client.confを修正しておく。 | ||
+ | |||
+ | < | ||
+ | # cat / | ||
+ | [global] | ||
+ | controllers=node1, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 確認 ===== | ||
+ | |||
+ | linstor_dbがPrimaryのノードでしか、linstor-controllerが起動しない事を確認 | ||
+ | |||
+ | < | ||
+ | # linstor controller which | ||
+ | linstor:// | ||
+ | |||
+ | # drbdadm status | ||
+ | linstor_db role: | ||
+ | disk: | ||
+ | worker02 role: | ||
+ | peer-disk: | ||
+ | worker03 role: | ||
+ | peer-disk: | ||
+ | |||
+ | node1# systemctl start linstor-controller.service | ||
+ | A dependency job for linstor-controller.service failed. See ' | ||
+ | |||
+ | node2# systemctl stop linstor-controller.service | ||
+ | node2# umount / | ||
+ | node2# # drbdadm secondary linstor_db | ||
+ | |||
+ | node1# drbdadm primary linstor_db | ||
+ | node1# # systemctl start linstor-controller.service | ||
+ | |||
+ | # linstor controller which | ||
+ | linstor:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== 確認(正常な動作) ===== | ||
+ | |||
+ | # cat / | ||
+ | version: 9.0.32-1 (api: | ||
+ | # linstor --version | ||
+ | linstor 1.13.0 | ||
+ | # drbd-reactor --version | ||
+ | drbd-reactor 0.6.0 | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | # linstor controller which | ||
+ | linstor:// | ||
+ | |||
+ | ## ノード再起動や、drbd-reactorを停止した状態で、linstor-controllerが停止 | ||
+ | node02:~# systemctl stop drbd-reactor.service | ||
+ | node02:~# systemctl stop linstor-controller.service | ||
+ | |||
+ | ## 即時に別のノードで、linstor-controllerが起動 | ||
+ | node01:~# linstor controller which | ||
+ | linstor:// | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== 7.Kubernetsから接続 ====== | ||
+ | |||
+ | |||
+ | ==== 大前提条件 ==== | ||
+ | |||
+ | Kubernetes helm インストール時下記の3つがlinstorインストールの前提の条件です。 | ||
+ | - kubernetes controller からPodのIPに通信できる事 | ||
+ | - Pod内から外部へ通信可能 | ||
+ | - Pod内で名前解決可能 | ||
+ | |||
+ | < | ||
+ | root@linstor-master: | ||
+ | NAME READY | ||
+ | alpine-test | ||
+ | root@linstor-master: | ||
+ | PING 10.224.1.2 (10.224.1.2) 56(84) bytes of data. | ||
+ | 64 bytes from 10.224.1.2: icmp_seq=1 ttl=63 time=0.959 ms | ||
+ | 64 bytes from 10.224.1.2: icmp_seq=2 ttl=63 time=0.679 ms | ||
+ | 64 bytes from 10.224.1.2: icmp_seq=3 ttl=63 time=0.506 ms | ||
+ | |||
+ | --- 10.224.1.2 ping statistics --- | ||
+ | 3 packets transmitted, | ||
+ | rtt min/ | ||
+ | |||
+ | root@linstor-master: | ||
+ | PING fl8.jp (182.48.51.190): | ||
+ | 64 bytes from 182.48.51.190: | ||
+ | 64 bytes from 182.48.51.190: | ||
+ | 64 bytes from 182.48.51.190: | ||
+ | |||
+ | --- fl8.jp ping statistics --- | ||
+ | 3 packets transmitted, | ||
+ | round-trip min/avg/max = 8.532/ | ||
+ | </ | ||
+ | ==== secret登録 ==== | ||
+ | |||
+ | < | ||
+ | kubectl create secret docker-registry drbdiocred --docker-server=drbd.io \ | ||
+ | --docker-username=[User] --docker-password=[Pass] | ||
+ | </ | ||
+ | |||
+ | ==== helm repository登録 ==== | ||
+ | |||
+ | < | ||
+ | helm repo add linstor https:// | ||
+ | # helm repo list | ||
+ | NAME URL | ||
+ | linstor https:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== linstor-opインストール ==== | ||
+ | |||
+ | < | ||
+ | helm install linstor-op linstor/ | ||
+ | --set operator.controller.enabled=false \ | ||
+ | --set etcd.persistentVolume.enabled=false \ | ||
+ | --set operator.etcd.enabled=false \ | ||
+ | --set controllerEndpoint=http:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== 確認 ==== | ||
+ | |||
+ | ちゃんとpodが起動してればOK | ||
+ | < | ||
+ | # kubectl get pod | ||
+ | NAME | ||
+ | alpine-test | ||
+ | linstor-op-csi-controller-76d5bcfcb9-z2mrw | ||
+ | linstor-op-csi-node-54wf6 | ||
+ | linstor-op-csi-node-9fcn9 | ||
+ | linstor-op-csi-node-rw4h5 | ||
+ | linstor-op-etcd-0 | ||
+ | linstor-op-ha-controller-6f9784f965-bqqcp | ||
+ | linstor-op-ns-node-74zjb | ||
+ | linstor-op-ns-node-ldc5q | ||
+ | linstor-op-ns-node-m7hcm | ||
+ | linstor-op-operator-7b9b9b685d-mnc8z | ||
+ | ubuntu | ||
+ | ubuntu-7c969d5f7d-lq96g | ||
+ | </ | ||
+ | |||
+ | ==== StorageClass作成 ==== | ||
+ | |||
+ | Kubernetes から利用する為に、StorageClass作成 | ||
+ | |||
+ | < | ||
+ | apiVersion: storage.k8s.io/ | ||
+ | kind: StorageClass | ||
+ | metadata: | ||
+ | # The name used to identify this StorageClass. | ||
+ | name: linstor-basic-storage-class | ||
+ | # The name used to match this StorageClass with a provisioner. | ||
+ | # linstor.csi.linbit.com is the name that the LINSTOR CSI plug-in uses to identify itself | ||
+ | provisioner: | ||
+ | volumeBindingMode: | ||
+ | parameters: | ||
+ | # LINSTOR will provision volumes from the drbdpool storage pool configured | ||
+ | # On the satellite nodes in the LINSTOR cluster specified in the plug-in' | ||
+ | storagePool: | ||
+ | resourceGroup: | ||
+ | # Setting a fstype is required for " | ||
+ | # Currently supported: xfs/ext4 | ||
+ | csi.storage.k8s.io/ | ||
+ | linstor.csi.linbit.com/ | ||
+ | </ | ||
+ | |||
+ | ==== PVC作成 ==== | ||
+ | |||
+ | < | ||
+ | kind: PersistentVolumeClaim | ||
+ | apiVersion: v1 | ||
+ | metadata: | ||
+ | name: linstor-volume-01 | ||
+ | spec: | ||
+ | storageClassName: | ||
+ | accessModes: | ||
+ | - ReadWriteOnce | ||
+ | resources: | ||
+ | requests: | ||
+ | storage: 3Gi | ||
+ | </ | ||
+ | |||
+ | |||
+ | === PVC作成した時点 === | ||
+ | |||
+ | PVC作成した時点ではまだPVは作成してない。 | ||
+ | |||
+ | < | ||
+ | # kubectl apply -f pvc.yaml | ||
+ | persistentvolumeclaim/ | ||
+ | |||
+ | # kubectl get pvc | ||
+ | NAME STATUS | ||
+ | linstor-volume-01 | ||
+ | |||
+ | # kubectl get pv | ||
+ | No resources found | ||
+ | |||
+ | # linstor volume list -p | ||
+ | +------------------------------------------------------------------------------------------+ | ||
+ | | Node | Resource | StoragePool | VolNr | MinorNr | DeviceName | Allocated | InUse | State | | ||
+ | |==========================================================================================| | ||
+ | +------------------------------------------------------------------------------------------+ | ||
+ | </ | ||
+ | ==== PodからPV利用 ==== | ||
+ | |||
+ | < | ||
+ | apiVersion: v1 | ||
+ | kind: Pod | ||
+ | metadata: | ||
+ | name: ubuntu | ||
+ | spec: | ||
+ | containers: | ||
+ | - image: ubuntu | ||
+ | name: ubuntu | ||
+ | command: [ "/ | ||
+ | args: [ "while true; do sleep 30; done;" ] | ||
+ | volumeMounts: | ||
+ | - name: linstor-volume | ||
+ | mountPath: /data | ||
+ | ports: | ||
+ | - containerPort: | ||
+ | volumes: | ||
+ | - name: linstor-volume | ||
+ | persistentVolumeClaim: | ||
+ | claimName: " | ||
+ | </ | ||
+ | |||
+ | |||
+ | === Pod作成すると、PVも作成される === | ||
+ | |||
+ | < | ||
+ | kubectl apply -f ubutnu.yaml | ||
+ | |||
+ | # kubectl get pv | ||
+ | NAME | ||
+ | pvc-c83e52e0-f8c7-447c-a3f2-8f01daaeb4c2 | ||
+ | |||
+ | # kubectl get pvc | ||
+ | NAME STATUS | ||
+ | linstor-volume-01 | ||
+ | |||
+ | # linstor volume list -p | ||
+ | +--------------------------------------------------------------------------------------------------------------------------------------------+ | ||
+ | | Node | Resource | ||
+ | |============================================================================================================================================| | ||
+ | | linstor-node04 | pvc-c83e52e0-f8c7-447c-a3f2-8f01daaeb4c2 | linstor-pool | 0 | 1000 | / | ||
+ | | linstor-node05 | pvc-c83e52e0-f8c7-447c-a3f2-8f01daaeb4c2 | linstor-pool | 0 | 1000 | / | ||
+ | | linstor-node06 | pvc-c83e52e0-f8c7-447c-a3f2-8f01daaeb4c2 | linstor-pool | 0 | 1000 | / | ||
+ | +--------------------------------------------------------------------------------------------------------------------------------------------+ | ||
+ | </ | ||
+ | |||
+ | |||
+ | === PVC削除 === | ||
+ | |||
+ | PVCを削除すると、ちゃんとlinstorで削除されている。 | ||
+ | |||
+ | < | ||
+ | # kubectl delete pod ubuntu | ||
+ | pod " | ||
+ | |||
+ | # kubectl get pvc | ||
+ | NAME STATUS | ||
+ | linstor-volume-01 | ||
+ | |||
+ | # kubectl delete pvc linstor-volume-01 | ||
+ | persistentvolumeclaim " | ||
+ | |||
+ | # linstor volume list -p | ||
+ | +------------------------------------------------------------------------------------------+ | ||
+ | | Node | Resource | StoragePool | VolNr | MinorNr | DeviceName | Allocated | InUse | State | | ||
+ | |==========================================================================================| | ||
+ | +------------------------------------------------------------------------------------------+ | ||
+ | </ | ||
{{tag> | {{tag> |