For Container Service for Kubernetes (ACK) clusters that run in the data plane and use the Terway network plugin, Alibaba Cloud Service Mesh (ASM) supports integration with Application Load Balancer (ALB) instances. This simplifies service governance, secures inter-service authentication, and provides mesh observability, reducing development and O&M workloads.
Prerequisites
-
A cluster is added to your ASM instance, and the ASM instance and the ACK cluster meet the following requirements.
-
ASM instance: Enterprise Edition.
-
ACK cluster:
-
The network plugin type is Terway.
-
The Cloud Controller Manager (CCM) component version is v1.9.3.313-g748f81e-aliyun or later. For more information, see Cloud Controller Manager.
-
The ALB Ingress Controller component is installed. For instructions, see Manage components.
-
-
-
Automatic sidecar proxy injection is enabled for the default namespace. For instructions, see Enable automatic sidecar proxy injection.
-
An ingress gateway is created with CLB instance type set to Private Access and Service Port set to 80. For instructions, see Create an ingress gateway.
Step 1: Deploy a test application
Create the Bookinfo sample application by using the KubeConfig of the data plane cluster. For more information, see Deploy an application to an ASM-associated cluster.
kubectl apply -f https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/platform/kube/bookinfo.yaml
Step 2: Create Istio resources
The gateway resource and virtual service that you create are used for the subsequent tests.
-
Create a gateway rule.
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
-
On the Gateway page, click Create and configure the following settings.
In the Basic Information section, for Namespace, select
default, and for Name, enterbookinfo-gateway. In the Apply to Gateway section, add a label with the nameistioand the valueingressgateway. In the Service section, for Name, enterhttp; for Port, enter80; and for Protocol, select HTTP. Then, click Create. -
At the bottom of the page, click Preview to view the YAML file of the gateway rule. After you confirm that the configuration is correct, click OK. Then, at the bottom of the Create page, click Create.
-
-
Create a virtual service and configure routes.
-
On the details page of the ASM instance, choose in the left-side navigation pane.
-
On the VirtualService page, click Create to configure the virtual service for the bookinfo-gateway gateway.
Configure the following parameters. For Namespace, select default. For Name, enter bookinfo. Turn off the Apply to All Sidecars switch, and add bookinfo-gateway to the gateway rules. In the HTTP Route section, add the following match rules: URI exact match
/productpage, URI prefix match/static, URI exact match/login, URI exact match/logout, and URI prefix match/api/v1/products. Set the route destination service name to productpage and the port to 9080. Then, click Create. -
At the bottom of the Create page, click Preview to view the YAML file. After you confirm that the configuration is correct, click Submit. Then, at the bottom of the Create page, click Create.
-
Step 3: Create an AlbConfig
Scenario 1: Integrate an ASM ingress gateway with an existing ALB Standard Edition instance
-
Log on to Server Load Balancer console and get the ALB instance ID.
-
Use the following content to create the alb-demo.yaml file.
Replace the
config.idof the AlbConfig with the ALB instance ID.apiVersion: alibabacloud.com/v1 kind: AlbConfig metadata: name: default spec: config: id: alb-xxxxx forceOverride: false -
Create the AlbConfig.
kubectl apply -f alb-demo.yaml
Scenario 2: Integrate an ASM ingress gateway with a new ALB instance
Scenario 2 creates a new ALB instance, which incurs fees. Because addressType is set to Internet, the instance also incurs public traffic fees and Elastic IP Address fees. For more information, see ALB billing overview.
Release the ALB instance and related resources after you complete this topic to avoid ongoing charges.
-
Use the following content to create the alb-demo.yaml file. For more information, see Expose services with ALB Ingress.
This configuration sets the name of the automatically created ALB instance to alb-demo.
apiVersion: alibabacloud.com/v1 kind: AlbConfig metadata: name: default spec: config: name: alb-demo addressType: Internet zoneMappings: - vSwitchId: vsw-uf6ccg2a9g71hx8go**** - vSwitchId: vsw-uf6nun9tql5t8nh15****Parameter
Description
spec.config.nameThe name of the ALB instance.
addressType(Required) Specifies the address type of the load balancer. Valid values:
-
Internet (default): The load balancer has a public IP address. The DNS domain name resolves to the public IP address, so the load balancer can be accessed over the Internet.
-
Intranet: The load balancer has only a private IP address. The DNS domain name resolves to the private IP address, so the load balancer can be accessed only from the internal network of the VPC where it resides.
zoneMappings(Required) Specifies the vSwitch IDs for ALB Ingress. You must specify at least two vSwitch IDs in different zones. The specified vSwitches must be in zones that ALB currently supports. For information about the regions and zones that ALB Ingress supports, see Regions and zones supported by ALB; for information about how to create a vSwitch, see Create and manage vSwitches.
-
-
Create the AlbConfig.
kubectl apply -f alb-demo.yaml
Step 4: Create an IngressClass
-
Create the alb.yaml file and copy the following content into it to create an IngressClass.
apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: alb spec: controller: ingress.k8s.alibabacloud/alb parameters: apiGroup: alibabacloud.com kind: AlbConfig name: default scope: Cluster -
Create the IngressClass.
kubectl apply -f alb.yamlExpected output:
ingressclass.networking.k8s.io/alb created
Step 5: Configure an Ingress
The ASM ingress gateway service is created in the istio-system namespace. You must create the Ingress in the istio-system namespace of the data plane cluster (the ACK cluster). The port must be the same as port 80 that you specified when you created the ASM ingress gateway.
-
Create the asm-gateway-ingress.yaml file and copy the following content into it.
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: asm-gateway-ingress namespace: istio-system spec: ingressClassName: alb rules: - http: paths: - backend: service: name: istio-ingressgateway port: number: 80 path: /* pathType: ImplementationSpecific -
Create the Ingress.
kubectl apply -f asm-gateway-ingress.yaml
Step 6: Test access
-
Get the address of the Ingress instance.
kubectl get ing -n istio-systemExpected output:
NAME CLASS HOSTS ADDRESS PORTS AGE asm-gateway-ingress alb * alb-xxxx.xxxx.alb.aliyuncs.com 80 18hThe address of the Ingress instance is
alb-xxxx.xxxx.alb.aliyuncs.com. -
Access the ASM ingress gateway.
-
Method 1: Access the ASM ingress gateway by using the address of the Ingress instance from the previous step:
http://alb-xxxx.xxxx.alb.aliyuncs.com/productpage. -
Method 2: Log on to the ALB console and access the ASM ingress gateway by using the public IP address of the ALB instance. If a domain name is bound to the ALB instance, you can also use the domain name to access the gateway. On the instance details page of the ALB console, view the basic information of the ALB instance ingress_test_base. In the zone section at the bottom, get the Elastic IP Address (EIP) of each zone.
-