zaki work log

作業ログやら生活ログやらなんやら

Red Hat CodeReady Containers(1.0.0-rc)を入れてOpenShift 4をローカル実行してみる(失敗編)

ローカル上でOpenShift 4.2を稼働することができるCode Ready Containerが提供されてますー。
是非、お試しくださいっ
https://github.com/code-ready/crc/releases/tag/1.0.0-rc.0
https://code-ready.github.io/crc/
@openshift

OpenShift Japan Community ( @openshiftjp )の上記ツイート、試してみます。

途中まで試した雰囲気としては、MinishiftやMinikubeに近い代物で、「セットアップするホスト上の仮想化機能を作ってVM上に(シングルノードの)OpenShift Clusterをデプロイする」という構成になっている。
OpenShiftのサブスクリプションは必要なさそうだけど、Red Hatアカウントは必要。

2019.10.07時点でCodeReady Containersは1.0.0 RC

※ 本エントリではストレージ不足でまだ完了してません ↓ ストレージを再設定して正常に動かしたエントリ zaki-hmkc.hatenablog.com

code-ready.github.io

Getting Started Guideにセットアップ手順は載ってるので、その通りに作業すれば(たぶん)OK。

VMインストーラの準備

"1.3. Installing CodeReady Containers"の通り、以下のスペックのVMを作成し、CentOS7を入れた。
※ 10/27追記: このシステム要件は「CodeReady Containersが動くVMのスペック」なので、ホストOSをこのスペックで用意するとリソースをほとんど持って行かれるので注意

vCPU memory storage
4 8GB 35GB

※ ちなみにホストOSが35だと足りなかったので、増やしてやり直す予定

インストールに必要なCodeReady Containersのアーカイブファイルはhttps://cloud.redhat.com/openshift/install/crc/installer-provisionedからダウンロードするようになっており、Red Hatアカウントが必要なんだけど、ツイートに載っているGitHubのリンクから同じページに認証無しでアクセスできる。
ただし、セットアップの途中でsecretデータの入力が必要なので、認証は結局必須。
ちなみにOpenShiftのサブスクリプションがなく、無料のDeveloperサブスクリプションでも大丈夫っぽい。

ダウンロードできたらPATHの通ったところに展開する。
(ファイルの中身は実行バイナリとドキュメントのみ)

[zaki@codeready ~]$ curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/crc/1.0.0-rc.0/crc-linux-amd64.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 31 2242M   31  704M    0     0  3619k      0  0:10:34  0:03:19  0:07:15 3672k
:
:
[zaki@codeready ~]$ tar tf crc-linux-amd64.tar.xz 
crc-linux-1.0.0-rc.0-amd64/
crc-linux-1.0.0-rc.0-amd64/LICENSE
crc-linux-1.0.0-rc.0-amd64/doc.pdf
crc-linux-1.0.0-rc.0-amd64/crc
[zaki@codeready ~]$ sudo tar xf crc-linux-amd64.tar.xz -C /usr/local/
[zaki@codeready ~]$ ls /usr/local/crc-linux-1.0.0-rc.0-amd64/
crc  doc.pdf  LICENSE
[zaki@codeready ~]$ 
[zaki@codeready ~]$ sudo ln -s /usr/local/crc-linux-1.0.0-rc.0-amd64/crc /usr/local/bin/
[zaki@codeready ~]$ which crc
/usr/local/bin/crc
[zaki@codeready ~]$
[zaki@codeready ~]$ crc version
version: 1.0.0-rc.0+34371d3
OpenShift version: 4.2.0-0.nightly-2019-09-26-192831 (embedded in binary)
[zaki@codeready ~]$ 
[zaki@codeready ~]$ crc help
Deploy local instance of an OpenShift 4.x cluster for development purpose

Usage:
  crc [flags]
  crc [command]

Available Commands:
  config      Modifies crc configuration properties.
  console     Opens or displays the OpenShift Web Console URL.
  delete      Delete cluster
  help        Help about any command
  ip          Get IP of the instance
  oc-env      Sets the path of the 'oc' binary.
  setup       setup hypervisor
  start       start cluster
  status      Display status of the cluster
  stop        Stop cluster
  version     Get CodeReady Container version.

Flags:
  -f, --force              Forcefully perform an action
  -h, --help               help for crc
      --log-level string   log level (e.g. "debug | info | warn | error") (default "info")

Use "crc [command] --help" for more information about a command.
[zaki@codeready ~]$ 

必要なソフトウェア

libvirtNetworkManagerを入れる。
libvirtは確認し忘れたけど、NetworkManagerCentOS 7 Minimalだと最初から入っていた。

[zaki@codeready ~]$ rpm -qa | grep NetworkManager
NetworkManager-tui-1.10.2-13.el7.x86_64
NetworkManager-libnm-1.10.2-13.el7.x86_64
NetworkManager-team-1.10.2-13.el7.x86_64
NetworkManager-wifi-1.10.2-13.el7.x86_64
NetworkManager-1.10.2-13.el7.x86_64
[zaki@codeready ~]$ 

libvirtの確認を忘れたのはドキュメントの本文を見ずに表しか見てなかったため()

CodeReadyのセットアップ

~/.crcディレクトリを作れとあるが、crc versionとかcrc helpを実行すると勝手にできる。

