Alibaba Cloud Service Mesh integrates with an Application Load Balancer (ALB) for Container Service for Kubernetes (ACK) clusters that use the Terway network plugin on the data plane. This integration simplifies service governance, ensures secure authenticated communication between services, provides mesh observability, and reduces the workload for development and operations. This topic describes how to integrate an ASM Service Mesh with an ALB.
Prerequisites
-
An ACK cluster is added to your ASM instance, and the ASM instance and 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 more information, see Manage components.
-
-
-
Automatic sidecar proxy injection is enabled for the default namespace. For more information, see Enable automatic injection.
-
An ingress gateway is created with the CLB instance type parameter set to Private Access and Service Port set to 80. For more information, see Create an ingress gateway.
Step 1: Deploy a sample application
Run the following command on the data plane cluster to deploy the Bookinfo sample application. For more information, see Deploy an application in a cluster associated with an ASM instance.
kubectl apply -f https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/platform/kube/bookinfo.yaml
Step 2: Create Istio resources
You will create a Gateway resource and a VirtualService for testing purposes.
-
Create a Gateway resource.
-
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.
In the Basic Information section, select
defaultfor Namespace and enterbookinfo-gatewayfor Name. In the Apply to Gateway section, add a label with the keyistioand the valueingressgateway. In the Service section, enterhttpfor Name, enter80for Port, and select HTTP for Protocol. Then, click Create. -
Click Preview to review the YAML file for the Gateway resource. After you confirm the configuration is correct, click OK. Then, click Create at the bottom of the Create page.
-
-
Create a VirtualService and set up routing.
-
On the details page of the ASM instance, choose in the left-side navigation pane.
-
On the VirtualService page, click Create to configure a virtual service for the bookinfo-gateway.
Set Namespace to default and Name to 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 matching 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 object
Scenario 1: Integrate an existing ALB instance
-
Log on to the ALB console and obtain your ALB instance ID.
-
Create a file named alb-demo.yaml with the following content.
Replace
config.idwith your ALB instance ID.apiVersion: alibabacloud.com/v1 kind: AlbConfig metadata: name: default spec: config: id: alb-xxxxx forceOverride: false -
Run the following command to create the AlbConfig object.
kubectl apply -f alb-demo.yaml
Scenario 2: Integrate a new ALB instance
-
Create a file named alb-demo.yaml with the following content. For more information, see Expose services by using an ALB Ingress.
This example automatically creates an ALB instance named 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) The address type of the load balancer. Valid values:
-
Internet (default): The load balancer has a public IP address. The DNS record resolves to the public IP address, and the load balancer can be accessed over the internet.
-
Intranet: The load balancer has only a private IP address. The DNS record resolves to the private IP address, and the load balancer can be accessed only from within the VPC where it is deployed.
zoneMappings(Required) The vSwitch IDs for the ALB Ingress. You must specify at least two vSwitch IDs that are in different availability zones. The specified vSwitches must be in availability zones supported by ALB. For information about supported regions and availability zones, see Regions and zones supported by ALB. For information about how to create a vSwitch, see Create and manage vSwitches.
-
-
Run the following command to create the AlbConfig object.
kubectl apply -f alb-demo.yaml
Step 4: Create an IngressClass resource
-
Create a file named alb.yaml and copy the following content into it.
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 -
Run the following command to create the IngressClass resource.
kubectl apply -f alb.yamlExpected output:
ingressclass.networking.k8s.io/alb created
Step 5: Create an Ingress resource
The service for the ASM ingress gateway runs in the istio-system namespace. You must create the Ingress resource in the same istio-system namespace of your data plane cluster (the ACK cluster). The port must be consistent with port 80, which you configured for the ASM ingress gateway.
-
Create a file named asm-gateway-ingress.yaml and copy the following content into the file.
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 -
Run the following command to create the Ingress resource.
kubectl apply -f asm-gateway-ingress.yaml
Step 6: Test access
-
Run the following command to get the Ingress address.
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 Ingress address is
alb-xxxx.xxxx.alb.aliyuncs.com. -
Access the ASM ingress gateway.
-
Method 1: Access the ASM gateway by using the address of the Ingress instance that you obtained in the previous step:
http://alb-xxxx.xxxx.alb.aliyuncs.com/productpage. -
Method 2: Log on to the ALB console and access the ASM gateway using the public IP address of the ALB instance or its bound domain name. On the instance details page in the ALB console, view the basic information of the alb-demo ALB instance. In the availability zone section at the bottom, you can find the Elastic IP Address (EIP) for each availability zone.
-