Use the sidecars that are automatically recommended based on access log analysis
By default, the information about all services on the data plane is stored in the configuration of each sidecar because the call dependencies between services in a service mesh cannot be determined. You can use the sidecar configuration feature to enable the sidecars of workloads to focus only on the services that the workloads need to call. This topic describes how to use the sidecars that are automatically recommended based on access log analysis.
Prerequisites
An ingress gateway is deployed. For more information, see Create an ingress gateway.
An application is deployed in the cluster that is added to the ASM instance. For more information, see Deploy an application to an ASM-associated cluster.
-
You have used Log Service to collect access logs from the data plane. For more information, see Use Log Service to collect access logs of a data plane cluster.
Background information
By default, any modification to the control plane or data plane triggers the control plane to push configurations to all sidecars on the data plane. Service MeshASM can analyze the access logs generated by sidecars on the data plane to identify call dependencies between services and automatically recommend a sidecar resource for each workload. After a sidecar resource is recommended for a workload:
Only the information about the services on which the workload depends is stored in the configuration of the sidecar.
If a service on which the workload does not depend is modified, or a resource, such as a virtual service, related to the service is modified, the control plane does not push the new configuration to the sidecar.
Usage notes
-
If you select Use Default for the Log Service Project when you enable access log collection, ASM uses the Log Service Project of the first cluster that you add to the service mesh to recommend sidecar resources.
The sidecar recommendation feature of ASM recommends sidecars based on the service dependencies of each workload. This simplifies the sidecar configuration of the data plane to the maximum extent. However, you must separately configure the feature for each workload on the data plane. In addition, because sidecars are recommended based on access logs, if no service call records exist for a workload in the access logs, the sidecar recommended for the workload may be inaccurate. In this case, you must manually check the recommended sidecar.
Step 1: Generate access logs
In the address bar of your browser, enter http://{IP address of the ingress gateway service}/productpage. Refresh the page of the Bookinfo application multiple times until the page displays black stars and red stars in turns.
Step 2: Recommend a sidecar for a workload
-
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 Inbound and Outbound Traffic Configuration (Sidecar Object) page, find the target application and click Recommend in the Actions column.
Recommendation complete in the Recommendation status column indicates that the sidecar resource was successfully recommended for the workload.
-
On the Inbound and Outbound Traffic Configuration (Sidecar Object) page, find the target application and click View in the Actions column.
-
In the Recommended Sidecar panel, check the sidecar's YAML file. Ensure that the hosts parameter includes all services the workload calls. After you confirm, click OK.
If a service that the workload needs to call is not contained in the value of the hosts parameter in the YAML file of the sidecar, add the service name to the YAML file before you create the sidecar.
Step 3: (Optional) Recommend a sidecar for a workload again
When your business applications are updated, service call dependencies in the Service Mesh may change, making previous sidecar resource recommendations outdated. You should then recollect the access logs and generate new recommendations for the corresponding workloads.
-
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 Inbound and Outbound Traffic Configuration (Sidecar Object) page, find the target application and click Recollecting Access Logs in the Actions column.
-
In the Recollecting Access Logs dialog box, click OK.
The applied sidecar resource is deleted. The Recommendation status column for the application displays Recollecting access logs.
Re-generate access logs for analysis. For more information, see Step 1: Generate access logs.
Recommend a sidecar for the workload again. For more information, see Step 2: Recommend a sidecar for a workload.