Openshift4事始め コスト削減のためにCRCで始めてみた
RedHat CodeReady Containersを入れてみる
コンテナ隆盛の時代。コンテナ稼働環境を自社で構築運用する、というレースが始まってます
決して楽ではない道のりですが、その選択肢として、Openshiftという選択肢があります。
Openshiftはピュアk8sの機能に対して運用やマルチてナンシーを意識したユーザ管理などエンタープライズで必要になりそうなものをもりもり盛り込んだフルアーマーk8s。なおかつRedhatさんのサポートまで付いてきて何それすごい。
よっしゃ!うちの環境でちょっと触ってみよか、と思うまでは早いかもしれませんが、実際にちょっとつかってみるには個人には厳しい制約があります。
OCPのインストールはある程度自動化されていて、構築作業は大変ではないのですが、辛いのが維持です。AWSでパッと作ろうと思うと以下のサーバ維持費用がかかります。
- マスターノード3台 (m4.xlarge!)
- ワーカーノード3台 (m4.xlarge!)
東京リージョンだと概算1ヶ月で11万程度かかります。
なおかつ、以下制約がありつかってない時だけ落としておこう♪が効かない。
- インストール後24時間はサーバ内に導入されている暫定の証明書が有効期限切れでせっかく作ったクラスタが使えなくなる。24時間は起動しておいてね。
- 内部で使っている証明書は30日で有効期限が切れるものもちらほら。定期的にアップデートするから落とさないでほしい。
まぁ何かと言うと、本番運用を前提としたシステムで、落としておくなんて考慮されてないんですね。
そこで、もう少し簡単にOCPを試し使いできないだろうか、という話。
RedHat CodeReady Containers
(https://code-ready.github.io/crc/)
OCPを自端末に入れられます。今日はこれ使ってみましょう。
事前準備
要求スペックは以下
HW
- 4 仮想CPU
- 8 GB memory
- 35GB のストレージ空きスペース
OS
- RHEL/CentOS 7.5以上
- Ubuntu 18.04LTS, Debian 10 以上
しかし実はこのスペックも簡単には揃いません。
自端末の要求スペック足りなければAWSでEC2立ててやればいいじゃん、と思うのですが、やってみたところHWの仮想化機能のチェックで弾かれ、EC2上のサーバには入れられませんでした。なので自分の端末勝負になります。
今回は最小要件をかろうじて満たしているmac miniでやってみます。
スペックが満たしているかは以下で確認できます
$ system_profiler SPHardwareDataType
手順は上記サイトに記載されているのでその手順に従って進めてゆきます。
2.3. Installing CodeReady Containers
Download the latest release of CodeReady Containers
最新のイメージをダウンロードしてきましょう
(https://cloud.redhat.com/openshift/install/crc/installer-provisioned)
ダウンロードの際はアカウント登録が必要です。特にお金はかからないので登録して進めます。
リンク先に
windows版、macOS版、Linux版のアーカイブが置かれています。
mac版をダウンロード。2.1GBとそれなりにサイズはあります。
extract the contents of the archive to a location in your PATH.
とあるので、PATHの通っている場所に解凍します。
path通っているところは以下のコマンド
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
解凍してパスの通っている場所に移動。
なお、/usr/local/bin/は存在しない場合もあるので、無かったら作りましょう
$ tar xvzf crc-macos-amd64.tar.xz
x crc-macos-1.8.0-amd64/
x crc-macos-1.8.0-amd64/LICENSE
x crc-macos-1.8.0-amd64/doc.pdf
x crc-macos-1.8.0-amd64/crc
$ mv crc-macos-1.8.0-amd64/crc /usr/local/bin
コマンドを打てることを確認
$crc version
crc version: 1.8.0+0a318dc
OpenShift version: 4.3.8 (embedded in binary)
3.1. Setting up CodeReady Containers
Set up your host machine for CodeReady Containers:
セットアップしましょう。
途中でrootのパスワードを聞かれます。
$ crc setup
INFO Checking if oc binary is cached
INFO Caching oc binary
INFO Checking if podman remote binary is cached
INFO Caching podman remote binary
INFO Checking if CRC bundle is cached in '$HOME/.crc'
INFO Unpacking bundle from the CRC binary
INFO Checking if running as non-root
INFO Checking if HyperKit is installed
INFO Setting up virtualization with HyperKit
INFO Will use root access: change ownership of /Users/[username]/.crc/bin/hyperkit
Password:
INFO Will use root access: set suid for /Users/[username]/.crc/bin/hyperkit
INFO Checking if crc-driver-hyperkit is installed
INFO Installing crc-machine-hyperkit
INFO Will use root access: change ownership of /Users/[username]/.crc/bin/crc-driver-hyperkit
INFO Will use root access: set suid for /Users/[username]/.crc/bin/crc-driver-hyperkit
INFO Checking file permissions for /etc/resolver/testing
INFO Setting file permissions for /etc/resolver/testing
INFO Will use root access: create dir /etc/resolver
INFO Will use root access: create file /etc/resolver/testing
INFO Will use root access: change ownership of /etc/resolver/testing
INFO Checking file permissions for /etc/hosts
INFO Setting file permissions for /etc/hosts
INFO Will use root access: change ownership of /etc/hosts
Setup is complete, you can now run 'crc start' to start the OpenShift cluster
3.2. Starting the virtual machine
You have a valid OpenShift user pull secret. Copy or download the pull secret from the Pull Secret section of the Install on Laptop: Red Hat CodeReady Containers page on cloud.redhat.com.
pull secretが要るとのこと。
先ほどファイルをダウンロードした画面に以下のボタンがあります。
準備整ったので実行します。
$ crc start
WARN A new version (1.9.0) has been published on https://cloud.redhat.com/openshift/install/crc/installer-provisioned
INFO Checking if oc binary is cached
INFO Checking if podman remote binary is cached
INFO Checking if running as non-root
INFO Checking if HyperKit is installed
INFO Checking if crc-driver-hyperkit is installed
INFO Checking file permissions for /etc/resolver/testing
INFO Checking file permissions for /etc/hosts
? Image pull secret
聞かれるので、入れてみる。
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 password 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
無事入りました。ログインするためのコマンドも丁寧に書かれています。
また、入れたばかりだとOCコマンドにパスが通ってないので、以下を実行するとパスが通すためのコマンドを教えてくれます。
$ crc oc-env
export PATH="/Users/[username]/.crc/bin:$PATH"
# Run this command to configure your shell:
# eval $(crc oc-env)
webコンソールへの入り方は以下
crc console
パスワードはcrc start実行時のログインコマンドに記載があります。
使ってない時は以下で停止しておくこともできます。
crc stop
所感
その後使ってみた際の感想ですが、これだけのクラスタをローカルで稼働できる環境が用意されているのはすごい。コンソールコマンドの検証はサクサクできる。
だけど、webコンソールを触ってみるにはスペックギリギリだと大分重いですね。。
操作をしているとタイムアウトする場合も多く、openshift-monitoringのprometheusやgrafanaを触ってみようとwebコンソールから入ってみましたが、webはうまく動いていなかったようでした。
細かく調査できていませんが、スペックは最低限より大きいマシンを用意して入れたほうが良さそうです。
Author And Source
この問題について(Openshift4事始め コスト削減のためにCRCで始めてみた), 我々は、より多くの情報をここで見つけました https://qiita.com/mugen14/items/4d216a9c8ada1c8fd9fd著者帰属:元の著者の情報は、元の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 .