By default, Alibaba Cloud Service Mesh (ASM) manages gateway Deployment replicas through the control plane. Any manual changes to the replica count are overwritten during synchronization. To use Horizontal Pod Autoscaler (HPA), CronHPA, or manual scaling for an ASM gateway, disable the default replica synchronization by adding an annotation to the gateway definition.
How it works
When you create an ASM gateway, the control plane creates a Deployment named istio-<gateway-name> in the istio-system namespace of the data plane cluster. ASM manages this Deployment and periodically resynchronizes its configuration, overwriting any manual changes to the replica count.
To support custom scaling, ASM V1.19 and later introduced the annotation asm.alibabacloud.com/replicas-managed-by-asm: false. This annotation tells the control plane to skip replica count synchronization for the gateway Deployment. All other gateway parameters continue to be managed by ASM.
Prerequisites
Before you begin, make sure that you have:
An ASM instance running V1.19 or later
At least one cluster added to the ASM instance
An ASM ingress gateway deployed in the cluster
Disable ASM replica management
Add the asm.alibabacloud.com/replicas-managed-by-asm: false annotation to the IstioGateway resource:
apiVersion: istio.alibabacloud.com/v1beta1
kind: IstioGateway
metadata:
name: "ingressgateway"
namespace: "istio-system"
annotations:
# Disable ASM-managed replica synchronization
asm.alibabacloud.com/replicas-managed-by-asm: false
spec:
......
ports:
- name: http
port: 80
targetPort: 80
......After you apply this change, the ASM control plane no longer overwrites the replica count for this gateway Deployment.
Configure scaling
With ASM replica management disabled, you can manage the number of replicas of the gateway using one of the following approaches:
Manual scaling: Directly modify the replica count of the gateway Deployment based on your business requirements.
HPA: Use Horizontal Pod Autoscaler to automatically scale the gateway based on resource utilization. For more information, see HPA.
CronHPA: Use CronHPA to scale the gateway on a schedule. This approach works well for services with predictable peak and off-peak traffic patterns. For more information, see CronHPA.