はじめに
本記事では、オンプレ環境でOpenShift Virtualizationを利用するにあたってOpenShiftをAssisted Installerを利用してOpenShift Clusterをセットアップする手順について記載します。
Virtualization機能は、3Node構成でControlとComputeが同居した環境でも利用できますが、本記事では5Node構成の環境を作成します。
永続ストレージの提供基盤としてNetAppのTridentを利用し、バックエンドストレージにはONTAPをiSCSIで利用する設定については別の記事で記載するといった内容になります。
OpenShiftのInstall操作自体は、過去の記事とほぼ同等になりますので、変更点以外は簡略化して記載します。
何をしたい?できる?
- Red Hat OpenShift Container Platform (OCP)の構築
- 5 Node構成で構築
OpenShift Virtualizationとは
OpenShift Virtualizationは、Red Hat OpenShiftプラットフォーム上で仮想マシン(VM)とコンテナを統合的に管理・運用するためソリューションで、従来のVMベースのアプリケーションとクラウドネイティブなコンテナアプリケーションを同じインフラ上で扱えるため、リソースの効率的な活用と運用の簡素化を実現します。
端的に言うと、コンテナのために用意されたOpenShift上で、仮想マシンも実行できるのがOpenShift Virtualizationというものになります。
記事における環境情報
本記事では、以下の環境で実施した内容となります。
OSやモジュールは以下の構成としています。
- ONTAP 9.18.1
- NetApp Trident 26.02.1
- Windows Server 2025 Hyper-V環境
- Red Hat Enterprise Linux 9.8
- OpenShift 4.21.17
設定手順
設定の流れとしては以下のような形になります。
1. 踏み台サーバとしてRHEL9の導入及びDNSサーバ設定
2. OpenShift用の Single Node仮想マシンを用意し Assist InstallでOpenshiftの導入
3. 踏み台サーバへOCコマンド導入やその他設定
本記事では社内機器で検証環境を構築するので、
組織の開発者向けに提供するRHEL for Business Developersという無償プログラムを利用する形になります。
(OpenShiftは60日間の評価版を利用となります)
1. 踏み台(CLI操作+DNSサーバ)となるLinux作成
Hyper-Vやそこで作成した仮想マシンでの作業を実施します。
1-3. 踏み台サーバのInstall
Hyper-V上で仮想マシンの作成を実施し、ダウンロードしたISOイメージを使用してRHEL9.8のInstallを実施します。
後々、踏み台サーバ上でWebブラウザの操作を実施したいので、ソフトウェアの選択ではGUIを指定してのInstallを実施します。
過去の記事とほぼ同等の内容になります。
SSHでログインを行い、Install情報を確認します。
本環境ではuser01というユーザで操作を実施しています。
> id
uid=1000(user01) gid=1000(user01) groups=1000(user01),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
> cat /etc/redhat-release
Red Hat Enterprise Linux release 9.8 (Plow)
1-4. RHELの登録し、パッケージをアップデート
踏み台サーバでRHELの登録を実施します。
> sudo rhc connect
Connecting ps-rh100.example.org to Red Hat.
This might take a few seconds.
Username: XXXXXX
Password: XXXXXX
● Connected to Red Hat Subscription Management
● Connected to Red Hat Insights
● Activated the Remote Host Configuration daemon
Successfully connected to Red Hat!
Manage your connected systems: https://red.ht/connector
インストール済みのパッケージをアップデートを実行します。
> sudo dnf update
サブスクリプション管理リポジトリーを更新しています。
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs) 18 MB/s | 117 MB 00:06
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 19 MB/s | 95 MB 00:05
(中略)
kernel-5.14.0-687.10.1.el9_8.x86_64 kernel-core-5.14.0-687.10.1.el9_8.x86_64
kernel-modules-5.14.0-687.10.1.el9_8.x86_64 kernel-modules-core-5.14.0-687.10.1.el9_8.x86_64
完了しました!
1-5. XRDPの有効化
OpenShiftをGUIで管理する際に、踏み台にリモートデスクトップ接続を行ってWebブラウザを使用する為、XRDPを導入しRDP(リモートデスクトップ)によるアクセスができるようにします。
# GUI サーバパッケージグループをインストール
> sudo dnf groupinstall "Server with GUI" -y
サブスクリプション管理リポジトリーを更新しています。
(中略)
完了しました!
# 起動時のデフォルトターゲットをGUIに設定
> sudo systemctl set-default graphical.target
# EPEL (Extra Packages for Enterprise Linux) リポジトリ有効化
> sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
サブスクリプション管理リポジトリーを更新しています。
(中略)
完了しました!
# XRDP をインストール
> sudo dnf install xrdp -y
サブスクリプション管理リポジトリーを更新しています。
Extra Packages for Enterprise Linux 9 - x86_64 13 MB/s | 21 MB 00:01
(中略)
完了しました!
システム起動時にも自動でXRDPが起動されるように設定します。
> sudo systemctl start xrdp
> sudo systemctl enable xrdp
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /usr/lib/systemd/system/xrdp.service.
RDP 接続できるように、3389/TCPをFiwareallで解放します。
# XDP用のPortの指定
> sudo firewall-cmd --permanent --add-port=3389/tcp
success
# 設定内容の再読み込み
> sudo firewall-cmd --reload
success.
# 設定状態の確認
> sudo firewall-cmd --list-ports --zone=public
3389/tcp
1-6. 踏み台サーバ上にDNSサーバの構築
control Planeとcompute node 間で、互いのノード名やAPIサーバーを特定する際や、インストール時にもDNSレコードの登録が必要となる為、踏み台サーバ上にDNSサーバの構築を実施します。
(別途仮想マシンを作成して用意してもいいが、手間を省く為に踏み台上で作成)
本記事では踏み台サーバ上でdnsmasqインストールを行い、DNSサービスを構築します。
# dnsmasqインストールを実施
> sudo dnf install -y dnsmasq
サブスクリプション管理リポジトリーを更新しています。
(中略)
完了しました!
dnsmasq設定を実施します。
本記事ではDNSのドメインとしてexample.orgを使用し、Openshiftクラスタ名はocp200とします。
IP等の環境情報は以下の通りに設定します。
| 名前 | IP | 役割 |
|---|---|---|
| rh200.example.org | 10.11.100.44 | DNSサーバ+踏み台サーバ |
| control-01.ocp200.example.org | 10.11.100.45 | OpenShift Control Node |
| control-02.ocp200.example.org | 10.11.100.46 | OpenShift Control Node |
| control-03.ocp200.example.org | 10.11.100.47 | OpenShift Control Node |
| compute-01.ocp200.example.org | 10.11.100.48 | OpenShift Compute Node |
| compute-01.ocp200.example.org | 10.11.100.49 | OpenShift Compute Node |
| api.ocp200.example.org | 10.11.100.60 | Kubernetes API |
| api-int.ocp200.example.org | 10.11.100.60 | Kubernetes API(内部通信) |
| .apps.ocp200.example.org | 10.11.100.61 | Ingress IP |
/etc/dnsmasq.confを以下のような形で作成します。
> sudo cat /etc/dnsmasq.conf
# ドメイン名を自動的にhostsに付与するか、/etc/hosts のエントリにドメイン追加が必要
expand-hosts
# 上位サーバに対して、プライベートIPアドレスの逆引き要求をしない
bogus-priv
# 上位DNSの設定ファイル
resolv-file=/etc/dnsmasq.resolv.conf
# DNS Server IP
listen-address=127.0.0.1,10.11.100.44
# Dnsmasq listen Port
port=53
# dnsmasqでCache Record
cache-size=150
# DNSクエリに対してのログを出力
log-queries
# ログの出力
log-facility=/var/log/dnsmasq.log
# カスタムドメインの追加
local=/example.org/
domain=example.org
# 正引き設定
address=/control-01.ocp200.example.org/10.11.100.45
address=/control-02.ocp200.example.org/10.11.100.46
address=/control-03.ocp200.example.org/10.11.100.47
address=/compute-01.ocp200.example.org/10.11.100.48
address=/compute-02.ocp200.example.org/10.11.100.49
address=/api.ocp200.example.org/10.11.100.60
address=/api-int.ocp200.example.org/10.11.100.60
address=/apps.ocp200.example.org/10.11.100.61
address=/rh200.example.org/10.128.215.44
# 逆引き設定
ptr-record=45.100.11.10.in-addr.arpa,control-01.ocp200.example.org
ptr-record=46.100.11.10.in-addr.arpa,control-02.ocp200.example.org
ptr-record=47.100.11.10.in-addr.arpa,control-03.ocp200.example.org
ptr-record=48.100.11.10.in-addr.arpa,compute-01.ocp200.example.org
ptr-record=49.100.11.10.in-addr.arpa,compute-02.ocp200.example.org
ptr-record=60.100.11.10.in-addr.arpa,api.ocp200.example.org
ptr-record=60.100.11.10.in-addr.arpa,api-int.ocp200.example.org
ptr-record=61.100.11.10.in-addr.arpa,apps.ocp200.example.org
ptr-record=44.100.11.10.in-addr.arpa,rh200.example.org
システム起動時にも自動でDNSが起動されるように設定します。
> sudo systemctl start dnsmasq
> sudo systemctl enable dnsmasq
Created symlink /etc/systemd/system/multi-user.target.wants/dnsmasq.service → /usr/lib/systemd/system/dnsmasq.service.
/etc/resolv.confの修正を実施します。
> cat /etc/resolv.conf
# Generated by NetworkManager
search example.org
nameserver 127.0.0.1
nameserver 8.8.8.8
DNS参照ができるように、DNSをFiwareallで解放します。
# DNSの指定
> sudo firewall-cmd --add-service dns --permanent
success
# 設定内容の再読み込み
> sudo firewall-cmd --reload
success.
# 設定状態の確認
> sudo firewall-cmd --list-service --zone=public
cockpit dhcpv6-client dns ssh
NetworkManager.confで以下のdns=dnsmasqを追記します。
> cat /etc/NetworkManager/NetworkManager.conf
# Configuration file for NetworkManager.
(中略)
[main]
#plugins=keyfile,ifcfg-rh
dns=dnsmasq
(中略)
サービスを再起動します。
> sudo systemctl restart NetworkManager
/etc/resolv.confが以下のように変更している事を確認します。
> cat /etc/resolv.conf
# Generated by NetworkManager
search example.org
nameserver 127.0.0.1
options edns0 trust-ad
dnsmasq が自身のキャッシュにないドメインを解決するために、8.8.8.8 などの外部DNSへ問い合わせるよう設定を記載します。
> cat /etc/dnsmasq.resolv.conf
nameserver 8.8.8.8
名前解決が正しくできることを確認します。
# IPから名前を参照できる事の確認
> dig @10.11.100.44 +short -x 10.11.100.45
control-01.ocp200.example.org.
# 名前からIPを参照できる事の確認
> dig @10.11.100.44 +short api.ocp200.example.org
10.128.215.60
# 外部の名前からIPを参照できる事の確認
> dig @10.11.100.44 +short qiita.com
18.65.207.100
18.65.207.4
18.65.207.34
18.65.207.93
1-7. SSH公開鍵の作成
次項からのOpenShiftの導入において、踏み台サーバで作成したSSH公開鍵の登録を行う必要があるのでSSH公開鍵を作成します。
> ssh-keygen -t rsa -b 4096 -N ''
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user01/.ssh/id_rsa):
Created directory '/home/user01/.ssh'.
Your identification has been saved in /home/user01/.ssh/id_rsa
Your public key has been saved in /home/user01/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:chcTDUoKsniY150/BzWpf2soRFOtfBL/qV2zBjRdYM0 user01@rh200.example.org
The key's randomart image is:
+---[RSA 4096]----+
| . . . == o+ |
| + + o + o+oo. E|
|+ + . + o+o+ . .|
| o .+.+ooo . |
| ..Sooo.... |
| o.+. ..o..|
| . o +..o|
| . . + .o |
| . . . |
+----[SHA256]-----+
公開鍵が作成されている事を確認します。
> pwd
/home/user01
> ls -al .ssh/
合計 8
drwx------. 2 user01 user01 38 6月 7 22:43 .
drwx------. 5 user01 user01 123 6月 7 22:43 ..
-rw-------. 1 user01 user01 3389 6月 7 22:43 id_rsa
-rw-r--r--. 1 user01 user01 750 6月 7 22:43 id_rsa.pub
2. OpenShiftの導入
本記事ではOpenShiftのInstallについて、Red Hat Hybrid Cloud コンソールにログインしてAssisted Installerを使用して実施します。
2-1. 5Node分の仮想マシンの作成
要件に従って、以下のサイズの仮想マシンをHyper-V上で作成します。
(本記事ではStorageは大き目に作成しています)
管理に使用するControl Nodeは以下の構成で3Node分作成します。
| コンポーネント | 設定値 |
|---|---|
| CPU | 8 vCPU |
| Memory | 16G |
| Storaeg | 200G |
| MACアドレス | 00:15:5D:DD:DD:AA~00:15:5D:DD:DD:CC |
VMやPodの載る事になるCompute Nodeは以下の構成で2Node分作成します。
| コンポーネント | 設定値 |
|---|---|
| CPU | 8 vCPU |
| Memory | 24G |
| Storaeg | 200G |
| MACアドレス | 00:15:5D:DD:DD:DD~00:15:5D:DD:DD:EE |
また、OpenShiftのAssisted Installerg画面でMACアドレスとIPの入力を行うので、作成した仮想マシンのMACアドレスを静的な形で作成します。
(Hyper-VでVM作成なので、ベンダーコードはマイクロソフトにしてます)
Compute NodeについてはHyper-Vの仮想マシン上で仮想化を利用する形になるので、Hyper-Vを提供しているWindows Server上のPowershellで入れ子の設定を実施します
PS C:\> Set-VMProcessor -VMName "Z02-Compute01" -ExposeVirtualizationExtensions $true
PS C:\> Set-VMProcessor -VMName "Z02-Compute02" -ExposeVirtualizationExtensions $true
2-2. Assisted Installerへのアクセス
OpenShiftのインストールにあたってはRed Hat Hybrid Cloudで設定情報を入力し、
ISOファイルを作成してから、仮想マシンで作成したISOを接続して起動させる事で導入を進めるような形になります。
まずは、インターネット接続可能な作業用端末のブラウザからRed Hat Hybrid Cloud コンソールへアクセスを行います。
画面左側の[Resources]から[Assisted Installer]を選択して、表示された中央の画面で[Create Cluster]をクリックします。

