2.3.5.7. Ingress Controller シャーディングのルート作成


ルートを使用すると、アプリケーションを URL でホストできます。Ingress Controller のシャーディングは、一連の Ingress Controller 間での着信トラフィック負荷のバランスをとるのに役立ちます。Ingress Controller のシャーディング機能を使用すると、トラフィックを特定の Ingress Controller に分離することもできます。たとえば、Company A のトラフィックをある Ingress Controller に指定し、Company B を別の Ingress Controller に指定できます。

以下の手順では、例として hello-openshift アプリケーションを使用して、Ingress Controller シャーディングのルートを作成する方法を説明します。

前提条件

  • OpenShift CLI (oc) がインストールされている。
  • プロジェクト管理者としてログインしている。
  • ポートを公開する Web アプリケーションと、そのポート上のトラフィックをリッスンする HTTP または TLS エンドポイントがある。
  • シャーディング用に Ingress Controller を設定している。

手順

  1. 次のコマンドを実行して、hello-openshift というプロジェクトを作成します。

    $ oc new-project hello-openshift
  2. 以下のコマンドを実行してプロジェクトに Pod を作成します。

    $ oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/hello-openshift/hello-pod.json
  3. 以下のコマンドを実行して、hello-openshift というサービスを作成します。

    $ oc expose pod/hello-openshift
  4. hello-openshift-route.yaml というルート定義を作成します。

    シャーディング用に作成したルートの YAML 定義

    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      labels:
        type: sharded
      name: hello-openshift-edge
      namespace: hello-openshift
    spec:
      subdomain: hello-openshift
      tls:
        termination: edge
      to:
        kind: Service
        name: hello-openshift

    各項目の説明:

    type
    ラベルキーとその対応するラベル値は、Ingress Controller で指定されたものと一致する必要があることを指定します。この例では、Ingress Controller にはラベルキーと値 type: sharded があります。
    subdomain
    サブドメイン フィールドの値を使用して公開されるルートを指定します。subdomain フィールドを指定するときは、ホスト名を未設定のままにしておく必要があります。ホストフィールドサブドメイン フィールドの両方を指定した場合、ルートは ホスト フィールドの値を使用し、サブドメイン フィールドは無視します。
  5. 次のコマンドを実行し、hello-openshift-route.yaml を使用して hello-openshift アプリケーションへのルートを作成します。

    $ oc -n hello-openshift create -f hello-openshift-route.yaml

検証

  • 次のコマンドを使用して、ルートのステータスを取得します。

    $ oc -n hello-openshift get routes/hello-openshift-edge -o yaml

    結果の Route リソースは次のようになります。

    出力例

    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
      labels:
        type: sharded
      name: hello-openshift-edge
      namespace: hello-openshift
    spec:
      subdomain: hello-openshift
      tls:
        termination: edge
      to:
        kind: Service
        name: hello-openshift
    status:
      ingress:
      - host: hello-openshift.<apps-sharded.basedomain.example.net>
        routerCanonicalHostname: router-sharded.<apps-sharded.basedomain.example.net>
        routerName: sharded

    各項目の説明:

    host
    イングレスコントローラー (ルーター) がルートを公開するために使用するホスト名を指定します。host フィールドの値は、Ingress Controller によって自動的に決定され、そのドメインを使用します。この例では、Ingress Controller のドメインは <apps-sharded.basedomain.example.net> です。
    <apps-sharded.basedomain.example.net>
    Ingress コントローラーのホスト名を指定します。ホスト名が設定されていない場合、ルートは代わりにサブドメインを使用できます。サブドメインを指定すると、ルートを公開する Ingress Controller のドメインが自動的に使用されます。ルートが複数の Ingress Controller によって公開される場合、ルートは複数の URL でホストされます。
    routerName
    Ingress コントローラーの名前を指定します。この例では、Ingress Controller の名前は sharded です。
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る