[zaki@codeready ~]$ mkdir .crc
mkdir: cannot create directory ‘.crc’: File exists
[zaki@codeready ~]$
[zaki@codeready ~]$ ll .crc/
total 4
-rw-rw-r--. 1 zaki zaki 2 Oct  7 22:05 crc.json
-rw-------. 1 zaki zaki 0 Oct  7 22:05 crc.log
[zaki@codeready ~]$ 

ので、crc setupを実行する。

NOTE The crc binary should not be run as root (or Administrator). The crc binary should always be run with your user account.

※ ドキュメントに書いてある内容。crcコマンドは非rootで実行すること。

[zaki@codeready ~]$ crc setup --help
setup hypervisor to run the cluster

Usage:
  crc setup [flags]

Flags:
  -h, --help               help for setup
  -d, --vm-driver string   The driver to use for the CRC VM. Possible values: [libvirt] (default "libvirt")

Global Flags:
  -f, --force              Forcefully perform an action
      --log-level string   log level (e.g. "debug | info | warn | error") (default "info")
[zaki@codeready ~]$ 
[zaki@codeready ~]$ crc setup
INFO Checking if running as non-root              
INFO Caching oc binary                            
INFO Setting up virtualization                    
INFO Setting up KVM                               
INFO Installing libvirt service and dependencies  
INFO Will use root access: install virtualization related packages 
[sudo] password for zaki: 
INFO Adding user to libvirt group                 
INFO Will use root access: add user to libvirt group 
INFO Enabling libvirt                             
INFO Starting libvirt service                     
INFO Will use root access: start libvirtd service 
INFO Checking if a supported libvirt version is installed 
INFO Installing crc-driver-libvirt                
INFO Removing older system-wide crc-driver-libvirt 
INFO Setting up libvirt 'crc' network             
INFO Starting libvirt 'crc' network               
INFO Checking if NetworkManager is installed      
INFO Checking if NetworkManager service is running 
INFO Writing Network Manager config for crc       
INFO Will use root access: write NetworkManager config in /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf 
INFO Will use root access: execute systemctl daemon-reload command 
INFO Will use root access: execute systemctl stop/start command 
INFO Writing dnsmasq config for crc               
INFO Will use root access: write dnsmasq configuration in /etc/NetworkManager/dnsmasq.d/crc.conf 
INFO Will use root access: execute systemctl daemon-reload command 
INFO Will use root access: execute systemctl stop/start command 
INFO Unpacking bundle from the CRC binary         
Setup is complete, you can now run 'crc start' to start a CodeReady Containers instance
[zaki@codeready ~]$ 

libvirt関連で途中でsudoが必要なのでパスワード入力して進めた。
(ちなみにこの時、virtualizationが有効になっていない場合エラーになるので、BIOSVM等の設定を見直す)

[zaki@codeready ~]$ crc setup
INFO Checking if running as non-root              
INFO Caching oc binary                            
INFO Setting up virtualization                    
FATA You need to enable virtualization in BIOS    
[zaki@codeready ~]$ 

f:id:zaki-hmkc:20191008075348p:plain

VMの起動

[zaki@codeready ~]$ time crc start
INFO Checking if running as non-root              
INFO Checking if oc binary is cached              
INFO Checking if Virtualization is enabled        
INFO Checking if KVM is enabled                   
INFO Checking if libvirt is installed             
INFO Checking if user is part of libvirt group    
INFO Checking if libvirt is enabled               
INFO Checking if libvirt daemon is running        
INFO Checking if a supported libvirt version is installed 
INFO Checking if crc-driver-libvirt is installed  
INFO Checking if libvirt 'crc' network is available 
INFO Checking if libvirt 'crc' network is active  
INFO Checking if NetworkManager is installed      
INFO Checking if NetworkManager service is running 
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists 
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists 
? Image pull secret [? for help] 

ここでsecretの入力。
Install on Laptop: Red Hat CodeReady Containers (要RHアカウント) のページの下部にある「Pull Secret」の内容をコピペする。(10文字とか32文字ってレベルじゃないので「Copy Pull Secret」でクリップボードにコピーして貼り付けると楽)

f:id:zaki-hmkc:20191008074641p:plain
pull secret

? Copy it from https://cloud.redhat.com/openshift/install/crc/installer-provisioned
? Image pull secret ************************************************************
********************************************************************************

:
:

********************************************************************************

INFO Extracting bundle: crc_libvirt_4.2.0-0.nightly-2019-09-26-192831.crcbundle ... 
INFO Creating CodeReady Containers VM for OpenShift 4.2.0-0.nightly-2019-09-26-192831... 
ERRO Error occurred: Error creating host: Error creating the VM. Error creating machine: Error in driver during machine creation: write /home/zaki/.crc/machines/crc/crc.tmp103483018: no space left on device 
[zaki@codeready ~]$ 

貼り付けて作業続行したらこうなった。

[zaki@codeready ~]$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   31G   23G  7.9G  75% /
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  9.0M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1               1014M  142M  873M  14% /boot
tmpfs                    783M     0  783M   0% /run/user/1000
tmpfs                    783M     0  783M   0% /run/user/0

そうか、VMを35GBで作ったけど/以外に容量取られて足りなかったのかな。。
倍くらいに増やしてまた試す。


正直に言うと、Red Hatのアカウント、今回初めて(プライベートで)作成しました←