2-3. Assisted InstallerでClusterの作成
本記事では、踏み台のDNSサーバはXXXXX.ocp200.example.orgのような形でOpenShiftを登録しているので、Cluster名はocp200で、base domainはexample.orgと指定します。
また、OpenShiftのversionは4.21.17で進めます。
Number of control plane nodesを3(highly available cluster)を指定します。
(Control Node数の指定なので3)
また、本記事ではIPを固定で設定するので、Hosts' network configurationは[Static IP, bridges, and bonds]を選択し、画面下方の[Next]をクリックします。
Static network configurationsの画面で、踏み台兼DNSとして作成したサーバのIP、ネットワークセグメント、デフォルトゲートウェイの入力を実施します。
OpenShiftのNodeに設定するMACアドレスとIPを入力します。
(DNSに登録したIPと仮想マシン作成時に静的に指定したMACアドレスを入力)
1 Node分の入力が完了後に、[Add another host configuration]をクリックし他のNode分についての入力を実施します。
後でVirtualization機能を追加するので、ここではOperatorsを何も指定せずに[Next]をクリックします。
Host discoveryでは[Add host]をクリックします。

表示された画面で、Provisioning typeはFull image Fileを選択します。
また、SSH public keyでは、[1-7. SSH公開鍵の作成]の踏み台サーバで作成したSSH公開鍵のコピーを実施し、[Generate Discovery ISO]をクリックします。

