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

Background information

By default, if the control plane or data plane is modified, the control plane needs to push the new configuration to all sidecars on the data plane. Alibaba Cloud Service Mesh (ASM) can obtain the call dependencies between services on the data plane by analyzing the access logs generated by sidecars on the data plane. ASM can then automatically recommend a sidecar for each workload on the data plane. After a sidecar is automatically 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.

Considerations

  • If you select Use Default for Log Service Project when you enable access log collection for an ASM instance, ASM uses the Log Service project of the first cluster that you added to the ASM instance to recommend sidecars.
  • 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

  1. Log on to the ASM console.
  2. In the left-side navigation pane, choose Service Mesh > Mesh Management.
  3. On the Mesh Management page, find the ASM instance that you want to configure. Click the name of the ASM instance or click Manage in the Actions column.
  4. On the details page of the ASM instance, choose Configuration push optimization > Sidecar recommendation in the left-side navigation pane.
  5. On the Sidecar recommendation page, find the workload for which you want to recommend a sidecar and click Recommend in the Actions column.
    If Recommendation complete is displayed in the Recommendation status column of the workload, a sidecar is recommended for the workload.
  6. On the Sidecar recommendation page, find the workload for which you want to view the recommended sidecar and click View in the Actions column.
  7. In the Recommended Sidecar panel, verify that the value of the hosts parameter in the YAML file of the sidecar contains all the services that the workload needs to call. Then, click Create.
    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) Re-recommend a sidecar for a workload

The call dependencies between services in an ASM instance may change as business applications are updated. If the call dependencies change, the sidecars that ASM recommends for workloads become invalid. In this case, we recommend that you collect logs again and re-recommend sidecars for the workloads.

  1. Log on to the ASM console.
  2. In the left-side navigation pane, choose Service Mesh > Mesh Management.
  3. On the Mesh Management page, find the ASM instance that you want to configure. Click the name of the ASM instance or click Manage in the Actions column.
  4. On the details page of the ASM instance, choose Configuration push optimization > Sidecar recommendation in the left-side navigation pane.
  5. On the Sidecar recommendation page, find the workload for which you want to re-recommend a sidecar and click Recollecting Access Logs in the Actions column.
  6. In the Recollecting Access Logs message, click OK.
    The sidecar that is applied is deleted, and Recollecting access logs is displayed in the Recommendation status column of the workload.
  7. Re-generate access logs for analysis. For more information, see Step 1: Generate access logs.
  8. Re-recommend a sidecar for the workload. For more information, see Step 2: Recommend a sidecar for a workload.