このドキュメントは、Gateway API から次のリソースを使用するアプリケーションの例を設定するのに役立ちます。 以下を行うための手順を示します。
バックグラウンド
Application Gateway for Containers を使用すると、バックエンドのパフォーマンスを向上させるために SSL オフロードが 可能になります。 次のシナリオ例を見てみましょう。
[前提条件]
BYO デプロイ戦略に従う場合は、Application Gateway for Containers リソースと ALB コントローラーを設定していることを確かめます
ALB マネージド デプロイ戦略に従う場合は、ALB コントローラーと、ApplicationLoadBalancer カスタム リソースを介した Application Gateway for Containers リソースのプロビジョニングが完了していることを確かめます。
サンプル HTTPS アプリケーションをデプロイします。クラスターに次の deployment.yaml ファイルを適用し、TLS/SSL オフロードのデモンストレーションを行うためのサンプル Web アプリケーションを作成します。
kubectl apply -f https://raw.githubusercontent.com/MicrosoftDocs/azure-docs/refs/heads/main/articles/application-gateway/for-containers/examples/https-scenario/ssl-termination/deployment.yamlこのコマンドによって、クラスターに次のものが作成されます。
-
test-infraと呼ばれる名前空間 -
echo名前空間内のtest-infraという 1 つのサービス -
echo名前空間にtest-infraと呼ばれる 1 つのデプロイ -
listener-tls-secret名前空間にtest-infraと呼ばれる 1 つのシークレット
-
必要な Gateway API リソースを展開する
ゲートウェイを作成する
kubectl apply -f - <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: gateway-01 namespace: test-infra annotations: alb.networking.azure.io/alb-namespace: alb-test-infra alb.networking.azure.io/alb-name: alb-test spec: gatewayClassName: azure-alb-external listeners: - name: https-listener port: 443 protocol: HTTPS allowedRoutes: namespaces: from: Same tls: mode: Terminate certificateRefs: - kind : Secret group: "" name: listener-tls-secret EOF
注
ALB コントローラーは、Azure Resource Manager で Application Gateway for Containers リソースを作成するときに、フロントエンド リソースに対して次の名前付け規則 ( fe-<eight randomly generated characters>) を使用します。
Azure で作成されたフロントエンド リソースの名前を変更する場合は、 独自のデプロイ戦略に従ってください。
ゲートウェイ リソースが作成されたら、状態が有効であること、リスナーが [プログラム済み] であること、ゲートウェイにアドレスが割り当てられていることを確認します。
kubectl get gateway gateway-01 -n test-infra -o yaml
ゲートウェイの作成に成功した出力例。
status:
addresses:
- type: Hostname
value: xxxx.yyyy.alb.azure.com
conditions:
- lastTransitionTime: "2023-06-19T21:04:55Z"
message: Valid Gateway
observedGeneration: 1
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: "2023-06-19T21:04:55Z"
message: Application Gateway For Containers resource has been successfully updated.
observedGeneration: 1
reason: Programmed
status: "True"
type: Programmed
listeners:
- attachedRoutes: 0
conditions:
- lastTransitionTime: "2023-06-19T21:04:55Z"
message: ""
observedGeneration: 1
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: "2023-06-19T21:04:55Z"
message: Listener is accepted
observedGeneration: 1
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: "2023-06-19T21:04:55Z"
message: Application Gateway For Containers resource has been successfully updated.
observedGeneration: 1
reason: Programmed
status: "True"
type: Programmed
name: https-listener
supportedKinds:
- group: gateway.networking.k8s.io
kind: HTTPRoute
ゲートウェイが作成されたら、HTTPRoute リソースを作成します。
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: https-route
namespace: test-infra
spec:
parentRefs:
- name: gateway-01
rules:
- backendRefs:
- name: echo
port: 80
EOF
HTTPRoute リソースが作成されたら、ルートが [承認済み] になり、Application Gateway for Containers リソースが [プログラム済み] になっていることを確かめます。
kubectl get httproute https-route -n test-infra -o yaml
Application Gateway for Containers リソースが正常に更新されたことを確認します。
status:
parents:
- conditions:
- lastTransitionTime: "2023-06-19T22:18:23Z"
message: ""
observedGeneration: 1
reason: ResolvedRefs
status: "True"
type: ResolvedRefs
- lastTransitionTime: "2023-06-19T22:18:23Z"
message: Route is Accepted
observedGeneration: 1
reason: Accepted
status: "True"
type: Accepted
- lastTransitionTime: "2023-06-19T22:18:23Z"
message: Application Gateway For Containers resource has been successfully updated.
observedGeneration: 1
reason: Programmed
status: "True"
type: Programmed
controllerName: alb.networking.azure.io/alb-controller
parentRef:
group: gateway.networking.k8s.io
kind: Gateway
name: gateway-01
namespace: test-infra
アプリケーションへのアクセスをテストする
これで、フロントエンドに割り当てられた FQDN を使用して、サンプル アプリケーションにトラフィックを送信する準備ができました。 次のコマンドを実行して、FQDN を取得します。
fqdn=$(kubectl get gateway gateway-01 -n test-infra -o jsonpath='{.status.addresses[0].value}')
この FQDN に curl を実行すると、HTTPRoute で構成されているバックエンドから応答が返されます。
curl --insecure https://$fqdn/
これで、ALB コントローラーをインストールし、バックエンド アプリケーションをデプロイして、Application Gateway for Containers のイングレス経由でアプリケーションにトラフィックをルーティングすることができました。