ダウンロードしたISOを用意しておいた仮想マシンに接続し、仮想マシンを起動します。

Assisted Installerの画面に戻り、起動したNodeを認識している事を確認し、Role列の[Auto-assign]をクリックして、個々のNodeに役割を選択し、[Next]をクリックします。
Storageの項目では特に何も操作せずに、[Next]をクリックします。

本記事ではNetworkingの項目で、DNSに設定しておいたAPI IPとIngress IPのIPを入力します。
Machine networkを10.X.X.Xの使用をする為、
[Use advanced networking]にチェックを入れて、Cluster network CIDRを192.168.0.0/16に変更します。
(Cluster network CIDRがデフォルトで使用する10.X.X.Xを変える)

Custom manifestsは特に指定せずに[Next]をクリックします。

Review and createの画面で、 preflight checksが通っている事を確認し、
画面下方の[Install cluster]をクリックします。


Install完了後に、踏み台サーバからOpenShiftを操作する為のkubeconfigのダウンロードと
初回でGUIアクセスを行い際に利用するkubeadminのパスワードをメモしておきます。
3. OpenShiftの導入後作業
踏み台サーバからocコマンドで操作できるようにする為の設定等を実施します。
3-1 ocコマンドの導入
作業PCから踏み台サーバにリモートデスクトップ接続を実施し、ブラウザを起動します。

