
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Many applications will eventually need to be distributed and have services running across multiple Anthos clusters. Anthos Service Mesh enables this with multi-cluster meshes.
A multi-cluster service mesh is a mesh composed of services running on more than one cluster.
A multi-cluster service mesh has the advantage that all the services look the same to clients, regardless of where the workloads are actually running. It’s transparent to the application whether a service is deployed in a single or multi-cluster service mesh.
In this lab, you build a service mesh encompassing two clusters, west and east. You deploy an application comprised of services, some running on west and some on east. You test the application to make sure that services can communicate across clusters without problem.
In this lab, you learn how to perform the following tasks:
In this task, you use Qwiklabs and perform initialization steps for your lab.
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
After you complete the initial sign-in steps, the project dashboard opens.
Google Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Example output:
Output:
Example output:
Confirm that you have two GKE clusters already created (use either the
Navigation menu > Kubernetes Engine > Clusters page or run the command
gcloud container clusters list
).
Confirm that both clusters have been registered with the Anthos Connect Hub by visiting Navigation menu > Anthos > Clusters.
Set the zone environment variable for the west cluster:
Set the zone environment variable for the west cluster:
Configure environment variables to use in scripts throughout the lab:
Install the asmcli
command line utility which you will use to install
Anthos Service Mesh:
Add the context info for each cluster to your kubeconfig file, and create an easy context to remember alias for each context:
You can verify that the two aliased contexts exist, and that the currently selected context is east, by using the following command:
The result should look like this:
Install Anthos Service Mesh on the west cluster using this command:
Install an ingress gateway on your west cluster:
Switch to the east context and install Anthos Service Mesh on the east cluster using these commands:
GKE automatically adds firewall rules to each node to allow traffic within the same subnet. If your mesh contains multiple subnets, you must explicitly set up the firewall rules to allow cross-subnet traffic. You must add a new firewall rule for each subnet to allow the source IP CIDR blocks and targets ports of all the incoming traffic.
Create a firewall rule that allows all traffic between the two clusters in your mesh:
In order for each cluster to discover endpoints in the other cluster, the
clusters must all be registered in the same fleet, and each cluster must be
configured with a secret that can be used to gain access to the other cluster's
API server for endpoint enumeration. The asmcli
utility will set this up
for you.
Configure the clusters for multi-cluster mesh operation using asmcli
:
Let's verify that all Anthos Service Mesh resources have been created correctly on both clusters.
Verify the required namespaces were created on the west cluster:
Check to make sure the same namespaces exist on the east cluster.
Check the deployments running in each of the three new namespaces to verify that the expected features are up and running.
In this task, you install the Online Boutique app to both clusters. Online Boutique consists of 10 microservices written in different languages.
In this lab, you split the application across west and east clusters.
Begin by creating a namespace for the Online Boutique services on the west cluster, then enable sidecar injection on that namespace:
Review the manifest that deploys the workloads to the west cluster by visiting deployments.yaml in Github.
Review the manifest for the services created on the west cluster by visiting services.yaml in Github.
Review the manifest that creates service mesh components on the cluster by visiting istio-defaults.yaml in Github.
Now do you see how the services will be accessed from outside the cluster?
Download the repository with all resources.
Apply the manifest to create deploy application resources to the west cluster:
Using the Kubernetes Engine pages in the console, or kubectl
within
Cloud Shell, verify that the workloads and services have been deployed.
Switch to the east context, create a namespace for the Online Boutique services on the east cluster, then enable sidecar injection on that namespace:
Review the manifests for the east cluster, noting the workloads and services being deployed.
Apply the manifests to the east cluster:
Using the console or Cloud Shell, review the deployments and the services on your east cluster.
Get a URL to access the istio-ingressgateway
service on each cluster:
Click on each of the provided URLs and verify that the Online Boutique applications loads.
Try browsing products, adding items to your cart, and checking out. Everything should work even though half the services run on one cluster and half on the other.
In the console, visit Navigation menu > Anthos > Service Mesh.
You should see 13 services deployed within your mesh, split across your clusters. If you see a read Action Required banner, try refreshing the page in your browser. That warning should go away.
If you want to view services running on a single cluster, you can filter the display.
Navigate to Monitoring, then click View All for Kubernetes services
Try filtering to see only the services running on the west cluster.
Navigate back to Anthos > Service Mesh and click on the frontend service entry in your list to see details
Note that the frontend service is receiving traffic from the istio-ingressgateway service and the loadgenerator service.
On the left, click on Connected Services. Then select the Outbound tab in the Requests section.
Note that connections from the frontend service to utility services are all using mTLS, regardless of which cluster the target services are running on. Click on some of the services in the table at the bottom of the window and note where each service is running (the information is displayed in the slideout on the right).
Return to Navigation menu > Anthos > Service Mesh.
Click on each node and note where the service is running.
In the console, go to Navigation menu > Kubernetes Engine > Gateways, Services & Ingress.
Look at the recommendationservice entries in the table. Each cluster has a recommendationservice entry, but while the west cluster has 1 pod behind the service, the east cluster has 0 pods.
The actual workload is deployed on the west cluster and not on the east cluster. You're going to deploy the workload to the east cluster as well.
Take a moment to review the deployment manifest for the recommendationservice workload
Apply the manifest to the east cluster using the following command in Cloud Shell:
Return to Navigation menu > Kubernetes Engine > Gateways, Services & Ingress and click on Services Note that the east entry for the recommendationservice service now shows 1 pod running on the east cluster.
Return to Navigation menu > Anthos > Service Mesh. Note that the recommendationservice entry now shows the service on both clusters.
Click on the recommendationservice entry, then click on the Infrastructure option on the left. Note you now have metrics for the service running on both clusters.
If you don't see metrics for the second workload, wait a minute then refresh the page.
Click on Traffic on the left.
Click on the recommendationservice entry, which opens an info area on the right.
In the info area, click on the DETAILS tab and note the workloads running on both clusters.
Return to Navigation menu > Anthos > Service Mesh.
Click on the recommendationservice node in the graph and note that the info area on the right is the service that is running on both clusters.
In this lab, you deployed Anthos Service Mesh to 2 clusters, configured the two clusters to participate in a single mesh, deployed an application with services split across both clusters, and made one service a distributed service running on both clusters.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one