
始める前に
- ラボでは、Google Cloud プロジェクトとリソースを一定の時間利用します
- ラボには時間制限があり、一時停止機能はありません。ラボを終了した場合は、最初からやり直す必要があります。
- 画面左上の [ラボを開始] をクリックして開始します
This lab is the second in a series of labs, each of which is intended to build skills related to the setup and operation of Anthos clusters on bare metal. In this lab, you start with the admin workstation and admin cluster in place; you then build the user cluster. After the user cluster is running, you deploy stateless and stateful workloads and expose the workloads using LoadBalancer services and Ingresses.
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:
Set the Zone environment variable
In Cloud Shell, SSH into the admin workstation with the following commands:
If prompted, answer Y, and press ENTER twice for an empty passphrase.
Change directories to the baremetal directory, then initialize environment variables needed for later commands:
Set the Zone environment variable
Configure kubectl to use the generated kubeconfig file that points to your admin cluster:
Rename your kubectl context to something a little easier to remember:
Test to make sure you can access and use your admin cluster:
You should see results that look like this:
Verify that the admin cluster has been registered with Anthos hub by visiting Navigation > Kubernetes Engine > Clusters. It should look like this:
In Cloud Shell, create a Kubernetes Service Account on your cluster and grant it the cluster-admin role:
Create a token that you can use to log in to the cluster from the Console:
Select the token in the SSH session (this will copy the token - don't try to copy with CTRL+C).
Find the abm-admin-cluster entry in the cluster list showing in the Console and click the three-dots menu at the far right of the row.
Select Log in, select Token, then paste the token from your Clipboard into the provided field. Click Login. When you're done, it should look like this:
In Cloud Shell, while SSH'd into the admin workstations, create the config file for the user cluster:
View the user cluster configuration file that was created above:
You can edit the configuration file manually, but for the purposes of this lab, you've been provided commands that will edit the file for you.
Delete the credentials file references from the configuration file:
Add a line to the beginning of the config file that points to the private ssh key:
Change the cluster type in the config file to user
:
Set the IP for the user cluster control plane's VM node:
Set the IP for the user cluster's control plane API server:
Set up the IP for the user cluster's Ingress:
Configure the IPs that will be associated when K8s LoadBalancer services are created:
Enable infrastructure and application logging for your user cluster:
Set the name for the user cluster's worker pool and the IP for the worker node:
Review the user cluster configuration file fully configured:
Create the user cluster; relax, this will take 10 minutes:
Make sure that your user cluster is fully created before continuing.
Configure kubectl to speak to the user cluster:
Test to make sure you can access and use your user cluster:
You should see results that look like this:
Notice that you have a node for the control plane and another one for your data plane.
Verify that the user cluster has been registered with Anthos hub by visiting Navigation > Kubernetes Engine > Clusters. It should look like this:
In Cloud Shell, create a Kubernetes Service Account on your cluster and grant it the cluster-admin role:
Get a token that you can use to log in to the cluster from the Console:
Select the token in the SSH session (this will copy the token - don't try to copy with CTRL+C).
Find the abm-user-cluster-central entry in the cluster list showing in the Console and click the three-dots menu at the far right of the row.
Select Log in, select Token, then paste the token from your Clipboard into the provided field. Click Login. When you're done, it should look like this:
In Cloud Shell, create a deployment for the hello-app application:
In the UI, visit Navigation > Kubernetes Engine > Workloads. On top of the table displaying all the cluster workloads, add a filter for the Cluster to be abm-user-cluster-central. Find the hello-app deployment that you just created.
In Cloud Shell, create a Kubernetes Service of type LoadBalancer to access the app:
In the UI, visit Navigation > Kubernetes Engine > Gateways, Services & Ingress. Find the hello-app service that you just created. You can see that it contains an external IP in the range that you configured earlier (10.200.0.100-10.200.0.200) in the user-cluster creation process.
In Cloud Shell, get the services and check that you have the same external IP. Copy the IP for this service, as you need it in the next task.
Access the external IP provided by the hello-app-service:
Create a second application deployment:
Create a Kubernetes Service of type NodePort to access the app. Notice that no external IP is associated:
Create a Kubernetes Ingress resource to route traffic between the two services:
Access the routes exposed by the Ingress to point to the hello-app-service:
Access the routes exposed by the Ingress to point to the hello-kubernetes-service:
Anthos clusters on bare metal are compatible with Container Storage Interface (CSI) v1.0 drivers. CSI is an open-standard API supported by many major storage vendors that enables Kubernetes to expose arbitrary storage systems to containerized workloads.
To use a CSI driver, you need to install the driver and you need to create a Kubernetes StorageClass. You set the CSI driver as the provisioner for the StorageClass. Then, you can set the StorageClass as the cluster's default, or configure your workloads to explicitly use the StorageClass.
Storage vendors develop their own CSI drivers, and they are responsible for providing installation instructions. In simple cases, installation might only involve deploying manifests to your clusters. See the list of CSI drivers in the CSI documentation.
In this lab, you install theCompute Engine Persistent Disk CSI driver, since the Anthos bare metal deployment is running on GCE and needs that type of driver to communicate with the GCE persistent disks. For production storage, we recommend installing a CSI driver from an Anthos Ready storage partner.
Initialize the environment variables used in the installation commands:
Check to see if any CSI drivers have been installed on the user cluster nodes:
You should see output that indicates there are no CSI drivers installed.
Clone the driver to your local machine:
Take a look at the setup-project.sh file to understand what setup actions need to be taken with your project:
Note that the script is creating a service account, downloading the corresponding key file, defining a customer role, and assigning roles to the service account.
Run the project setup script:
Deploy the CSI driver into your cluster:
Check the installed CSI drivers to verify that GCE PD driver has been installed on the user cluster nodes:
Create a new StorageClass on your user cluster, referencing your driver in the provisioner field:
Deploy an application comprised of a PersistentVolumeClaim (PVC) and a pod that uses that PVC. A persistent volume will be provisioned via the new StorageClass and CSI driver.
In the UI, visit Navigation > Kubernetes Engine > Storage. Check the Persistent Volume Claims list, and you should see a new PVC, of storage class gce-pd, called podpvc.
In the UI, visit Navigation > Kubernetes Engine > Workloads. Find the web-server pod that you just created and verify that is running. (It may take 1-2 minutes for the pod to become fully operational - you can wait and refresh the page to see the results).
If you get disconnected from Cloud Shell and want to sign back into the admin workstation:
If you get disconnected from Cloud Shell and want to connect to the admin cluster:
If you get disconnected from Cloud Shell and want to connect to the user cluster:
In this lab, you used the provisioned bare metal infrastructure to install an Anthos cluster on bare metal user cluster. You also deployed applications running in the user cluster load balancing in L4 with services exposed in the MetalLB load balancer, as well as L7 load balancing with the Ingress resource. In addition, you installed a CSI driver and deployed a stateful workload.
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.
このコンテンツは現在ご利用いただけません
利用可能になりましたら、メールでお知らせいたします
ありがとうございます。
利用可能になりましたら、メールでご連絡いたします
1 回に 1 つのラボ
既存のラボをすべて終了して、このラボを開始することを確認してください