ブラウザからOpenShiftのInstall完了時に表示されていたWeb Console URLに控えて置いたkubeadminでログインを行い、画面右上の[?]から[コマンドラインツール]を選択します。

表示された画面からOpenShift Command Line Interface (OC)のダウンロードを実施します。
本記事の環境では、踏み台サーバをRHEL9.8で作成しているので、[Download oc for Linux for x86_64 - RHEL 9]を使用します。
踏み台サーバのコンソールを立ち上げるかSSHで接続して、ダウンロードしたものを作業フォルダに移動させます。
> mkdir work
> mv ダウンロード/oc.rhel9.tar work/
> ls work/
oc.rhel9.tar
tarを展開します。
> cd work/
> tar -xvf oc.rhel9.tar
oc.rhel9
OpenShiftをInstall後にDownloadしておいたkubeconfigファイルを
踏み台サーバにSSH SCPなどを使ってアップロードしておきます。
> mkdir auth
> ls -l auth/
合計 12
-rw-r--r--. 1 user01 user01 12128 6月 8 01:26 kubeconfig
oc.rhel9だと使いにくいので、ocにRenameしてから、プログラム名だけで実行できるようにPATHを通します。
# Renameの実施
> ls -l
合計 398768
drwxr-xr-x. 2 user01 user01 24 6月 8 13:20 auth
-rwxr-xr-x. 1 user01 user01 139965608 5月 20 14:15 oc.rhel9
-rw-r--r--. 1 user01 user01 139970560 6月 8 13:17 oc.rhel9.tar
> mv oc.rhel9 oc
#$PATHの後に/home/user01/workを追加する
> cd
> pwd
/home/user01
> cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH:/home/user01/work"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. "$rc"
fi
done
fi
unset rc
ログインし直すとocのみでコマンドが実施できるようになります。
KUBECONFIG環境変数をセットして、ocコマンドでInstallしたOpenShiftの状態について確認します。
> export KUBECONFIG=${HOME}/work/auth/kubeconfig
> oc cluster-info
Kubernetes control plane is running at https://api.ocp200.example.org:6443
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
> oc get nodes
NAME STATUS ROLES AGE VERSION
compute-01.ocp200.example.org Ready worker 12h v1.34.8
compute-02.ocp200.example.org Ready worker 12h v1.34.8
control-01.ocp200.example.org Ready control-plane,master 12h v1.34.8
control-02.ocp200.example.org Ready control-plane,master 12h v1.34.8
control-03.ocp200.example.org Ready control-plane,master 12h v1.34.8
3-2 アイデンティティプロバイダー(IdP)設定
OpenShiftのGUIへkubeadminユーザでアクセスしていたかと思いますが、
GUIの上方に記載されているようにkubeadminユーザは一時的な管理ユーザとなる為、OAuth 設定を行います。
OpenShiftにおけるIdPは、クラスターへのアクセスユーザーを認証(IDとパスワードの検証)する外部システムまたはメカニズムで、OAuthサーバーと連携し、LDAP、OpenID Connect、htpasswdなどを用いてユーザーの信頼性を確認し、セキュアなアクセスを管理する役割を担います。
本記事では、テスト・小規模用のhtpasswd設定を実施します。
最初に、BASIC認証をかける時に必要な「.htpasswd」ファイルを作成します。
# htpasswdが利用できない場合は、事前にhttpd-toolsを導入します
> sudo dnf install httpd-tools
サブスクリプション管理リポジトリーを更新しています。
(中略)
完了しました!
# 指定するXXXXXX部分のPasswordは各自で設定してください
> pwd
/home/user01/work/auth
> htpasswd -c -B -b users.htpasswd ocadmin XXXXXX
Adding password for user ocadmin
> ls
kubeconfig users.htpasswd
htpasswdファイルが含まれるSecretオブジェクトを作成します。
# 作成前の状態
> oc get secret -n openshift-config
NAME TYPE DATA AGE
etcd-client kubernetes.io/tls 2 12h
initial-service-account-private-key Opaque 1 12h
pull-secret kubernetes.io/dockerconfigjson 1 12h
webhook-authentication-integrated-oauth Opaque 1 12h
# 作成の実施
> oc create secret generic htpass-secret --from-file=htpasswd=users.htpasswd -n openshift-config
secret/htpass-secret created
# 作成後の状態
> oc get secret -n openshift-config
NAME TYPE DATA AGE
etcd-client kubernetes.io/tls 2 12h
htpass-secret Opaque 1 30s
initial-service-account-private-key Opaque 1 12h
pull-secret kubernetes.io/dockerconfigjson 1 12h
webhook-authentication-integrated-oauth Opaque 1 12h
htpasswdのカスタムリソース(CR)を作成します。
これはhtpasswd IdPのパラメーターと許可される値を定義したものとなり、 oauth_cr.yamlというファイル名で作成します。
> cat oauth_cr.yaml
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: my_htpasswd_provider
mappingMethod: claim
type: HTPasswd
htpasswd:
fileData:
name: htpass-secret
> oc apply -f oauth_cr.yaml
Warning: resource oauths/cluster is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by oc apply. oc apply should only be used on resources created declaratively by either oc create --save-config or oc apply. The missing annotation will be patched automatically.
oauth.config.openshift.io/cluster configured
htpasswdの作業時に作成したユーザocpadminをクラスター管理者として定義します。
> oc create clusterrolebinding admin --clusterrole=cluster-admin --user=ocadmin
clusterrolebinding.rbac.authorization.k8s.io/admin created
OpenShiftのGUIでocpadminによるログインを確認します。
ログイン時にはmy_htpassword_providerの方を選択して実施します。
参考及びリンク
Trident + OpenShift: A NetApp + Red Hat solution to dynamically provision storage for OpenShift
OpenShiftコンテナ環境でTrident + ONTAP利用①【OpenShift Single Node環境の構築】





















