チュートリアル
第1章 チュートリアルの概要 リンクのコピーリンクがクリップボードにコピーされました!
Red Hat エキスパートによるステップバイステップのチュートリアルを使用して、マネージド OpenShift クラスターを最大限に活用してください。
このコンテンツは Red Hat のエキスパートが作成したものですが、サポート対象のすべての設定でまだテストされていません。
第2章 チュートリアル: カスタムドメインと TLS 証明書を使用してコンポーネントルートを更新する リンクのコピーリンクがクリップボードにコピーされました!
このガイドでは、Google Cloud Platform (GCP) バージョン 4.14 以降上の OpenShift Dedicated で、Web コンソール、OAuth サーバー、およびダウンロードコンポーネントルートのホスト名と TLS 証明書を変更する方法を説明します。[1]
コンポーネントルートに加える変更[2] このガイドで説明されている内容の詳細は、OpenShift Dedicated ドキュメントの 内部 OAuth サーバー URL のカスタマイズ、コンソールルートのカスタマイズ、および ダウンロードルートのカスタマイズ を参照してください。
2.1. 前提条件 リンクのコピーリンクがクリップボードにコピーされました!
-
OCM CLI (
ocm
) バージョン 1.0.5 以上 -
gcloud CLI (
gcloud
) - Google Cloud Platform (GCP) クラスター上で稼働しているバージョン 4.14 以上の OpenShift Dedicated
-
OpenShift CLI (
oc
) -
jq
CLI -
cluster-admin
ロールを持つユーザーとしてクラスターにアクセスできる。 - OpenSSL (デモ用の SSL/TLS 証明書を生成するため)
2.2. 環境の設定 リンクのコピーリンクがクリップボードにコピーされました!
-
cluster-admin
権限を持つアカウントを使用してクラスターにログインします。 クラスター名の環境変数を設定します。
export CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//')
$ export CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のセクションに進む前に、すべてのフィールドが正しく出力されていることを確認してください。
echo "Cluster: ${CLUSTER_NAME}"
$ echo "Cluster: ${CLUSTER_NAME}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 出力例
Cluster: my-osd-cluster
Cluster: my-osd-cluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. 現在のルートを確認する リンクのコピーリンクがクリップボードにコピーされました!
デフォルトのホスト名でコンポーネントルートに到達できることを確認します。
openshift-console
およびopenshift-authentication
プロジェクトでルートのリストをクエリーすることで、ホスト名を確認できます。oc get routes -n openshift-console oc get routes -n openshift-authentication
$ oc get routes -n openshift-console $ oc get routes -n openshift-authentication
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 出力例
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD console console-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more console https reencrypt/Redirect None downloads downloads-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more downloads http edge/Redirect None NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD oauth-openshift oauth-openshift.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more oauth-openshift 6443 passthrough/Redirect None
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD console console-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more console https reencrypt/Redirect None downloads downloads-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more downloads http edge/Redirect None NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD oauth-openshift oauth-openshift.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more oauth-openshift 6443 passthrough/Redirect None
Copy to Clipboard Copied! Toggle word wrap Toggle overflow この出力から、ベースホスト名が
z9a9.p2.openshiftapps.com
であることを確認できます。次のコマンドを実行して、デフォルト Ingress の ID を取得します。
export INGRESS_ID=$(ocm list ingress -c ${CLUSTER_NAME} -o json | jq -r '.[] | select(.default == true) | .id')
$ export INGRESS_ID=$(ocm list ingress -c ${CLUSTER_NAME} -o json | jq -r '.[] | select(.default == true) | .id')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のセクションに進む前に、すべてのフィールドが正しく出力されていることを確認してください。
echo "Ingress ID: ${INGRESS_ID}"
$ echo "Ingress ID: ${INGRESS_ID}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 出力例
Ingress ID: r3l6
Ingress ID: r3l6
Copy to Clipboard Copied! Toggle word wrap Toggle overflow これらのコマンドを実行すると、クラスターのデフォルトのコンポーネントルートが次のとおりであることがわかります。
-
コンソール:
console-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com
-
ダウンロード:
downloads-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com
-
OAuth:
oauth-openshift.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com
-
コンソール:
ocm edit Ingress
コマンドを使用して、各サービスのホスト名を変更し、すべてのコンポーネントルートに TLS 証明書を追加できます。関連するパラメーターは、以下に示す ocm edit ingress
コマンドのコマンドラインヘルプの抜粋で確認できます。
ocm edit ingress -h
$ ocm edit ingress -h
Edit a cluster ingress for a cluster. Usage:
ocm edit ingress ID [flags]
[...]
--component-routes string Component routes settings. Available keys [oauth, console, downloads]. For each key a pair of hostname and tlsSecretRef is expected to be supplied. Format should be a comma separate list 'oauth: hostname=example-hostname;tlsSecretRef=example-secret-ref,downloads:...'
この例では、次のカスタムコンポーネントルートを使用します。
-
Console の場合:
console.my-new-domain.dev
-
Downloads の場合:
downloads.my-new-domain.dev
-
OAuth の場合:
oauth.my-new-domain.dev
2.4. 各コンポーネントルートに有効な TLS 証明書を作成する リンクのコピーリンクがクリップボードにコピーされました!
このセクションでは、3 つの個別の自己署名証明書キーペアを作成し、それらを信頼して、実際の Web ブラウザーを使用して新しいコンポーネントルートにアクセスできることを確認します。
これはデモンストレーションのみを目的としており、実稼働環境のワークロードのソリューションとしては推奨されません。実稼働環境のワークロード用に同様の属性を持つ証明書を作成する方法は、認証局に問い合わせてください。
HTTP/2 接続の結合に関する問題を防ぐには、エンドポイントごとに個別の証明書を使用する必要があります。ワイルドカードまたは SAN 証明書の使用はサポートされません。
各コンポーネントルートの証明書を生成し、使用するコンポーネントルートのカスタムドメインに、証明書のサブジェクト (
-subj
) を設定するように注意してください。例
openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-console.pem -out cert-console.pem -subj "/CN=console.my-new-domain.dev" openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-downloads.pem -out cert-downloads.pem -subj "/CN=downloads.my-new-domain.dev" openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-oauth.pem -out cert-oauth.pem -subj "/CN=oauth.my-new-domain.dev"
$ openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-console.pem -out cert-console.pem -subj "/CN=console.my-new-domain.dev" $ openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-downloads.pem -out cert-downloads.pem -subj "/CN=downloads.my-new-domain.dev" $ openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout key-oauth.pem -out cert-oauth.pem -subj "/CN=oauth.my-new-domain.dev"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow これにより、
.pem
ファイル、key-<component>.pem
、cert-<component>.pem
ペアが 3 つ生成されます。
2.5. 証明書をシークレットとしてクラスターに追加する リンクのコピーリンクがクリップボードにコピーされました!
openshift-config
namespace に 3 つの TLS シークレットを作成します。これは、このガイドで後にコンポーネントルートを更新するときのシークレット参照になります。
oc create secret tls console-tls --cert=cert-console.pem --key=key-console.pem -n openshift-config oc create secret tls downloads-tls --cert=cert-downloads.pem --key=key-downloads.pem -n openshift-config oc create secret tls oauth-tls --cert=cert-oauth.pem --key=key-oauth.pem -n openshift-config
$ oc create secret tls console-tls --cert=cert-console.pem --key=key-console.pem -n openshift-config $ oc create secret tls downloads-tls --cert=cert-downloads.pem --key=key-downloads.pem -n openshift-config $ oc create secret tls oauth-tls --cert=cert-oauth.pem --key=key-oauth.pem -n openshift-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.6. クラスター内のロードバランサーのロードバランサー IP を見つける リンクのコピーリンクがクリップボードにコピーされました!
クラスターを作成すると、サービスによってロードバランサーが作成され、そのロードバランサーのロードバランサー IP が生成されます。クラスターの DNS レコードを作成するために、ロードバランサーの IP を確認する必要があります。
ロードバランサー IP を確認するには、openshift-ingress
namespace に対して oc get svc
コマンドを実行します。ロードバランサーの IP は、openshift-Ingress
namespace の router-default
サービスに関連付けられた EXTERNAL-IP
です。
oc get svc -n openshift-ingress
$ oc get svc -n openshift-ingress
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
router-default LoadBalancer 172.30.237.88 34.85.169.230 80:31175/TCP,443:31554/TCP 76d
この場合、ロードバランサーの IP は 34.85.169.230
です。
この値を後の手順のために保存します。新しいコンポーネントルートのホスト名に DNS レコードを設定する際に必要になります。
2.7. ホスティングプロバイダーにコンポーネントルート DNS レコードを追加する リンクのコピーリンクがクリップボードにコピーされました!
DNS 設定で A レコードを作成し、ドメインをルーターのデフォルトのロードバランサーの IP アドレスを参照します。
2.8. OCM CLI を使用してコンポーネントルートと TLS シークレットを更新する リンクのコピーリンクがクリップボードにコピーされました!
DNS レコードが更新されたら、OCM CLI を使用してコンポーネントルートを変更できます。
ocm edit Ingress
コマンドを使用して、デフォルトの Ingress ルートを新しいベースドメインとそれに関連付けられたシークレット参照で更新します。その際、各コンポーネントルートのホスト名を更新するように注意してください。ocm edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname=downloads.my-new-domain.dev;tlsSecretRef=downloads-tls,oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'
$ ocm edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname=downloads.my-new-domain.dev;tlsSecretRef=downloads-tls,oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注記変更しないコンポーネントルートを空の文字列に設定したままにして、コンポーネントルートのサブセットのみを編集することもできます。たとえば、コンソールおよび OAuth サーバーのホスト名および TLS 証明書のみを変更する場合は、以下のコマンドを実行します。
ocm edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname="";tlsSecretRef="", oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'
$ ocm edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname=console.my-new-domain.dev;tlsSecretRef=console-tls,downloads: hostname="";tlsSecretRef="", oauth: hostname=oauth.my-new-domain.dev;tlsSecretRef=oauth-tls'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ocm list Ingress
コマンドを実行して、変更が正常に行われたことを確認します。ocm list ingress -c ${CLUSTER_NAME} -ojson | jq ".[] | select(.id == \"${INGRESS_ID}\") | .component_routes"
$ ocm list ingress -c ${CLUSTER_NAME} -ojson | jq ".[] | select(.id == \"${INGRESS_ID}\") | .component_routes"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 出力例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - ローカルシステムのトラストストアに証明書を追加し、ローカル Web ブラウザーを使用して新しいルートでコンポーネントにアクセスできることを確認します。
2.9. OCM CLI を使用してコンポーネントルートをデフォルトにリセットする リンクのコピーリンクがクリップボードにコピーされました!
コンポーネントルートをデフォルト設定にリセットする場合は、次の ocm edit Ingress
コマンドを実行します。
ocm edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname="";tlsSecretRef="",downloads: hostname="";tlsSecretRef="", oauth: hostname="";tlsSecretRef=""'
$ ocm edit ingress -c ${CLUSTER_NAME} ${INGRESS_ID} --component-routes 'console: hostname="";tlsSecretRef="",downloads: hostname="";tlsSecretRef="", oauth: hostname="";tlsSecretRef=""'
Legal Notice
リンクのコピーリンクがクリップボードにコピーされました!
Copyright © 2025 Red Hat
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.