arrow_back

Provision Cloud Infrastructure with Gemini

로그인 가입
700개 이상의 실습 및 과정 이용하기

Provision Cloud Infrastructure with Gemini

실습 1시간 15분 universal_currency_alt 크레딧 5개 show_chart 입문
info 이 실습에는 학습을 지원하는 AI 도구가 통합되어 있을 수 있습니다.
700개 이상의 실습 및 과정 이용하기

Overview

Gemini for Google Cloud is an always-on AI collaborator that provides help to users of all skill levels where they need it. In this lab, you will learn how to use Gemini, an AI-powered collaborator in Google Cloud, to to create, test, and modify a Google Kubernetes Engine (GKE) cluster in Autopilot mode.

Note: Duet AI was renamed to Gemini, our next-generation model. This lab has been updated to reflect this change. Any references to Duet AI in the user interface or documentation should be treated as equivalent to Gemini while following the lab instructions. Note: As an early-stage technology, Gemini can generate output that seems plausible but is factually incorrect. We recommend that you validate all output from Gemini before you use it. For more information, see Gemini for Google Cloud and responsible AI.

Objectives

In this lab, you will learn how to perform the following tasks:

  • Enable Gemini
  • Explore various Google services that you can use to deploy an app to GKE by asking Gemini context-based questions.
  • Prompt Gemini to provide commands that you can use to deploy a basic app to a GKE cluster.
  • Create, explore, and modify the GKE cluster by using Gemini to explain and generate the shell commands.

Setup and requirements

For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab Details panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab Details panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left, or type the service or product name in the Search field. Navigation menu icon

Task 1. Enable Gemini

You will first enable Gemini in your Google Cloud project and configure the necessary permissions for your Google Cloud Qwiklabs user account.

  1. Click on the Cloud Shell icon (Cloud Shell icon) in the top-right corner of the Google Cloud console toolbar.

  2. To set your project ID and region environment variables, run the following commands:

PROJECT_ID=$(gcloud config get-value project) REGION={{{project_0.default_region|lab region}}} echo "PROJECT_ID=${PROJECT_ID}" echo "REGION=${REGION}" Note:It is worth noting the region, as it may differ to the sample prompts below.
  1. To store the signed-in Google user account in an environment variable, run the following command:
USER=$(gcloud config get-value account 2> /dev/null) echo "USER=${USER}"
  1. Click Authorize if prompted.

  2. Enable the Cloud AI Companion API for Gemini:

gcloud services enable cloudaicompanion.googleapis.com --project ${PROJECT_ID}
  1. To use Gemini, grant the necessary IAM roles to your Google Cloud Qwiklabs user account:
gcloud projects add-iam-policy-binding ${PROJECT_ID} --member user:${USER} --role=roles/cloudaicompanion.user gcloud projects add-iam-policy-binding ${PROJECT_ID} --member user:${USER} --role=roles/serviceusage.serviceUsageViewer

Adding these roles lets the user use Gemini assistance.

Click Check my progress to verify the objective. Enable the Cloud AI Companion API for Gemini and grant IAM roles

Task 2. Deploy GKE clusters

In this task, you use the Google Cloud console and Cloud Shell to deploy GKE clusters.

For the following example, consider that you are an infrastructure admin who is responsible for setting up infrastructure for a team developing a web application. The organization at large has standardized on containers and Kubernetes, so the team wants to understand how to run their web application on Kubernetes in Google Cloud. The team also wants to understand how to do so with as little infrastructure management overhead as possible.

In this case, you have the existing GKE cluster running a set of microservices that make up an ecommerce web app. With Gemini assistance, you will now identify areas to improve.

  1. Return to your tab with the Google Cloud console.

  2. Refresh the Google Cloud console page.

  3. Click on the Gemini icon (Gemini icon) in the top-right corner of the Google Cloud console toolbar.

  4. Click the Start Chatting button.

  5. Enter the following prompt:

How can I run Kubernetes on Google Cloud without having to own management of nodes and the control plane? Note: When you construct prompts for Gemini, use the same amount of detail and context that you would provide if you were to ask the question of a subject matter expert.

Gemini should respond with something similar to the following:

To run Kubernetes on Google Cloud without having to own management of nodes and the control plane, you can use Google Kubernetes Engine (GKE) in Autopilot mode. In Autopilot mode, Google manages the control plane and system components for you, and also manages your worker nodes. Note: Gemini doesn't use your prompts or its responses as data to train its model. For more information, see How Gemini in Google Cloud uses your data.

From the information that Gemini has provided, it looks like a GKE autopilot cluster will meet our needs.

Task 3: Deploy a GKE Autopilot cluster

In this task, you prompt Gemini on how to deploy a GKE Autopliot cluster.

  1. Enter the following prompt:
How do I create a GKE Autopilot cluster?

Gemini responds with the instructions for creating a cluster using the Google Cloud console and instructions for creating a cluster using the Google Cloud CLI.

