Last active
June 26, 2020 16:33
-
-
Save tnk4on/19159c0932e7c0206925f4de65c98aee to your computer and use it in GitHub Desktop.
OCS4 with LocalStorage on 3-node OCP4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ocs4_and_localstorage_setup.sh | |
### 前提条件 ### | |
# OCP4.5構築済み(3-nodeクラスター) | |
# OCPクラスターはシャットダウン済み | |
# ------------------------------------------------------ # | |
### 1. インストール事前作業 ### | |
## 踏み台サーバーへSSH接続 | |
# テスト環境なのでrootで直接ログイン | |
ssh-add -K ~/.ssh/id_rsa | |
ssh -A [email protected] | |
cd OCP/ | |
## 仮想マシン事前設定 | |
# PowerCliコンテナ起動 | |
docker run --rm -it vmware/powerclicore | |
# ESXi接続 | |
Connect-VIServer -Server 192.168.1.101 -Force:$true | |
Get-VM -name master* | |
<< C.O. | |
# Snapshotの切り戻し(Name: preOCS) | |
$VMs = Get-VM -name master* | |
foreach($vm in $VMs){ | |
set-vm -vm $vm -Snapshot preOCS -Confirm:$false -RunAsync | |
} | |
C.O. | |
# CPU、Memory設定 | |
Set-VM -vm master* -NumCpu 12 -CoresPerSocket 12 -Confirm:$false | |
Set-vm -vm master* -MemoryGB 32 -Confirm:$false | |
# ハードディスクの追加 | |
$VMs = Get-VM -name master* | |
foreach($vm in $VMs){ | |
New-HardDisk -CapacityGB 1024 -StorageFormat:Thin -VM $vm | |
} | |
# disk.enableUUIDのパラメーター追加 | |
foreach($vm in $VMs){ | |
Get-vm $vm | New-AdvancedSetting -Name disk.enableUUID -Value 'TRUE' -confirm:$false | |
} | |
foreach($vm in $VMs){ | |
Get-vm $vm | Get-AdvancedSetting -Name disk.enableUUID | |
} | |
# 仮想マシンの起動(Masterのみ) | |
Get-VM -name master-* | Start-vm | |
## クラスターへのログイン | |
# kubeconfigのexport | |
export KUBECONFIG=/root/OCP/bare-metal/auth/kubeconfig | |
# クラスターの各種確認 | |
oc whoami | |
oc get nodes | |
# ---------------------------- # | |
### 2. LocalStorage Operatorの導入 ### | |
## ドキュメント:v4.3 日本語版 | |
# https://access.redhat.com/documentation/ja-jp/red_hat_openshift_container_storage/4.3/html/deploying_openshift_container_storage/installing-openshift-container-storage-using-local-storage-devices_rhocs | |
# ラベル付与 | |
oc label nodes master-0 cluster.ocs.openshift.io/openshift-storage='' | |
oc label nodes master-1 cluster.ocs.openshift.io/openshift-storage='' | |
oc label nodes master-2 cluster.ocs.openshift.io/openshift-storage='' | |
## Namespace作成 | |
oc create namespace local-storage | |
## LocalStorage Operatorのインストール | |
# GUIでOperatorHubからLocalStorageを検索 | |
## Local Disk IDの確認 | |
# https://access.redhat.com/solutions/4928841 | |
# Apply the DeamonSet with | |
oc apply -f https://raw.githubusercontent.com/dmoessne/ocs-disk-gather/master/ocs-disk-gatherer.yaml | |
# Podの起動確認 | |
oc get po -l name=ocs-disk-gatherer -n default | |
# To collect the disk information, execute the following command: | |
kubectl logs --selector name=ocs-disk-gatherer --tail=-1 --since=10m --namespace default | |
#To clean up, use | |
oc delete daemonsets ocs-disk-gatherer --namespace default | |
watch oc get po -l name=ocs-disk-gatherer -n default | |
## Option: Local Disk IDの手動確認 | |
# 公式ドキュメントに記載の手順。ocs-disk-gathererを使う場合は実施不要。 | |
oc debug node/master-0 | |
chroot /host | |
ls -l /dev/disk/by-id | |
exit | |
exit | |
oc debug node/master-1 | |
chroot /host | |
ls -l /dev/disk/by-id | |
exit | |
exit | |
oc debug node/master-2 | |
chroot /host | |
ls -l /dev/disk/by-id | |
exit | |
exit | |
## LocalVolumeの作成 | |
# GUIでLocalVolume作成 | |
# LocalStorageをファイルシステムとして利用するCR(local-storage-block.yaml) | |
# ================== local-storage-block.yaml ================== # | |
apiVersion: local.storage.openshift.io/v1 | |
kind: LocalVolume | |
metadata: | |
name: local-block | |
namespace: local-storage | |
spec: | |
nodeSelector: | |
nodeSelectorTerms: | |
- matchExpressions: | |
- key: cluster.ocs.openshift.io/openshift-storage | |
operator: In | |
values: | |
- "" | |
storageClassDevices: | |
- storageClassName: localblock | |
volumeMode: Block | |
devicePaths: | |
- /dev/disk/by-id/scsi-36000c2971c7455cfa9a475f5e1f7351f | |
- /dev/disk/by-id/scsi-36000c29eda91eb1dc336a2d98c2fd399 | |
- /dev/disk/by-id/scsi-36000c291b67bf04375fba95a58b6007d | |
# ============================================================== # | |
# ---------------------------- # | |
### 3. OpenShift Container Storage Operator導入 ### | |
# GUIで実施 | |
# OperatorHubからOpenShift Container Storageを検索、インストール | |
# https://access.redhat.com/documentation/en-us/red_hat_openshift_container_storage/4.4/html/deploying_openshift_container_storage/deploying-openshift-container-storage | |
# Waiting Pod up | |
watch oc get pod -n openshift-storage | |
## ベアメタルでの OpenShift Container Storage クラスターの作成 | |
# https://access.redhat.com/documentation/ja-jp/red_hat_openshift_container_storage/4.3/html/deploying_openshift_container_storage/installing-openshift-container-storage-using-local-storage-devices_rhocs#creating-openshift-container-storage-cluster-on-bare-metal_rhocs | |
## cluster-service-metal.yamlの確認 | |
cd /root/OCP/OCS | |
cat cluster-service-metal.yaml | |
# ==== cluster-service-metal.yaml === # | |
apiVersion: ocs.openshift.io/v1 | |
kind: StorageCluster | |
metadata: | |
name: ocs-storagecluster | |
namespace: openshift-storage | |
spec: | |
manageNodes: false | |
monDataDirHostPath: /var/lib/rook | |
storageDeviceSets: | |
- count: 1 | |
dataPVCTemplate: | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 500Gi | |
storageClassName: localblock | |
volumeMode: Block | |
name: ocs-deviceset | |
placement: {} | |
portable: false | |
replica: 3 | |
resources: {} | |
# =================================== # | |
# StorageCluster CR の作成 | |
oc create -f cluster-service-metal.yaml | |
# Waiting Pod up | |
watch oc get pod -n openshift-storage | |
# ---------------------------- # | |
### 4. イメージレジストリーの設定 ### | |
# https://access.redhat.com/documentation/ja-jp/red_hat_openshift_container_storage/4.3/html/managing_openshift_container_storage/configure-storage-for-openshift-container-platform-services_rhocs#configuring-image-registry-to-use-openshift-container-storage_rhocs | |
# Project を openshift-image-registry に設定します。 | |
# コンフィグを編集 | |
# Removed→Managed | |
# storage:{} → PVC設定 | |
oc edit configs.imageregistry.operator.openshift.io | |
<< C.O. | |
storage: | |
pvc: | |
claim: ocs4registry | |
C.O. | |
# ------------------------------------------------------ # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
このコードは、下記の動画の中で使用しています。
【Live Install】OCS4 with LocalStorage on 3-node OCP4 #tech4on
https://youtu.be/TynNGH0Buh0