LoginSignup
20
12

More than 3 years have passed since last update.

Red Hat CodeReady Containers (OpenShift4) のインストールのメモ

Posted at

Mimishift (OpenShift 3.11) の後続となる Red Hat CodeReady Containers (OpenShift 4.2) のインストールと起動について検証メモである。

Red Hat CodeReady Containers とは

Red Hat CodeReady Containersは、ノート型PCなどで、最小のOpenShift4 を動作させるためのソフトウェアである。このソフトウェアは、開発およびテストの目的で最小限の環境する。
主に開発者のパーソナルコンピュータ上で実行することを対象とする。サーバー上で稼働させたり、複数の開発者チームなど利用する場合は、本格的な OpenShift 4の使用が推奨される。
このソフトウェアをインストールすることで、CRCコマンドを実行して、仮想マシン上で CodeReady Containers を実行できる。

OpenShift4 と CodeReady Containers の主な違いは以下である。

  • マスターノードとワーカーノードの両方を単一のノードで稼働
  • machine-configそしてmonitoringオペレータは、デフォルトでは無効
  • 新しいOpenShiftバージョンへのアップグレードパスは無い
  • 技術的な制限により、CodeReady Containersクラスターは一時的なもの

動作環境として次のスペックが提示されている。

  • 4 vCPUs
  • 8GB RAM
  • 35GB ディスク容量

参考URL:
https://code-ready.github.io/crc/

インストール方法

CodeReady Containers (以下CRC) のセットアップに参考になるサイトは、以下がある。

macOSにセットアップしてCRCクラスタが起動するまでを検証する。

上記のダウンロードのURLから、tarファイルを取得して、crcディレクトリに展開する。

imac:~ maho$ /Users/maho/Downloads/crc-macos-amd64.tar.xz 
imac:~ maho$ mkdir crc
imac:~ maho$ mv /Users/maho/Downloads/crc-macos-amd64.tar.xz crc
imac:~ maho$ cd crc
imac:crc maho$ tar xzvf crc-macos-amd64.tar.xz 
x crc-macos-1.2.0-amd64/
x crc-macos-1.2.0-amd64/LICENSE
x crc-macos-1.2.0-amd64/doc.pdf
x crc-macos-1.2.0-amd64/crc

ディレクトリを移動して、crc setupを実行する。

imac:crc maho$ cd crc-macos-1.2.0-amd64
imac:crc-macos-1.2.0-amd64 maho$ ./crc setup
INFO Checking if running as non-root              
INFO Caching oc binary                            
INFO Setting up virtualization with HyperKit      
INFO Will use root access: change ownership of /Users/maho/.crc/bin/hyperkit 
Password:
INFO Will use root access: set suid for /Users/maho/.crc/bin/hyperkit 
INFO Installing crc-machine-hyperkit              
INFO Will use root access: change ownership of /Users/maho/.crc/bin/crc-driver-hyperkit 
INFO Will use root access: set suid for /Users/maho/.crc/bin/crc-driver-hyperkit 
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 Setting file permissions for /etc/hosts      
INFO Will use root access: change ownership of /etc/hosts 
INFO Unpacking bundle from the CRC binary         
Setup is complete, you can now run 'crc start' to start the OpenShift cluster

OpenShift の kubectl コマンドに相当する oc コマンドが利用できることを確認しておく。

imac:crc-macos-1.2.0-amd64 maho$ which oc
/Users/maho/.crc/bin/oc

前述のダウンロードサイトに、Pull Secret と呼ばれるファイルがあるので、こちらも入手して、同じディレクトリにコピーしておく。

imac:crc-macos-1.2.0-amd64 maho$ mv /Users/maho/Downloads/pull-secret.txt .

次のコマンドで、CRCクラスタを起動する。

imac:crc-macos-1.2.0-amd64 maho$ ./crc start -p pull-secret.txt 
INFO Checking if running as non-root              
INFO Checking if oc binary is cached              
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     
INFO Loading bundle: crc_hyperkit_4.2.8.crcbundle ... 
INFO Creating CodeReady Containers VM for OpenShift 4.2.8... 
INFO Verifying validity of the cluster certificates ... 
INFO Network restart not needed                   
INFO Check internal and public DNS query ...      
INFO Copying kubeconfig file to instance dir ...  
INFO Adding user's pull secret and cluster ID ... 
INFO Starting OpenShift cluster ... [waiting 3m]  
INFO                                              
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, username is 'kubeadmin' and password is UMeRe-hBQAi-JJ4Bi-8ynRD 
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 : OpneShiftを操作するための oc コマンドの環境セットアップ
  • oc login -u developer -p developer https://api.crc.testing:6443 : デベロッパー権限でのログイン
  • oc login -u kubeadmin -p UMeRe-hBQAi-JJ4Bi-8ynRD https://api.crc.testing:6443 : 管理者権限でログイン
  • crc console : OpenShift4 の ウェブコンソールの起動

