7.2. Containerfile の例
RHCOS イメージのレイヤー化により、次のタイプのイメージを使用してカスタムレイヤーイメージを作成できます。
OpenShift Container Platform ホットフィックス。Customer Experience and Engagement (CEE) を使用して、ホットフィックスパッケージ を取得し、RHCOS イメージに適用することができます。場合によっては、公式の OpenShift Container Platform リリースに含まれる前に、バグ修正または機能強化が必要になることがあります。RHCOS イメージのレイヤー化により、公式にリリースされる前にホットフィックスを簡単に追加し、基になる RHCOS イメージに修正が組み込まれたときにホットフィックスを削除できます。
重要一部のホットフィックスは Red Hat Support Exception を必要とし、OpenShift Container Platform のサポート範囲またはライフサイクルポリシーの通常の範囲外です。
ホットフィックスは Red Hat ホットフィックスポリシー に基づいて提供されます。それを基本イメージ上に適用し、その新しいカスタムレイヤーイメージを非実稼働環境でテストします。カスタムレイヤーイメージが実稼働環境で安全に使用できることを確認したら、独自のスケジュールで特定のノードプールにロールアウトできます。何らかの理由で、カスタムレイヤーイメージを簡単にロールバックして、デフォルトの RHCOS の使用に戻すことができます。
ホットフィックスを適用するクラスター上の Containerfile の例
# Using a 4.17.0 image containerfileArch: noarch content: |- FROM configs AS final #Install hotfix rpm RUN dnf install -y https://example.com/myrepo/haproxy-1.0.16-5.el8.src.rpm && \ dnf clean all && \ ostree container commitホットフィックスを適用するクラスター外の Containerfile の例
# Using a 4.17.0 image FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256... #Install hotfix rpm RUN dnf install -y https://example.com/myrepo/haproxy-1.0.16-5.el8.src.rpm && \ dnf clean all && \ ostree container commitRHEL パッケージ。chrony、firewalld、iputils などの Red Hat Enterprise Linux (RHEL) パッケージは、Red Hat Customer Portal からダウンロードできます。
libreswan ユーティリティーを適用するクラスター外の Containerfile の例
# Get RHCOS base image of target cluster `oc adm release info --image-for rhel-coreos` # hadolint ignore=DL3006 FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256... # Install our config file COPY my-host-to-host.conf /etc/ipsec.d/ # RHEL entitled host is needed here to access RHEL packages # Install libreswan as extra RHEL package RUN dnf install -y libreswan && \ dnf clean all && \ systemctl enable ipsec && \ ostree container commitlibreswan には追加の RHEL パッケージが必要なため、イメージはエンタイトルメントのある RHEL ホストでビルドする必要があります。RHEL エンタイトルメントを機能させるには、
etc-pki-entitlementシークレットをopenshift-machine-apinamespace にコピーする必要があります。サードパーティーのパッケージ。次のタイプのパッケージなど、サードパーティーから RPM をダウンロードおよびインストールできます。
- 最先端のドライバーとカーネルの強化により、パフォーマンスを向上させたり、機能を追加したりします。
- 侵入の可能性と実際の侵入を調査するためのフォレンジッククライアントツール。
- セキュリティーエージェント。
- クラスター全体の一貫性のあるビューを提供するインベントリーエージェント。
- SSH キー管理パッケージ。
EPEL からのサードパーティーパッケージを適用するクラスター上の Containerfile の例
FROM configs AS final #Enable EPEL (more info at https://docs.fedoraproject.org/en-US/epel/ ) and install htop RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ dnf install -y htop && \ dnf clean all && \ ostree container commitEPEL からサードパーティーパッケージを適用するクラスター外の Containerfile の例
# Get RHCOS base image of target cluster `oc adm release info --image-for rhel-coreos` # hadolint ignore=DL3006 FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256... #Enable EPEL (more info at https://docs.fedoraproject.org/en-US/epel/ ) and install htop RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \ dnf install -y htop && \ dnf clean all && \ ostree container commitこの Containerfile は、RHEL fish プログラムをインストールします。fish には追加の RHEL パッケージが必要なため、イメージはエンタイトルメントのある RHEL ホストでビルドする必要があります。RHEL エンタイトルメントを機能させるには、
etc-pki-entitlementシークレットをopenshift-machine-apinamespace にコピーする必要があります。RHEL 依存関係を持つサードパーティーパッケージを適用するクラスター上の Containerfile の例
FROM configs AS final # RHEL entitled host is needed here to access RHEL packages # Install fish as third party package from EPEL RUN dnf install -y https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/f/fish-3.3.1-3.el9.x86_64.rpm && \ dnf clean all && \ ostree container commitRHEL 依存関係を持つサードパーティーパッケージを適用するクラスター外の Containerfile の例
# Get RHCOS base image of target cluster `oc adm release info --image-for rhel-coreos` # hadolint ignore=DL3006 FROM quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256... # RHEL entitled host is needed here to access RHEL packages # Install fish as third party package from EPEL RUN dnf install -y https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/f/fish-3.3.1-3.el9.x86_64.rpm && \ dnf clean all && \ ostree container commit
マシン設定を作成した後、Machine Config Operator (MCO) は次の手順を実行します。
- 指定された 1 つ以上のプールの新しいマシン設定をレンダリングします。
- 1 つ以上のプール内のノードでコードンおよびドレイン操作を実行します。
- 残りのマシン設定パラメーターをノードに書き込みます。
- カスタムレイヤーイメージをノードに適用します。
- 新しいイメージを使用してノードを再起動します。
クラスターにロールアウトする前に、実稼働環境の外でイメージをテストすることを強く推奨します。