CentOS Stream 9
Sponsored Link

CodeReady Containers : インストール2022/03/15

 
シングルノードで RedHat OpenShift 4 クラスターを構成可能な CodeReady Containers をインストールします。
CodeReady Containers をインストールするにあたっての、ハードウェアの最小要件は以下の通りです。
* 4 CPU (vCPU)
* 9 GB of free memory
* 35 GB of storage space
[1]
CodeReady Containers のセットアップは一般ユーザーで実行する仕様となっています。
ただし、セットアップ過程では当然 root 権限が必要な作業も含まれています。
よって、こちらの [1] を参考に、CodeReady Containers のセットアップを実行したい一般ユーザーに、sudo による root 権限を付与しておきます
[2]
以下の公式サイトにアクセスして CodeReady Containers インストーラー および Pull Secret をダウンロードし、インストールしたいサーバーにアップロードしておきます。
ダウンロードするには、RedHat アカウントでのログインが必要です。
⇒ https://cloud.redhat.com/openshift/create/local
[3] [1] で権限を付与したユーザーでログインして、CodeReady Containers をセットアップします。
一般ユーザーは root から su するのではなく、そのユーザー自身でログインして作業します。
root からの su では crc setup が失敗します。(環境変数等々の設定で回避可能だが、当例ではそこは説明はしません)
[cent@dlp ~]$
total 3074516
-rwxr--r--. 1 cent cent 3148299700 Mar 15 10:28 crc-linux-amd64.tar.xz
-rwxr--r--. 1 cent cent       2771 Mar 15 10:28 pull-secret.txt

[cent@dlp ~]$
tar Jxvf crc-linux-amd64.tar.xz

[cent@dlp ~]$
sudo mv ./crc-linux-1.40.0-amd64/crc /usr/local/bin/

[cent@dlp ~]$
sudo chown root. /usr/local/bin/crc

[cent@dlp ~]$
sudo chmod 755 /usr/local/bin/crc

[cent@dlp ~]$
crc version

CodeReady Containers version: 1.40.0+5966df09
OpenShift version: 4.9.18 (embedded in executable)

# CodeReady Containers インストールのためのシステム要件をセットアップ

[cent@dlp ~]$
crc setup

