700개 이상의 실습 및 과정 이용하기

gcloud and kubectl for Google Kubernetes Engine

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

GSP821

Google Cloud self-paced labs logo

Overview

Google Kubernetes Engine (GKE) provides a managed environment for deploying, managing, and scaling your containerized applications using Google infrastructure. The GKE environment consists of multiple machines (specifically Compute Engine instances) grouped to form a container cluster.

In this lab, you get hands-on practice with container creation and application deployment with GKE.

What you'll learn to do

In this lab you will learn how to:

  • Deploy an application to the GKE cluster

Cluster orchestration with Google Kubernetes Engine

Google Kubernetes Engine (GKE) clusters are powered by the Kubernetes open source cluster management system. Kubernetes provides the mechanisms through which you interact with your container cluster. You use Kubernetes commands and resources to deploy and manage your applications, perform administrative tasks, set policies, and monitor the health of your deployed workloads.

Kubernetes draws on the same design principles that run popular Google services and provides the same benefits: automatic management, monitoring and liveness probes for application containers, automatic scaling, rolling updates, and more. When you run your applications on a container cluster, you're using technology based on Google's 10+ years of experience with running production workloads in containers.

Kubernetes on Google Cloud

When you run a GKE cluster, you also gain the benefit of advanced cluster management features that Google Cloud provides. These include:

Now that you have a basic understanding of Kubernetes, you will learn how to deploy a containerized application with GKE in less than 15 minutes. Follow the steps below to set up your lab environment.

Setup and requirements

  • Labs are timed and cannot be paused. The timer starts when you click Start Lab.
  • The included cloud terminal is preconfigured with the gcloud SDK.
  • Use the terminal to execute commands and then click Check my progress to verify your work.

Pre-configured resource:

  • You have a pre-created GKE cluster for this lab named lab-cluster.

Task 1. Set a default compute zone

Your compute zone is an approximate regional location in which your clusters and their resources live. For example, us-central1-a is a zone in the us-central1 region.

In your cloud terminal, run the following commands.

  1. Set the default compute region:

    gcloud config set compute/region {{{project_0.default_region|"REGION"}}}

    Expected output:

    Updated property [compute/region].
  2. Set the default compute zone:

    gcloud config set compute/zone {{{project_0.default_zone|"ZONE"}}}

    Expected output:

    Updated property [compute/zone].

Task 2. Get authentication credentials for the GKE cluster

You need authentication credentials to interact with your cluster.

  • Use the following gcloud command to retrieve the cluster credentials:

    gcloud container clusters get-credentials lab-cluster

    Expected output:

    Fetching cluster endpoint and auth data. kubeconfig entry generated for lab-cluster.

    This command is used to authenticate your kubectl client to a specific Google Kubernetes Engine (GKE) cluster so that you can interact with the cluster. This command fetches the cluster's credentials and updates your kubectl configuration with the necessary information.

Task 3. Deploy an application to the GKE cluster

You can now deploy a containerized application to the cluster. For this lab, you'll deploy hello-app on your cluster.

GKE uses Kubernetes objects to create and manage your cluster's resources. Kubernetes provides the Deployment object for deploying stateless applications like web servers. Service objects define rules and load balancing for accessing your application from the internet.

  1. To create a new Deployment named hello-server from the hello-app container image, run the following kubectl create command:

    kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0

    Expected output:

    deployment.apps/hello-server created

    This Kubernetes command creates a deployment object that represents hello-server. In this case, --image specifies a container image to deploy. The command pulls the example image from a Container Registry bucket. gcr.io/google-samples/hello-app:1.0 indicates the specific image version to pull. If a version is not specified, the latest version is used.

    Click Check my progress to verify the objective. Create a new Deployment: hello-server

  2. To create a Kubernetes Service, which is a Kubernetes resource that lets you expose your application to external traffic, run the following kubectl expose command:

    kubectl expose deployment hello-server --type=LoadBalancer --port 8080

    In this command:

    • --port specifies the port that the container exposes.
    • type="LoadBalancer" creates a Compute Engine load balancer for your container.

    Expected output:

    service/hello-server exposed
  3. To inspect the hello-server Service, run kubectl get:

    kubectl get service

    Expected output:

    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-server loadBalancer 10.39.244.36 35.202.234.26 8080:31991/TCP 65s kubernetes ClusterIP 10.39.240.1 433/TCP 5m13s

    Note: It might take a minute for an external IP address to be generated. Run the previous command again if the EXTERNAL-IP column status is pending.

  4. To view the application from your web browser, open a new tab and enter the following address, replacing [EXTERNAL IP] with the EXTERNAL-IP for hello-server.

    http://[EXTERNAL-IP]:8080

    Expected output: The browser tab displays the message Hello, world! as well as the version and hostname.

    Click Check my progress to verify the objective. Create a Kubernetes Service

Congratulations!

You have just deployed a containerized application to Google Kubernetes Engine! In this lab, you deployed a containerized application to the GKE cluster. You can now apply this knowledge to deploy your own applications with GKE.

Next steps / Learn more

Learn more about the Google Kubernetes Engine:

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated January 9, 2025

Lab Last Tested November 19, 2024

Copyright 2025 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개만 가능

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

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

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