LoginSignup
9
8

More than 3 years have passed since last update.

CentOS7にOpenShift4(Red Hat CodeReady Containers)をインストールする

Last updated at Posted at 2019-10-05

はじめに

Dockerでいろいろ試してみてダメだったので、勉強用の中古PCをGetしました。
VMwareで仮想マシン立ててOpenShift4(Red Hat CodeReady Containers)を試してみたいと思います。

まずはRed Hat Developer アカウントを作成する必要があります。

OpenShift 4のページのGET STARTEDからInfrastructure ProviderLapTopを選択します。

01.png

OpenShift4(Red Hat CodeReady Containers)のインストーラーのURLをメモメモ
そしてOpenShift4(Red Hat CodeReady Containers)スタート時に使うPull Secretをコピーしておきます。(下側のCopy Pull Secretより)
02.png

環境

  • Windows10 Pro
  • VMware Workstation 15 Player
    • CentOS7-1908 with GNOME Desktop

Prerequisites

OSに関する要求事項。ハードルがかなり上がってます。

CodeReady Containers requires the following system resources in order to run OpenShift:
- 4 virtual CPUs (vCPUs)
- 8 GB of memory
- 35 GB of storage space

下準備

VMWare Workstation 15 PlayerにCentOS7を立てます。
利用したのはCentOS-7-x86_64-Minimal-1908.isoのイメージ
これにGNOME Desktopを入れました。
とりあえずvCPU:4, Memory: 8GB, HDD:50GBとしています。

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

OpenShift4(Red Hat CodeReady Containers)を実行するユーザは一般ユーザです。
ただし、セットアップを行う際にsudoを行いますので、/etc/sudoersを修正しsudoできるようにします。

1.3. Installing CodeReady Containersに従いインストールしていきます。

まずは要求されているソフトウェアのインストール確認

1.4. Required software packagesより、NetworkManagerが必要だそうです。
インストールされているか確認します。

[root@centos7 ~]# yum install NetworkManager
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
base                                                                                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                                                                                | 2.9 kB  00:00:00     
updates                                                                                                                                                               | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                     76% [=====================================================-                ]  0.0 B/s | 1.4 MB  --:--:-- ETA updates/7/x86_64/primary_db                                                                                                                                           | 1.9 MB  00:00:00     
パッケージ 1:NetworkManager-1.18.0-5.el7_7.1.x86_64 はインストール済みか最新バージョンです
何もしません

特に記載はありませんでしたが、libvirtdの設定も行っておきました。

[root@centos7 ~]# usermod -aG libvirt tak
[root@centos7 ~]# exit
ログアウト
[tak@centos7 ~]$ newgrp libvirt

下準備が終わったのでいよいよセットアップ開始です。
Install on Laptop: Red Hat CodeReady ContainersからLinux: Download (Libvirt)のURLをコピーしcurlでダウンロードします。

[tak@centos7 ~]$ curl -sS https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz -o /tmp/crc-linux-amd64.tar.xz
[tak@centos7 ~]$ cd /tmp
[tak@centos7 tmp]$ ls crc*
crc-linux-amd64.tar.xz    

ダウンロードできたら解凍しバイナリー(crc)をパスの通った場所に移動します。

[tak@centos7 tmp]$ xz  -dc /tmp/crc-linux-amd64.tar.xz | tar xfv -
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
[tak@centos7 tmp]$ su -
パスワード:
最終ログイン: 2019/10/05 (土) 09:20:45 JST日時 pts/1
[root@centos7 ~]# mv /tmp/crc-linux-1.0.0-rc.0-amd64/crc /usr/local/bin
[root@centos7 ~]# ll /usr/local/bin/
合計 2304424
-rwxr-xr-x. 1 tak libvirt 2359726874  9月 29 20:56 crc
[root@centos7 ~]# exit
ログアウト
[tak@centos7 tmp]$ cd ~
[tak@centos7 ~]$

OpenShift4(Red Hat CodeReady Containers)の初期セットアップ

初期セットアップはsudoさえできれば簡単で、crc setupするだけです。
セットアップメッセージを確認するとINFO Adding user to libvirt groupと書いてあるので
事前準備で行ったlibvirtdの設定は不要だったかもしれません。

[tak@centos7 ~]$ 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] tak のパスワード:
INFO Adding user to libvirt group                 
INFO Enabling libvirt                             
INFO Starting libvirt 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

OpenShift4(Red Hat CodeReady Containers)の実行

ではOpenShift4(Red Hat CodeReady Containers)を起動します。
crc startと入力します。
途中で? Image pull secret [? for help]が出たら最初にメモっていたPull Secretを入力します。
(下側のCopy Pull Secretより)
02.png

[tak@centos7 ~]$ 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] 

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... 

ここでTeraTermが落ちてしまいました。嫌な予感が…
一度を停止し再度ホスト側のターミナルで実行してみます。

[tak@centos7 ~]$ crc stop
Stopping CodeReady Containers instance... this may take a few minutes
CodeReady Containers instance stopped
[tak@centos7 ~]$ 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 
INFO Starting CodeReady Containers VM for OpenShift 4.2.0-0.nightly-2019-09-26-192831... 
ERRO Error occurred: Failed to connect to the crc VM with SSH 

マジですか…

気を取り直して再セットアップ

VMイメージを一度削除し再度インストールしてみました。
今度はTeraTerm経由ではなく、CentOS7のコンソールで実行してます。
なお、今回はlibvirtdの設定を事前に行っていません。

OpenShift4(Red Hat CodeReady Containers)のセットアップ(crc setup)

[tak@centos7 tmp]$ 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 
INFO Adding user to libvirt group                 
INFO Will use root access: add user to libvirt group 
INFO Enabling libvirt                             
INFO Starting libvirt 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

OpenShift4(Red Hat CodeReady Containers)の起動(crc start)

[tak@centos7 tmp]$ 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] 

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... 
INFO Verifying validity of the cluster certificates ... 
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 *****-*****-*****-***** 
INFO                                              
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console 
CodeReady Containers instance is running
[tak@centos7 tmp]$ 

今度はうまくいきました!

OpenShift4(Red Hat CodeReady Containers)のコンソールへアクセス(crc console)

ではOpenShift4(Red Hat CodeReady Containers)のコンソールとご対面しましょうか♪

[tak@centos7 tmp]$ crc console
Opening the OpenShift Web Console in the default browser...
This tool has been deprecated, use 'gio open' instead.
See 'gio help open' for more info.

03.png

Log in with...
kube:adminを選択してみます。

04.png

とりあえずdeveloper?

05.png

06.png

おやおや。。。

じゃあ、
Log in with...
htpasswd_providerを選択してみます。

07.png

06.png

どうやらユーザ作る必要がありそうですね(汗
と思ったら、crc startの出力に書いてありました(笑)

OpenShift4(Red Hat CodeReady Containers)のコンソールへログイン

[tak@centos7 tmp]$ crc console
Opening the OpenShift Web Console in the default browser...
This tool has been deprecated, use 'gio open' instead.
See 'gio help open' for more info.

03.png

Log in with...
htpasswd_providerを選択します。

developer/develoerでログイン

07-5.png

08.png

ようやくご対面♪
大幅にUIも変わっておりこれは大変かも(笑)

09.png

9
8
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
9
8