CodeReady Containers is constantly improving and we would like to know more about usage (more details at https://developers.redhat.com/article/tool-data-collection)
Your preference can be changed manually if desired using 'crc config set consent-telemetry <yes/no>'
Would you like to contribute anonymous usage statistics? [y/N]: y
Thanks for helping us! You can disable telemetry with the command 'crc config set consent-telemetry no'.
INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
INFO Caching crc-admin-helper executable
INFO Using root access: Changing ownership of /home/cent/.crc/bin/crc-admin-helper-linux
INFO Using root access: Setting suid for /home/cent/.crc/bin/crc-admin-helper-linux
INFO Checking for obsolete admin-helper executable
INFO Checking if running on a supported CPU architecture
INFO Checking minimum RAM requirements
INFO Checking if crc executable symlink exists
INFO Creating symlink for crc executable
INFO Checking if Virtualization is enabled
INFO Checking if KVM is enabled
INFO Checking if libvirt is installed
INFO Installing libvirt service and dependencies
INFO Using root access: Installing virtualization packages
INFO Checking if user is part of libvirt group
INFO Adding user to libvirt group
INFO Using root access: Adding user to the libvirt group
INFO Checking if active user/process is currently part of the libvirt group
INFO Checking if libvirt daemon is running
WARN No active (running) libvirtd systemd unit could be found - make sure one of libvirt systemd units is enabled so that it's autostarted at boot time.
INFO Starting libvirt service
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl start libvirtd
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Installing crc-driver-libvirt
INFO Checking crc daemon systemd service
INFO Setting up crc daemon systemd service
INFO Checking crc daemon systemd socket units
INFO Setting up crc daemon systemd socket units
INFO Checking if systemd-networkd is running
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 Writing Network Manager config for crc
INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf
INFO Using root access: Changing permissions for /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf to 644
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl reload NetworkManager
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
INFO Writing dnsmasq config for crc
INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/dnsmasq.d/crc.conf
INFO Using root access: Changing permissions for /etc/NetworkManager/dnsmasq.d/crc.conf to 644
INFO Using root access: Executing systemctl daemon-reload command
INFO Using root access: Executing systemctl reload NetworkManager
INFO Checking if libvirt 'crc' network is available
INFO Setting up libvirt 'crc' network
INFO Checking if libvirt 'crc' network is active
INFO Starting libvirt 'crc' network
INFO Checking if CRC bundle is extracted in '$HOME/.crc'
INFO Checking if /home/cent/.crc/cache/crc_libvirt_4.9.18.crcbundle exists
INFO Extracting bundle from the CRC executable
INFO Ensuring directory /home/cent/.crc/cache exists
INFO Extracting embedded bundle crc_libvirt_4.9.18.crcbundle to /home/cent/.crc/cache
INFO Uncompressing crc_libvirt_4.9.18.crcbundle

Your system is correctly setup for using CodeReady Containers, you can now run 'crc start' to start the OpenShift cluster

[cent@dlp ~]$
sudo systemctl enable libvirtd
# ダウンロードした Pull Secret を指定して CodeReady Containers セットアップ

[cent@dlp ~]$
crc start -p pull-secret.txt

INFO Checking if running as non-root
INFO Checking if running inside WSL2
INFO Checking if crc-admin-helper executable is cached
INFO Checking for obsolete admin-helper executable
INFO Checking if running on a supported CPU architecture
INFO Checking minimum RAM requirements
INFO Checking if crc executable symlink exists
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 active user/process is currently part of the libvirt group
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 crc daemon systemd socket units
INFO Checking if systemd-networkd is running
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 Checking if libvirt 'crc' network is available
INFO Checking if libvirt 'crc' network is active
INFO Loading bundle: crc_libvirt_4.9.18...
INFO Creating CodeReady Containers VM for OpenShift 4.9.18...
INFO Generating new SSH Key pair...
INFO Generating new password for the kubeadmin user
INFO Starting CodeReady Containers VM for OpenShift 4.9.18...
INFO CodeReady Containers instance is running with IP 192.168.130.11
INFO CodeReady Containers VM is running
INFO Updating authorized keys...
INFO Check internal and public DNS query...
INFO Check DNS query from host...
INFO Verifying validity of the kubelet certificates...
INFO Starting OpenShift kubelet service
INFO Waiting for kube-apiserver availability... [takes around 2min]
INFO Adding user's pull secret to the cluster...
INFO Updating SSH key to machine config resource...
INFO Waiting for user's pull secret part of instance disk...
INFO Changing the password for the kubeadmin user
INFO Updating cluster ID...
INFO Updating root CA cert to admin-kubeconfig-client-ca configmap...
INFO Starting OpenShift cluster... [waiting for the cluster to stabilize]
INFO 3 operators are progressing: authentication, network, openshift-controller-manager
INFO 2 operators are progressing: authentication, openshift-controller-manager
INFO 3 operators are progressing: authentication, kube-apiserver, openshift-controller-manager
INFO 2 operators are progressing: kube-apiserver, openshift-controller-manager
INFO 2 operators are progressing: kube-apiserver, openshift-controller-manager
INFO Operator openshift-controller-manager is progressing
INFO All operators are available. Ensuring stability...
INFO Operators are stable (2/3)...
INFO Operators are stable (3/3)...
INFO Adding crc-admin and crc-developer contexts to kubeconfig...
Started the OpenShift cluster.

The server is accessible via web console at:
  https://console-openshift-console.apps-crc.testing

Log in as administrator:
  Username: kubeadmin
  Password: A7bNk-aXxV3-VJsPS-5EUSG

Log in as user:
  Username: developer
  Password: developer

Use the 'oc' command line interface:
  $ eval $(crc oc-env)
  $ oc login -u developer https://api.crc.testing:6443

# [Started the OpenShift cluster] と表示されればセットアップは正常終了
[4] OpenShift Cluster にログインして動作確認しておきます。
[cent@dlp ~]$
eval $(crc oc-env)

[cent@dlp ~]$
oc login -u kubeadmin https://api.crc.testing:6443

Logged into "https://api.crc.testing:6443" as "kubeadmin" using existing credentials.

You have access to 64 projects, the list has been suppressed. You can list all projects with 'oc projects'

Using project "default".

[cent@dlp ~]$
oc get nodes

NAME                 STATUS   ROLES           AGE   VERSION
crc-8k6jw-master-0   Ready    master,worker   26d   v1.22.3+e790d7f

[cent@dlp ~]$
oc get pods -A

NAMESPACE                                    NAME                                                     READY   STATUS      RESTARTS      AGE
openshift-apiserver-operator                 openshift-apiserver-operator-857b6997dd-9wwkv            1/1     Running     0             26d
openshift-apiserver                          apiserver-6fd87f9978-tf9zn                               2/2     Running     0             25d
openshift-authentication-operator            authentication-operator-864b54899b-jq26f                 1/1     Running     0             26d
openshift-authentication                     oauth-openshift-59d6b6cfdf-7hv9w                         1/1     Running     0             11m
openshift-cluster-machine-approver           machine-approver-75686bc4d5-hw88q                        2/2     Running     0             26d
openshift-cluster-node-tuning-operator       cluster-node-tuning-operator-66cfc4f78c-nrr86            1/1     Running     0             25d
.....
.....
openshift-operator-lifecycle-manager         packageserver-7f74cd78d-n55b4                            1/1     Running     0             26d
openshift-sdn                                sdn-9c7k7                                                2/2     Running     0             26d
openshift-sdn                                sdn-controller-g8dnf                                     1/1     Running     0             26d
openshift-service-ca-operator                service-ca-operator-6cd44c4546-lbgbc                     1/1     Running     0             25d
openshift-service-ca                         service-ca-6b66bc68d-ml7n6                               1/1     Running     0             26d

[cent@dlp ~]$
oc get service

NAME         TYPE           CLUSTER-IP   EXTERNAL-IP                            PORT(S)   AGE
kubernetes   ClusterIP      10.217.4.1   <none>                                 443/TCP   26d
openshift    ExternalName   <none>       kubernetes.default.svc.cluster.local   <none>    26d

[cent@dlp ~]$
oc get pv

NAME     CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                                                 STORAGECLASS   REASON   AGE
pv0001   100Gi      RWO,ROX,RWX    Recycle          Bound       openshift-image-registry/crc-image-registry-storage                           25d
pv0002   100Gi      RWO,ROX,RWX    Recycle          Available                                                                                 25d
pv0003   100Gi      RWO,ROX,RWX    Recycle          Available                                                                                 25d
pv0004   100Gi      RWO,ROX,RWX    Recycle          Available                                                                                 25d
pv0005   100Gi      RWO,ROX,RWX    Recycle          Available                                                                                 25d
.....
.....
[5] CodeReady Containers の起動/停止は以下のように実行します。
# 状態確認

[cent@dlp ~]$
crc status

CRC VM:          Running
OpenShift:       Running (v4.9.18)
Disk Usage:      13.75GB of 32.74GB (Inside the CRC VM)
Cache Usage:     16.04GB
Cache Directory: /home/cent/.crc/cache

# 停止

[cent@dlp ~]$
crc stop
# 起動

[cent@dlp ~]$
crc start
# CodeReady Containers は仮想マシンで動作

[cent@dlp ~]$
sudo virsh list

 Id   Name   State
----------------------
 1    crc    running
関連コンテンツ