
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
Welcome to Anthos!
Kubernetes is the de-facto standard for container orchestration, and Google Kubernetes Engine (GKE) is a leader in the field of managed Kubernetes offerings. In 2018, Google brought Kubernetes to data centers with a new offering called Anthos, a certified and managed extension of the cloud-based GKE platform.
Responding to significant early successes and listening to customer needs, Google has expanded its efforts to enable your modernization effort.
Anthos is a modern application management platform announced by Google at Next '19. Anthos provides the tools and technology you need for modern, hybrid, and multi-cloud solutions, all built on the foundations of GKE. Anthos enables several features, including:
In this lab, you will deploy Anthos clusters on AWS. Note that Anthos has a number of other deployment options, such as Anthos clusters on bare metal, Anthos clusters on VMware, and Anthos clusters on Azure. In addition, you use Attached clusters, which are third-party Kubernetes clusters registered to your fleet.
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 appears.
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:
To access some of the resource types within Google Cloud, you first need to enable a few APIs. These are enabled automatically when you first access a service through the UI or command line. To simplify the process and reduce user prompts, you explicitly enable the APIs needed.
In the Cloud Shell, set up the following environment variables, which will be used in scripts throughout the lab:
In the Cloud Shell, enable APIs required for the tasks in the lab:
To confirm that specific APIs are enabled, in the Google Cloud Console, on the Navigation menu (), click APIs & Services.
To create your cluster, in Cloud Shell, run the following command:
This should begin the installation of your GKE cluster. Cluster creation will take about five minutes, so continue to the next task while installation continues in the background.
This lab has provisioned the following AWS Virtual Private Cloud (VPC) architecture for you to be able to run Anthos clusters on AWS. Refer to the Create an AWS VPC documentation to reproduce the setup steps.
The AWS VPC has been deployed in us-east-1
and uses the IP CIDR range
10.0.0.0/16
. It contains the following resources:
us-east-1a
,
us-east-1b
, us-east-1c
All subnets are tagged for subnet auto-discovery so that when you create a Kubernetes Service, an AWS Load Balancer can be provisioned in those networks. Internal load balancers will be provisioned in the private subnets, and internet-facing load balancers will be provisioned in the public subnets. The tag used dictates the type of load balancer.
Right-click on the AWS Console URL button on the Qwiklabs instructions page, and select Open Link in Incognito Window (or whatever the equivalent is in your browser).
Log in using the AWS Username and AWS Password provided by Qwiklabs.
In the search bar of the console window, enter vpc and press ENTER.
A dashboard displays all the AWS networking resources that have been deployed.
(Optional) Investigate the resources created and verify that they match the lab architecture diagram in the Objectives section of this lab guide. There might be some additional resources that AWS creates in every new account, but you can ignore them.
In the Google Cloud Console, open a new Cloud Shell tab.
In the new tab, set the project ID as an environment variable:
Download and install the AWS CLI:
Configure the AWS CLI:
At the prompt, enter the following:
Property | Value |
---|---|
AWS Access Key ID | |
AWS Secret Access Key | |
Default region name | us-east-1 |
Default output format | json |
Initialize the environment variables with the references to AWS resources:
Get the AWS VPC and the subnets, and store their IDs:
Get the AWS API Roles that will be used by the Anthos Multi-Cloud API to create and manage your clusters and node pools:
This role has a policy associated with permissions to manage AWS Key Management Service (KMS), Elastic Compute Cloud (EC2), Autoscaling, Elastic Load Balancer (ELB), and Identity and Access Management (IAM).
Get the AWS Key Management Service (KMS) keys:
Anthos clusters on AWS require two AWS KMS keys. In this lab, you use the same key for both use cases. The KMS keys encrypt:
Create the Anthos cluster on AWS:
Notice that the 10.1.0.0/16
IP CIDR range is used for Kubernetes
ClusterIP Services and the 10.2.0.0/16
IP CIDR is used for Kubernetes Pods. Those
CIDR ranges are part of the AWS VPC that you created but are not part of the
subnets. The subnets host the cluster nodes.
Congratulations! You have started the Anthos cluster on AWS creation process. This process will take approximately 5 minutes to complete.
Switch back to the browser tab with Cloud Shell open, and when the command returns, generate an asymmetric private key and import its public key into AWS:
In the next step, you associate them with the EC2 node pool instances to be able to SSH into them later.
Add a node pool to your cluster:
Obtain the credentials to your cluster:
Check the cluster information:
Output:
Notice that you are not connecting directly to your Anthos cluster on AWS. Instead, you are connecting through the Anthos Connect Gateway, which then securely forwards the requests via the connect agent to the Kubernetes API server.
Verify that you can see your worker nodes:
To authorize the Kubernetes workload identity gke-system/gke-telemetry-agent
to write logs
to Cloud Logging and write metrics to Cloud Monitoring, run this command:
Anthos clusters on AWS can create and upload system logs and metrics to Google Cloud's operations suite only if authorized.
In your browser, switch to the tab with Google Cloud Console.
On the Navigation menu, click Kubernetes Engine > Clusters.
In the row for aws-cluster in the cluster list, click the 3-dots menu.
Select Log in, select Use your Google Identity to log-in, and then click Login.
Click on the aws-cluster entry to display information about your Anthos cluster on AWS.
On the Navigation menu, click Anthos > Overview. One cluster is displayed.
Click View all clusters.
Click on the aws-cluster entry.
A Details pane displays information about your AWS Anthos Cluster.
Return to the first Cloud Shell tab.
Verify that your cluster has been created. The output from the initial cluster creation command should look like this:
You may need to wait for a minute or two for the cluster to be created.
To configure kubectx with a short name for the kubectl context that is used to manage the Google Cloud cluster, run the following command:
While registering the cluster, you can configure the Connect Agent to use either Workload Identity or a Google Cloud Service Account. In this lab, you use Workload Identity.
Register the GKE cluster on the Anthos Hub:
In the Cloud Console, on the Navigation menu, click Anthos > Overview. Cluster Status should now list two available clusters.
Click View all clusters. A list displays your GKE on Google Cloud cluster.
Click on the gcp-cluster entry to see cluster details.
In your browser, return to the Cloud Shell tab. Switch to the first Cloud Shell terminal tab, where you originally created the cluster on Google Cloud.
Ensure that kubectl
is configured in this terminal window to point to your
Google Cloud cluster:
Create a manifest for a Kubernetes Deployment of a simple application:
Create the deployment on your Google Cloud cluster:
In the Cloud Console, go to Kubernetes Engine > Workloads, and verify that the Deployment has been created and the pods are running.
You can also check the pods from the command line:
Return to the Cloud Shell tab. Create a Kubernetes service manifest for your application:
Create the service:
In the Cloud Console, go to Kubernetes Engine > Services & Ingress, and verify that the Service has been created and the external IP address has been assigned. It make take a minute or two until the service is ready.
You can also check the pods from the command-line:
When the service is ready, get the External IP address of the load balancer and load that address in a new browser tab. You should see output like this:
Now, you will do the same deployment to your AWS cluster.
Switch to the browser tab with Cloud Shell.
Switch to the second Cloud Shell tab where you created the AWS cluster.
Ensure that kubectl
is configured to manage your AWS cluster:
Apply the deployment and service manifest to your AWS cluster:
Confirm that the deployment was successfully created:
Confirm that the service was successfully created:
You can also check both via GKE management UI in the console.
Switch to the browser tab with the Google Cloud Console.
On the Navigation menu, click Kubernetes Engine > Workloads.
A second my-deployment-50001 entry is displayed, this time for aws-cluster.
In the menu pane, click Services & Ingress.
Two my-lb-service entries, one for each cluster, are displayed.
Click the link in the Endpoints column for the aws-cluster my-lb-service.
The same hello world
message you saw with
the gcp-cluster deployment should be displayed. If you see an error, wait a minute or two
until the load balancer in AWS has finished setting up, and then try again.
Enter Y and press enter to confirm.
Delete your cluster Anthos cluster on AWS:
Enter Y and press enter to confirm.
Delete your GKE cluster:
In this lab, you created and registered Anthos GKE clusters on Google Cloud and
AWS. You managed clusters using both the CLI and the Google Cloud Console. You
deployed workloads using standard kubectl
commands 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