ASM通過Gateway API部署Ambient模式的Waypoint組件。本文介紹如何自訂Waypoint的配置。
適用範圍
叢集中已安裝1.2.1及以上版本的Gateway API組件。
建立ConfigMap
ASM支援通過自訂ConfigMap來指定Waypoint的Deployment、HPA、ProxyConfig。請確保ConfigMap和Gateway資源在同一命名空間。
使用以下內容建立gw-options.yaml。
apiVersion: v1 kind: ConfigMap metadata: name: gw-options data: horizontalPodAutoscaler: | spec: minReplicas: 2 maxReplicas: 2 deployment: | spec: # 配置了HPA時,不可以同時配置replicas # replicas: 4 template: spec: containers: - name: istio-proxy resources: requests: cpu: 1000m # pod下線的最長等待時間 terminationGracePeriodSeconds: 120 proxyConfig: | # proxy排水時間 drainDuration: 30s # proxy停止排水的最長時間,請確保terminationGracePeriodSeconds > terminationDrainDuration > drainDuration terminationDrainDuration: 60sdata.horizontalPodAutoscaler:用於定義HPA的配置資訊。本樣本將HPA的最大和最小Pod 副本數均配置為2。data.deployment:配置Pod層級的模板。本樣本配置容器名稱為istio-proxy,CPU需求量為1000m。data.proxyConfig:定義 Istio 代理(istio-proxy)的運行時配置。
建立ConfigMap。
kubectl apply -f gw-options.yaml
更新Waypoint
修改Gateway資源配置,引用ConfigMap資源。將以下內容儲存為gateway.yaml檔案。
apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: waypoint namespace: default spec: infrastructure: parametersRef: group: "" kind: ConfigMap name: gw-options gatewayClassName: istio-waypoint listeners: - allowedRoutes: namespaces: from: Same name: mesh port: 15008 protocol: HBONE更新Waypoint。
kubectl apply -f gateway.yaml更新完成後,ASM會使用ConfigMap中的配置對預設資源配置執行Strategic Merge Patch,然後根據合并後的配置來建立或更新實際的Waypoint資源。