ログインして、動作確認

管理者権限でログインして、動作確認をすすめる。

imac:crc-macos-1.2.0-amd64 maho$ oc login -u kubeadmin -p UMeRe-hBQAi-JJ4Bi-8ynRD https://api.crc.testing:6443
Login successful.

バージョンの確認, 以下では、パソコンにOpenShift 3 の ocコマンドがインストールされていたので、3.11のコマンドが利用されたようだ。

imac:crc-macos-1.2.0-amd64 maho$ oc version 
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth

Server https://api.crc.testing:6443
kubernetes v1.14.6+dea7fb9

既存のOCコマンドのパスを削除して、もう一度、crc oc-envからやり直し

imac:crc-macos-1.2.0-amd64 maho$ oc version
Client Version: v4.2.11
Kubernetes Version: v1.14.6+dea7fb9

CRCのVMの状況も確認しておく。

mac:crc-macos-1.2.0-amd64 maho$ ./crc status
CRC VM:          Running
OpenShift:       Running (v4.2.8)
Disk Usage:      9.447GB of 32.2GB (Inside the CRC VM)
Cache Usage:     11.15GB
Cache Directory: /Users/maho/.crc/cache

oc login することで、kubectl コマンドが利用できるようになったことも確認する。

imac:crc-macos-1.2.0-amd64 maho$ kubectl get componentstatus
NAME                 STATUS      MESSAGE                                                                                     ERROR
controller-manager   Unhealthy   Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: connect: connection refused   
scheduler            Healthy     ok                                                                                          
etcd-0               Healthy     {"health":"true"}    

imac:crc-macos-1.2.0-amd64 maho$ kubectl cluster-info
Kubernetes master is running at https://api.crc.testing:6443

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

ノードのリストを表示すると、masterとworkerが一つのノードにセットアップされている事がわかる。

imac:crc-macos-1.2.0-amd64 maho$ oc get nodes
NAME                 STATUS    ROLES           AGE       VERSION
crc-2n9vw-master-0   Ready     master,worker   21d       v1.14.6+6ac6aa4b0

ステータスを確認しておく。

imac:crc-macos-1.2.0-amd64 maho$ oc status
In project default on server https://api.crc.testing:6443

svc/openshift - kubernetes.default.svc.cluster.local
svc/kubernetes - 172.30.0.1:443 -> 6443

View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.

稼働状態を見ておく。

imac:crc-macos-1.2.0-amd64 maho$ oc get co
NAME                                       VERSION   AVAILABLE   PROGRESSING   DEGRADED   SINCE
authentication                             4.2.8     True        False         False      21d
cloud-credential                           4.2.8     True        False         False      21d
cluster-autoscaler                         4.2.8     True        False         False      21d
console                                    4.2.8     True        False         False      21d
dns                                        4.2.8     True        False         False      15m
image-registry                             4.2.8     True        False         False      21d
ingress                                    4.2.8     True        False         False      21d
insights                                   4.2.8     True        False         False      21d
kube-apiserver                             4.2.8     True        False         False      21d
kube-controller-manager                    4.2.8     True        False         False      21d
kube-scheduler                             4.2.8     True        False         False      21d
machine-api                                4.2.8     True        False         False      21d
machine-config                             4.2.8     True        False         False      21d
marketplace                                4.2.8     True        False         False      15m
monitoring                                 4.2.8     False       True          True       21d
network                                    4.2.8     True        False         False      21d
node-tuning                                4.2.8     True        False         False      15m
openshift-apiserver                        4.2.8     True        False         False      13m
openshift-controller-manager               4.2.8     True        False         False      12m
openshift-samples                          4.2.8     True        False         False      21d
operator-lifecycle-manager                 4.2.8     True        False         False      21d
operator-lifecycle-manager-catalog         4.2.8     True        False         False      21d
operator-lifecycle-manager-packageserver   4.2.8     True        False         False      10m
service-ca                                 4.2.8     True        False         False      21d
service-catalog-apiserver                  4.2.8     True        False         False      21d
service-catalog-controller-manager         4.2.8     True        False         False      21d
storage                                    4.2.8     True        False         False      21d

ウェブコンソールの起動

OpenShift4 のウェブコンソールを起動するには、crc console を実行する。

imac:crc-macos-1.2.0-amd64 maho$ ./crc console
Opening the OpenShift Web Console in the default browser...

これでパソコンのブラウザが起動して、ログインして利用する事ができる。

web-console-1.png

まとめ

Mimishift (OpenShift 3.11) の後続となる Red Hat CodeReady Containers (OpenShift 4.2) のインストールと起動について確認した。思いのほか、親切なソフトウェアなので安心した。

あまり、日本語の情報が無いので、OpenShift4 について知りたい人の助けになればと願う。

20
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
12