背景
AGICを作成した後、いろいろ設定を変更したいですが、例えばListnerの追加、Backendsettingの変更など、Azure portal上では作業してはだめです。
Application Gateway の構成情報は AKS の yaml ファイルにて管理され、手動での構成は AKS によって上書き (削除) されるためです。
では、どうやって設定変更をしますか。
実機検証
## まず、AKSにアクセスしますね。AKS上のyaml fileを取得するので、AKSにログインします。
## Purpose: This command configures kubectl to authenticate and communicate with the specified AKS cluster.
PS /home/hao> az aks get-credentials -n myCluster -g myResourceGroup2 Merged "myCluster" as current context in /home/hao/.kube/config
PS /home/hao>
PS /home/hao>
## イングレスの IP アドレスを取得します。
PS /home/hao> kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
aspnetapp azure-application-gateway * 130.33.81.231 80 8h
## Retrieves all Ingress resources from all namespaces (-A flag) in the cluster and outputs them in YAML format (-o=yaml).
PS /home/hao> kubectl get ingress -A -o=yaml > get_ingress.yaml
PS /home/hao>
##Purpose: Retrieves all Ingress resources from all namespaces (-A flag) and outputs them in a default tabular format.
PS /home/hao> kubectl get ingress -A > get_ingress.txt
PS /home/hao>
##Purpose: Provides a detailed description of all Ingress resources across all namespaces (-A flag).
PS /home/hao> kubectl describe ingress -A > describe_ingress.txt
PS /home/hao>
PS /home/hao>
PS /home/hao> ls
describe_ingress.txt get_ingress.txt get_ingress.yaml Microsoft
結果
get_ingress.yamlの中身は以下です。
apiVersion: v1
items:
- apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"name":"aspnetapp","namespace":"default"},"spec":{"ingressClassName":"azure-application-gateway","rules":[{"http":{"paths":[{"backend":{"service":{"name":"aspnetapp","port":{"number":80}}},"path":"/","pathType":"Exact"}]}}]}}
creationTimestamp: "2025-07-10T04:28:39Z"
generation: 1
name: aspnetapp
namespace: default
resourceVersion: "3774"
uid: e87241dd-20c6-499a-95c3-a7358ae8dc91
spec:
ingressClassName: azure-application-gateway
rules:
- http:
paths:
- backend:
service:
name: aspnetapp
port:
number: 80
path: /
pathType: Exact
status:
loadBalancer:
ingress:
- ip: 130.33.81.231
kind: List
metadata:
resourceVersion: ""
get_ingress.txtの中身は以下です。
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
default aspnetapp azure-application-gateway * 130.33.81.231 80 8h
describe_ingress.txtの中身は以下です。
Name: aspnetapp
Labels: <none>
Namespace: default
Address: 130.33.81.231
Ingress Class: azure-application-gateway
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
*
/ aspnetapp:80 (10.224.0.14:8080)
Annotations: <none>
Events: <none>
設定変更を検証
いよいよ設定変更をやります。まず以下の公開情報を参照して
https://learn.microsoft.com/ja-jp/azure/application-gateway/ingress-controller-annotations
以下のdrainの設定を追加しようと思います。
appgw.ingress.kubernetes.io/connection-draining: "true"
appgw.ingress.kubernetes.io/connection-draining-timeout: "60"
前のget_ingress.yamlを編集して、以下のように追加します。
apiVersion: v1
items:
- apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"name":"aspnetapp","namespace":"default"},"spec":{"ingressClassName":"azure-application-gateway","rules":[{"http":{"paths":[{"backend":{"service":{"name":"aspnetapp","port":{"number":80}}},"path":"/","pathType":"Exact"}]}}]}}
appgw.ingress.kubernetes.io/connection-draining: "true"
appgw.ingress.kubernetes.io/connection-draining-timeout: "60"
creationTimestamp: "2025-07-10T04:28:39Z"
generation: 1
name: aspnetapp
namespace: default
resourceVersion: "3774"
uid: e87241dd-20c6-499a-95c3-a7358ae8dc91
spec:
ingressClassName: azure-application-gateway
rules:
- http:
paths:
- backend:
service:
name: aspnetapp
port:
number: 80
path: /
pathType: Exact
status:
loadBalancer:
ingress:
- ip: 130.33.81.231
kind: List
metadata:
resourceVersion: ""
次は以下のコマンドで文法には問題はないかを確認します。
errorがなくなるまで修正します。(Chatgptを使えばなお修正が速い)
PS /home/hao> kubectl apply -f get_ingress.yaml --dry-run=client
error: error parsing get_ingress.yaml: error converting YAML to JSON: yaml: line 15: mapping values are not allowed in this context
よし、文法は問題なくなりましたので、
PS /home/hao>
PS /home/hao> kubectl apply -f get_ingress.yaml --dry-run=client
ingress.networking.k8s.io/aspnetapp configured (dry run)
PS /home/hao>
デプロイします。
PS /home/hao> kubectl apply -f get_ingress.yaml
ingress.networking.k8s.io/aspnetapp configured
では、Azure Portal上でDrainの設定が追加されたことを確認できました。
やった!
まとめ
数時間をかけて、ようやくAGICに対して理解が深めました。
1.AGICはAKSの中にデプロイしたものです。だから、AGICの設定確認と修正は全部AKSにアクセスできたらやります。
2.AKSにアクセスする方法は難しい。今回はデプロイ時に記録が残っていたので、わかりますが、
実際のPortal上のResource gourp では、Cluster名とか全然異なります。
az aks get-credentials -n myCluster -g myResourceGroup2
3.kubectl apply -fはAKS上にいろいろをデプロイするコマンドですね。
4.get_ingress.yamlを適切に修正して、AGICの設定変更は可能となりますが、修正自体も簡単ではないですよ。
幸い kubectl apply -f get_ingress.yaml --dry-run=clientで文法の確認ができますのでよかったです。