macOSにRed Hat OpenShift 4 CodeReadyコンテナーを導入す
OpenShiftとは、Red Hat社が提供しているKubernetes(以下、k8s)コンテナプラットフォームです。
詳しくは以下を参照ください。
https://www.redhat.com/ja/technologies/cloud-computing/openshift
CodeReadyコンテナーとは
K8sやOpenShiftでは、通常は複数のマスターノード・ワーカーノードで構成されているので、複数台の仮想マシンが準備できる環境が必要であったり、仮想マシンの作成からK8s・OpenShiftの導入作業など、初心者が試すにはちょっと敷居の高いものがあります。
CodeReadyコンテナー(以下、CRC)とは、K8sにおける「Minikube」「MicroK8s」のように、軽量のOpenShift環境でPCに手軽にインストールして機能を試せます。
OpenShiftの種類
OpenShiftで検索すると、色々なエディションや提供形態があり初心者はちょっと混乱します。簡単に整理すると、、、
Red Hat OpenShift
Red Hatが提供する製品版。提供形態により以下3種類があります。
・OpenShift Container Platform
自社のサーバ等に導入するソフトウェア版。
・OpenShift Dedicated
AWS・Azure等のパブリッククラウドで提供されるPaaS版。パブリッククラウドのアカウントを持っていれば、専用のOpenShift環境を利用できる。
・OpenShift Online
Red Hat社が提供するCaaS(Container as a Service)。ユーザ登録で即利用可能。無償プランもあり。
okd
OpenShiftのコミュニティー版。OpenShiftと同じように複数台のノードでクラスターを構成できる。OpenShiftのインストールやインフラ運用の学習にはこちらの方が適しているかも。
旧称は、OpenShift origin。
CodeReadyコンテナー
PC上で実行可能な軽量のOpenShift環境。OpenShiftのコマンド・GUIによる操作の学習向けには最適化かと。
旧バージョンは、minishift。
インストールする
古いMac Proが余っていたので導入しました。
・Mac Pro Mid 2010 (CPU8コア、メモリ24GB)
・macOS 10.13.6 (High Sierra、古い・・・)
1.ダウンロードと展開
以下のサイトからダウンロードします。Red Hat アカウントが必要ですが、無償で登録できます。
https://cloud.redhat.com/openshift/install/crc/installer-provisioned
CRC本体だけでなく、インストール時に使用するプルシークレットのダウンロードもお忘れなく。
以下コマンドの作業は、私はWindows PCからmacOSへSSHで接続して実施しました。古いMac Proはディスプレイを繋いでいないので
macOSユーザのホームディレクトリで作業をしました。
ダウンロードしたファイルを、/home/username に移動して、
$ tar xvzf crc-macos-amd64.tar.xz
x crc-macos-1.13.0-amd64/
x crc-macos-1.13.0-amd64/LICENSE
x crc-macos-1.13.0-amd64/doc.pdf
x crc-macos-1.13.0-amd64/crc
$
2.セットアップの実行
セットアップ中に、macOSユーザのパスワードが求められます。
$ cd ./crc-macos-1.13.0-amd64
$ ./crc setup
INFO Will use root access: change ownership of /Users/username/.crc/bin/goodhosts
Password:
(中略)
INFO Will use root access: change ownership of /etc/resolver/testing
Setup is complete, you can now run 'crc start' to start the OpenShift cluster
$
セットアップが正常終了したら、
$ crc start
? Image pull secret [? for help]
上記の画面が表示されたら、プルシークレットを貼り付けます。テキストファイルの中身を全選択して、ペースト。
{"auths":{"cloud.openshift.com":{"auth":" (中略),"email":"[email protected]"}}}
インターネットから10GB近いモジュールをダウンロードします。
間違ってました、Extracting bundle」モジュールを展開していますね。
INFO Extracting bundle: crc_hyperkit_4.5.1.crcbundle ...
crc.qcow2: 9.10 GiB / 9.10 GiB [--------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00%
INFO Checking size of the disk image /Users/masa03/.crc/cache/crc_hyperkit_4.5.1/crc.qcow2 ...
INFO Creating CodeReady Containers VM for OpenShift 4.5.1...
INFO CodeReady Containers VM is running
さらに進むと、インターネット接続が無いというエラーが出ましたが、ひとまず最後まで進みました。
INFO Restarting the host network
ERRO Host is not connected to internet.
(中略)
INFO To access the cluster, first set up your environment by following 'crc oc-env' instructions
INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443'
INFO To login as an admin, run 'oc login -u kubeadmin -p XXXXX-XXXXX-XXXXX-XXXXX https://api.crc.testing:6443'
INFO
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console
Started the OpenShift cluster
WARN The cluster might report a degraded or error state. This is expected since several operators have been disabled to lower the resource usage. For more information, please consult the documentation
$
画面に出力されている通り、「crc oc-env」を実行。
出力されたPATHを、「.bash_profile」に追記もしておきます。
$ ./crc oc-env
export PATH="/Users/username/.crc/bin/oc:$PATH"
# Run this command to configure your shell:
# eval $(crc oc-env)
$ cat .bash_profile
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export PATH="/Users/username/.crc/bin/oc:$PATH"
$
3.クラスタへログインする
コマンドラインでログイン。
$ oc login -u developer -p developer https://api.crc.testing:6443
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y
Login successful.
You don't have any projects. You can try to create a new project, by running
oc new-project <projectname>
Welcome! See 'oc help' to get started.
$
Web Consoleでログイン。
$ ./crc console
Opening the OpenShift Web Console in the default browser...
$
セットアップを終えて
CRCのセットアップ自体は非常に簡単でした。crcコマンドだけで完結しており、かなり導入の手順が簡素化された印象です。
旧バージョンのminishiftでは、「xhyve」を導入したりドライバを導入したり、またそのためには「brew」が必要だったり。。。
macOS上でCRC用の仮想マシンを実行しているため、CRCに設定されているIPアドレスが特殊です。私の環境では、macOS自体は「192.168.1.x」というアドレスを付与していますが、CRCが実行されているVMは「192.168.64.x」となっています。
今後は、Windows PCからCRC環境へ接続できるのかなど、試してみたいと思います。
Author And Source
この問題について(macOSにRed Hat OpenShift 4 CodeReadyコンテナーを導入す), 我々は、より多くの情報をここで見つけました https://qiita.com/masa03/items/2e14ec5c321d987cad0f著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .