Mac OSにCode Ready Container(CRC)をインストールしてみる

OpenShiftを自分で動かしてみたので紹介致します。

以下の流れで紹介します。

  • CRCとは
  • CRCのダウンロード
  • CRCのセットアップ
  • CRCの起動

CRCとは

OpenShift4を個人用PCにインストールして動かすことができます。

CRCのダウンロード

まずはCRCを以下のサイトからダウンロードします。ダウンロードするにはRed Hatアカウントが必要になるので、お持ちでない方はアカウントを作成する必要があります。

CRCダウンロードサイト

以下赤枠をクリックしてダウンロードします。コラッタはmacOSを利用しているので、macOSのCRCをダウンロードしています。お使いのPCに合わせてダウンロードしてください。

完了すると以下のファイルがダウンロードされます。

  • crc-macos-amd64.tar.xz
  • pull-secret

CRCのセットアップ

以下のコマンドを実行して、ファイルを展開します。ディレクトリ名はcrc-macos-[バージョン]-amd64です。2020/05/18時点の最新は1.10.0みたいです。

$ tar xzvf crc-macos-amd64.tar.xz
$ cd crc-macos-1.7.0-amd64

ついでに、pull-secretもcrc-macos-1.7.0-amd64に移動します。

$ mv pull-secret crc-macos-1.7.0-amd64

以下のコマンドでCRCのセットアップを行います。コマンドのパスを通してあげることで、どこからでも実行できるようになりますが、今回はディレクトリにあるファイルを直接して実行します。 途中で求められるパスワードは自身の個人PCのパスワードです。

$ ./crc setup
INFO Checking if oc binary is cached
INFO Checking if podman remote binary is cached
INFO Checking if CRC bundle is cached in '$HOME/.crc'
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
INFO Setting file permissions for /etc/hosts
INFO Will use root access: change ownership of /etc/hosts
Password:
Setup is complete, you can now run 'crc start' to start the OpenShift cluster

CRCの起動

以下のコマンドでCRCの起動を行います。

$ ./crc start -p pull-secret

CRCの起動が完了すると、最後に以下のインフォメーションが表示されます。これがログイン方法になります。

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 db9Dr-J2csc-8oP78-9sbmf https://api.crc.testing:6443'
INFO
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console

実際にログインします。

$ oc login -u kubeadmin -p db9Dr-J2csc-8oP78-9sbmf https://api.crc.testing:6443
Login successful.

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

Using project "default".
$ oc get nodes
NAME                 STATUS    ROLES           AGE       VERSION
crc-pxt56-master-0   Ready     master,worker   73d       v1.16.2

コンソールを起動する場合は、以下のコマンドを実行します。

$ ./crc console

以上、CRCの導入手順と実行手順でした。OpenShiftに興味ある方は是非インストールしてみたください!