2.12.4. Gateway API デプロイメントトポロジー
Gateway API は、共有ゲートウェイと専用ゲートウェイという 2 つのトポロジーに対応するように設計されています。トポロジーは、それぞれの利点とセキュリティー上の影響の違いに基づいて選択できます。
- 専用ゲートウェイ
-
ルートおよびロードバランサーやプロキシーは、同じ namespace から提供されます。
Gatewayオブジェクトは、特定のアプリケーション namespace へのルートを制限します。これは、OpenShift Container Platform に Gateway API リソースをデプロイする場合のデフォルトのトポロジーです。
次の例は、専用の Gateway リソースの fin-gateway を示しています。
専用 Gateway リソースの例
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: fin-gateway
namespace: openshift-ingress
spec:
gatewayClassName: openshift-default
listeners:
- name: http
protocol: HTTP
port: 80
hostname: "example.com"
-
spec.listeneres::Gatewayリソースに対してspec.listeners[].allowedRoutesを設定しない場合、システムは暗黙的にnamespaces.fromフィールドをSameの値に設定します。
次の例は、専用の Gateway オブジェクトにアタッチされる、関連付けられた HTTPRoute リソースの sales-db を示しています。
HTTPRoute リソースの例
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: sales-db
namespace: openshift-ingress
spec:
parentRefs:
- name: fin-gateway
hostnames:
- sales-db.example.com
rules:
- backendRefs:
- name: sales-db
¦ port: 8080
HTTPRoute リソースをゲートウェイにアタッチするには、その parentRefs フィールドの値として Gateway オブジェクトの名前を指定する必要があります。システムは、ルートが ゲートウェイ オブジェクトと同じ名前空間に存在することを暗黙のうちに前提としています。
- 共有ゲートウェイ
-
ルートは複数の名前空間または複数のホスト名から提供されます。
Gatewayオブジェクトは、spec.listeners.allowedRoutes.namespacesフィールドを使用することで、アプリケーション名前空間からのルートを許可します。
次の例は、spec.listeners.allowedRoutes.namespaces ラベルセレクターが shared-gateway-access: "true" を含む任意の namespace と一致するように設定された Gateway リソースの devops-gateway を示しています。
共有 Gateway リソースの例
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: devops-gateway
namespace: openshift-ingress
spec:
gatewayClassName: openshift-default
listeners:
- name: http
protocol: HTTP
port: 80
hostname: "example.com"
allowedRoutes:
namespaces:
from: Selector
selector:
¦ matchLabels:
¦ shared-gateway-access: "true"
次の例は、devops-gateway リソースに許可される namespace を示しています。
Namespace リソースの例
apiVersion: v1
kind: Namespace
metadata:
name: dev
labels:
shared-gateway-access: "true"
---
apiVersion: v1
kind: Namespace
metadata:
name: ops
labels:
shared-gateway-access: "true"
この例では、dev-portal と ops-home という 2 つの HTTPRoute リソースが異なる namespace にありますが、共有ゲートウェイに接続されています。
apiVersion: v1
kind: HTTPRoute
metadata:
name: dev-portal
namespace: dev
spec:
parentRefs:
- name: devops-gateway
namespace: openshift-ingress
rules:
- backendRefs:
- name: dev-portal
port: 8080
---
apiVersion: v1
kind: HTTPRoute
metadata:
name: ops-home
namespace: ops
spec:
parentRefs:
- name: devops-gateway
namespace: openshift-ingress
rules:
- backendRefs:
- name: ops-home
port: 8080
共有ゲートウェイトポロジーでは、各ルートは、アタッチしたい Gateway オブジェクトの namespace を指定する必要があります。複数の Gateway オブジェクトを namespace 間でデプロイして共有できます。共有ゲートウェイが複数ある場合、このトポロジーは概念的には Ingress Controller シャーディングに似たものになります。