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资源。
该文章对您有帮助吗?