Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

第2章 OpenShift Container Platform のインストール

2.1. 概要

本書では、OpenShift Container Platform に関する基本的な概念を紹介し、基本的なアプリケーションのインストールに役立ちます。本書は、OpenShift Container Platform の実稼働環境のデプロイやインストールには適していません。

2.1.1. 前提条件

OpenShift Container Platform をインストールするには、以下が必要です。

  • 完全修飾ドメイン名 (実世界またはネットワーク内) と パスワードなしの SSH アクセスを備えた少なくとも 2 台の物理または仮想 RHEL 7 以降のマシン。本書では、master.openshift.example.com および node.openshift.example.com を使用します。これらのマシンは、これらのドメイン名を使用して相互に ping できるようにする必要があります。IBM POWER サーバーを使用する場合、クラスター内のすべてのサーバーは IBM POWER サーバーである必要があります。
  • 有効な Red Hat サブスクリプション
  • ドメインをノードの IP に解決するワイルドカード DNS 解決。そのため、DNS サーバーに以下のようなエントリーがあります。

    master.openshift.example.com. 300 IN A <master_ip>
    node.openshift.example.com. 300 IN A <node_ip>
    *.apps.openshift.example.com. 300 IN A <node_ip>
ドメイン名の apps にワイルドカードのエントリーを指定する理由

OpenShift Container Platform を使用してアプリケーションをデプロイする場合、内部ルーターは受信要求を対応するアプリケーション Pod にプロキシー設定する必要があります。apps をアプリケーションドメインの一部として使用すると、アプリケーショントラフィックは適切な Pod に正確にマークされます。

apps 以外のものを使用できます。

*.cloudapps.openshift.example.com. 300 IN A <node_ip>

これらが設定されたら、以下の手順を使用して 2 台のマシンに OpenShift Container Platform のインストールを設定します。

2.1.2. OpenShift Container Platform サブスクリプションのアタッチ

  1. ターゲットマシン (マスターとノードの両方) で、root として subscription-manager を使用して、Red Hat にシステムを登録します。

    # subscription-manager register
  2. 最新のサブスクリプションデータを Red Hat Subscription Manager (RHSM) からプルします。

    # subscription-manager refresh
  3. 利用可能なサブスクリプションを一覧表示します。

    # subscription-manager list --available
  4. OpenShift Container Platform サブスクリプションを提供するプール ID を見つけ、これを割り当てます。

    # subscription-manager attach --pool=<pool_id>
  5. <pool_id> の文字列は、OpenShift Container Platform を提供するプールのプール ID に置き換えます。プール ID は、長い英数字の文字列です。

これらの RHEL システムには、OpenShift Container Platform をインストールできるようになりました。次に、OpenShift Container Platform を取得する場所からシステムに指示する必要があります。

2.1.3. リポジトリーの設定

マスターおよびノードの両方で subscription-manager を使用し、OpenShift Container Platform をインストールするのに必要なリポジトリーを有効にします。この例では、最初の 2 つのリポジトリーがすでに有効になっている可能性があります。

  • x86_64 サーバーでのクラウドインストールおよびオンプレミスインストールの場合は、以下のコマンドを実行します。

    # subscription-manager repos --enable="rhel-7-server-rpms" \
        --enable="rhel-7-server-extras-rpms" \
        --enable="rhel-7-server-ose-3.11-rpms" \
        --enable="rhel-7-server-ansible-2.9-rpms"
  • IBM POWER8 サーバーでのオンプレミスインストールの場合は、以下のコマンドを実行します。

    # subscription-manager repos \
        --enable="rhel-7-for-power-le-rpms" \
        --enable="rhel-7-for-power-le-extras-rpms" \
        --enable="rhel-7-for-power-le-optional-rpms" \
        --enable="rhel-7-server-ansible-2.9-for-power-le-rpms" \
        --enable="rhel-7-server-for-power-le-rhscl-rpms" \
        --enable="rhel-7-for-power-le-ose-3.11-rpms"
  • IBM POWER9 サーバーでのオンプレミスインストールの場合は、以下のコマンドを実行します。

    # subscription-manager repos \
        --enable="rhel-7-for-power-9-rpms" \
        --enable="rhel-7-for-power-9-extras-rpms" \
        --enable="rhel-7-for-power-9-optional-rpms" \
        --enable="rhel-7-server-ansible-2.9-for-power-9-rpms" \
        --enable="rhel-7-server-for-power-9-rhscl-rpms" \
        --enable="rhel-7-for-power-9-ose-3.11-rpms"

このコマンドは、RHEL システムに対し、OpenShift Container Platform のインストールに必要なツールがこれらのリポジトリーから利用できるようになることを示します。次に、Ansible をベースとする OpenShift Container Platform インストーラーが必要になります。

注記

以前のバージョンの OpenShift Container Platform 3.11 は Ansible 2.6 のみをサポートしていました。最新バージョンの Playbook が Ansible 2.9 に対応するようになりました。Ansible 2.9 は、使用する推奨バージョンです。

2.1.4. OpenShift Container Platform パッケージのインストール

OpenShift Container Platform のインストーラーは、openshift-ansible パッケージで提供されます。マスターで yum を使用してインストールしてから、yum update を実行します。

# yum -y install wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
# yum -y update
# reboot
# yum -y install openshift-ansible

ここでコンテナーエンジンをインストールします。

  • CRI-O をインストールするには、以下を実行します。

    # yum -y install cri-o
  • Docker をインストールするには、以下を実行します。

    # yum -y install docker

2.1.5. パスワードなしの SSH アクセスの設定

マスターでインストーラーを実行する前に、パスワードなしの SSH アクセスを設定します。これは、インストーラーがマシンにアクセスするのに必要です。マスターで以下のコマンドを実行します。

$ ssh-keygen

プロンプトに従い、パスフレーズを求められたら Enter を押してください。

SSH キーを配布する簡単な方法として、bash ループを使用できます。

$ for host in master.openshift.example.com \
    node.openshift.example.com; \
    do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; \
    done

2.1.6. インストール Playbook の実行

  1. インベントリーファイルの例 を参照して、必要なクラスター設定に最も近いサンプルを選択します。

    重要

    Ansible Playbook を --tags または --check オプションを使用して実行することを、Red Hat ではサポートしていません。

注記

追加のホストファイルの例は、/usr/share/doc/openshift-ansible-docs-3.11.<version>/docs/example-inventories/ ディレクトリーの参照として利用できます (<version> を、openshift-ansible-docs パッケージがインストールされている最新のバージョンに置き換えます。これにより、openshift-ansible の親パッケージがアップグレードされるたびに更新されます)。利用可能なインベントリー変数の詳細は、Configuring Your Inventory File を参照してください。

  1. ホスト名を使用するようにインベントリー例を編集して、ファイルに保存します。デフォルトの場所は /etc/ansible/hosts です。
  2. Playbook ディレクトリーに切り替え、ご自身のイベントリーファイルを使用して、prerequisites.yml Playbook を実行します。

    $ cd /usr/share/ansible/openshift-ansible
    $ ansible-playbook -i <inventory_file> playbooks/prerequisites.yml
  3. Playbook ディレクトリーに切り替え、ご自身のイベントリーファイルを使用して deploy_cluster.yml Playbook を実行します。

    $ cd /usr/share/ansible/openshift-ansible
    $ ansible-playbook -i <inventory_file> playbooks/deploy_cluster.yml

インストールに成功したら、新規プロジェクトを追加する前に、Basic 認証、ユーザーアクセス、およびルートを設定する必要があります。