Note: When you ask Gemini for help, you should include as much context and specific detail as possible. Because AI-generated responses are based on a vast range of possibilities, it's important for you to be precise.
  1. When you see a response that includes placeholder values such as CLUSTER_NAME, REGION, and PROJECT_ID, adding that information to the prompt could lead to even more useful responses. Refine the prompt again with more detail:
What is the command to create a GKE Autopilot cluster in my current project and in the {{{project_0.default_region|lab region}}} region named gemini-demo using the gcloud CLI?

Gemini should respond with something similar to the following:

gcloud container clusters create-auto gemini-demo --region {{{project_0.default_region|lab region}}} Note: If the command given by Gemini is significantly different from the example above, use the above command instead.
  1. Click on the Cloud Shell icon (Cloud Shell icon) in the Gemini toolbar.

The command is copied to Cloud Shell.

  1. Click Enter to run the command.
Note: You need to wait a few minutes for the cluster deployment to complete.

When provisioning is complete, the Kubernetes Engine > Clusters page looks like this screenshot:

Clusters page

  1. Click the cluster name gemini-demo to view the cluster details.

You can scroll down the page to view more details.

Click Check my progress to verify the objective. Deploy GKE cluster

Task 4 : Deploy a sample web application

Now that you have created a GKE cluster in Autopilot mode, you now decide you would like to test running a sample web application similar to the web application your team will run on this infrastructure. Internally, you see that you have the following container image from Google us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0 bookmarked for testing a containerized web application:

  1. In the Gemini pane, enter the following prompt, and then click Send:
What is the kubectl command to create a deployment called hello-server for the image us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0?

Gemini will respond with something similar to:

To create a deployment called hello-server for the image us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0, you can use the following kubectl command:

kubectl create deployment hello-server --image=us-docker.pkg.dev/google-samples/containers/gke/hello-app:1.0

Run the kubectl command in the Cloud Shell.

  1. With the web server now created, you now decide you want to test out provisioning a load balancer in front of the web server to expose it to the internet.

In the Gemini pane, enter the following prompt, and then click Send:

What is the kubectl command to expose this deployment on port 80 and target port 8080 with a load balancer?

Gemini should respond with something similar to the following:

To expose a deployment called hello-server with a load balancer, you can use the following kubectl expose command: kubectl expose deployment hello-server --type LoadBalancer --port 80 --target-port 8080 This will create a Compute Engine load balancer for your container.

While providing more context is always helpful, notice how Gemini was able to pull the deployment name hello-server from the conversation history without it being included in the prompt.

  1. In Cloud Shell, run the command provided by Gemini.

  2. Now you want to see if the web server is running and serving requests properly. To view your deployed application, you need to retrieve the external IP address from the Kubernetes service you created.

Enter the following prompt:

What is the kubectl command to see the external IP address associated with this load balancer?

Gemini should respond with something similar to the following:

To see the external IP associated with a load balancer, you can use the following kubectl command:

kubectl get service hello-server

This will output the name of the service, the type of service, the cluster IP address, the external IP address, and the ports that the service is listening on.
  1. In Cloud Shell, run the command provided by Gemini.

After a few minutes, the above kubectl command will yield the result in an output similar to:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-server LoadBalancer 34.118.227.57 35.225.15.112 80:31473/TCP 6m18s
  1. Open another tab in your browser and navigate to the external IP address for the cluster.

You should see the hello-app running in the tab.

Clusters page

Click Check my progress to verify the objective. Deploy a sample workload

End your lab

When you have completed your lab, click End Lab. Qwiklabs 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:

  • 1 star = Very dissatisfied
  • 2 stars = Dissatisfied
  • 3 stars = Neutral
  • 4 stars = Satisfied
  • 5 stars = Very satisfied

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 2024 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. 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
  2. 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
  3. 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.

시크릿 브라우징 사용

  1. 실습에 입력한 사용자 이름비밀번호를 복사합니다.
  2. 비공개 모드에서 콘솔 열기를 클릭합니다.

콘솔에 로그인

    실습 사용자 인증 정보를 사용하여
  1. 로그인합니다. 다른 사용자 인증 정보를 사용하면 오류가 발생하거나 요금이 부과될 수 있습니다.
  2. 약관에 동의하고 리소스 복구 페이지를 건너뜁니다.
  3. 실습을 완료했거나 다시 시작하려고 하는 경우가 아니면 실습 종료를 클릭하지 마세요. 이 버튼을 클릭하면 작업 내용이 지워지고 프로젝트가 삭제됩니다.

현재 이 콘텐츠를 이용할 수 없습니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

감사합니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

한 번에 실습 1개만 가능

모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.

시크릿 브라우징을 사용하여 실습 실행하기

이 실습을 실행하려면 시크릿 모드 또는 시크릿 브라우저 창을 사용하세요. 개인 계정과 학생 계정 간의 충돌로 개인 계정에 추가 요금이 발생하는 일을 방지해 줍니다.