[Kubernetes in Google Cloud][중급] - Lecture1. Introduction to Google Cloud

윰진·2023년 6월 4일
0

빅데이터특화과정

목록 보기
7/8

GOAL

  • 클라우드 컴퓨팅 기본 개념 이해
  • Google Cloud의 리소스 구성과 관리 방법 학습
  • 리소스 할당 및 해제를 위한 도구 사용 방법 학습

Lecture 1. Cloud Computing and Google Cloud

1 ) Cloud Computing의 다섯가지 속성

  • 주문형 셀프서비스로 컴퓨팅 리소스를 할당
    • 필요한 성능, 스토리지, 네트워크를 확보
  • 네트워크를 통해 어디서나 리소스에 액세스
  • 대규모 풀에서 리소스를 할당{\rightarrow}규모의 경제에서 오는 이점을 가질 수 있음
  • 탄력적인 리소스 사용
  • 리소스를 사용/예약한 만큼 피용 지불

2 ) GCP에서 제공하는 서비스들

  • Compute Engine
    • 서버 인스턴스를 스스로 관리하려는 사용자에게 유연성을 제공 (가상 머신 배포 환경 관리)
    • Google Cloud의 IaaS 제품
  • Google Kubernetes Engine(GKE)
    • 주어진 권한에 따라 컨테이너화된 애플리케이션 배포 환경 관리
  • App Engine
    • 인프라에 대한 고려없이 클라우드에서 코드 실행
      • 애플리케이션에 대한 서버리스 플랫폼 관리
    • Google에서 프로비저닝과 리소스 관리를 처리
  • Cloud Function
    • Function에 해당하는 이벤트 발생
    • Google에서 리소스 할당 관리
    • 사용한만큼 비용 지불

📑 DB의 경우, Compute Engine이나 GKE에 자체 데이터베이스 서버를 운영하거나 Bigtable/Cloud Storage/Cloud SQL/Cloud Spanner/DataStore 같은 스토리지를 사용할 수 있다.

📑 이외에도 Google Cloud는 Vision API 같은 다양한 ML API를 제공

Quize

1 ) Which of these Google Cloud compute services provides environments for execution of code, in which users don't have to worry about infrastructure management? Choose all that are correct (2 correct answers).

📑 인프라 고려 없이 코드만 실행할 수 있도록 환경을 제공하는 Google Cloud 서비스는?

정답 : App Engine, Cloud Functions


2 ) Which statements are true about cloud computing? Mark all that are true (2 correct answers).

📑 클라우드 컴퓨팅 설명 맞는 것 두 가지

정답 :

  • Customers pay for the resources they use or reserve.
  • Customers who need more resources can get them rapidly

오답 :

  • Cloud computing providers dedicate particular physical resources to particular customers.
  • Human intervention is required to stop using cloud resources once reserved, and payment continues until the change is confirmed.

Lecture 2. Resource Management

하드웨어 같은 물리적 리소스와 가상 머신, 컨테이너 같은 가상 리소스는 Google의 글로벌 데이터 센터에서 관리

  • Multi-region, Region, Zone에서 리소스 제공

1 ) 리소스 할당 위치

Multi-region

  • America, Europe, Asia

Region

  • 같은 대륙 내에서 독립적인 지리적 위치로 구성
    • 동일한 Region 내에서는 네트워크 연결이 빠름

Zone

  • Region 내에서 집중된 GCP 리소스 배포 위치
    • Compute Engine과 가상 머신 인스턴스는 특정 Zone 내에 존재
      {\rightarrow} 애플리케이션을 여러 Zone에 배포하면 가용성과 내결함성이 좋아짐

2 ) 리소스 계층도

  • 각 계층 별로 리소스를 관리할 수 있음
    • 하위 수준으 상위 수준의 정책을 상속

📑 GCP는 Low-level의 보안, 네트워크 보안 등의 하위 계층의 보안을 관리해줌

Quize


1. Within which of these Google Cloud geographic scopes are network latencies generally less than 1 millisecond? Choose all that are correct (2 correct answers).

📑 1ms보다 작은 latency를 가지는 지리적 영역 두 가지

정답 : Zone, Region

2. What type of resource is a Compute Engine virtual machine?

정답 : Zonal

3. What is the base-level organizing entity for creating and using Google Cloud resources and services?

📑 Gogle Cloud 리소스와 서비스를 사용하고 만드는 기본 관리 단위

정답 : Project

Lecture 3. Billing

💰 한계점 설정을 할 수 있어 일정량에 도달하면 서비스 중지 등의 설정이 가능

  • 리소스를 사용한 만큼 비용 지불

Quize

1 ) Which type of quota resets at regular intervals?

정답 : Rate quotas

2) At what level in the Google Cloud resource hierarchy is billing set up?

정답 : Project

Lecture 4. Interacting with Google Cloud

1 ) Google Cloud와 상호작용하는 방법

  • Google Cloud Console
  • Cloud SDK and Cloud Shell
    • gcloud, kubectl, gsutil, bq
  • Cloud Console mobile app
  • REST-based API
    • 초당 호출 횟수 등을 확인할 수 있음

Quiz

1.
Which of these ways to interact with give you access to the gcloud and kubectl commands? Choose all that are correct (2 correct answers).

📑 glcoud와 kubectl 명령에 접근할 수 있는 상호작용 방법 2가지

정답 : Cloud Shell, Cloud SDK

Lecture 5. Summary

Lab. Accessing the Google Cloud Console and Cloud Shell

GOAL

  • GCP 콘솔 사용법 배우기
  • Cloud Shell 코드 편집기 등 기능 알아보기
  • GCP 콘솔과 Cloud Shell로 버킷, VM, 서비스 계정 생성 실습

Task 1. Explore the Google Cloud Console

a ) bucket 만들기

b ) VM Instance 만들기

c ) VM 세부사항 확인하기

d ) IAM service account 생성하기

📑 IAM 서비스 계정은 애플리케이션이나 가상 머신에 속하는 특별한 유형의 Google 계정




📑 KEY는 나중에 VM에 업로드하여 사용될 예정

Task 2. Task 2. Explore Cloud Shell

📑 Cloud Shell은 브라우저에서 cloud resources에 직접적인 접근을 할 수 있는 comand-line을 제공

  • gcloud 같은 Cloud SDK command-line tools를 항상 최신, 최고 권한으로 사용 가능

Cloud Shell에서 가능한 일들

  • 임시 Compute Engine VM
  • Browser에서 Command-line으로 instance에 접근
  • 영구 디스크 저장소 5GB ($HOME dir)
  • 설치되어 있는 Cloud SDK와 다른 도구들
  • gcloud : Cloud Engine, GKE 그리고 많은 Google Cloud services 작업용
  • gsutil : Cloud Storage 작업용
  • kubectl : GKE와 Kubernetes 작업용
  • bq : BigQuery 작업용
  • 다양한 프로그래밍 언어 지원
  • 웹 미리보기 기능
  • 리소스와 인스턴스에 대한 액세스 권한 내장

📑 1시간 동안 활동이 없으면 Cloud Shell Instance가 재활용됨 (/home directory만 영구)

a ) Use Cloud Shell to set up the environment variables for this task

📑 버킷 생성/관리를 위한 환경변수 설정
✨ Cloud Shell을 사용할 때는 환경변수를 사용하여 오류 발생 확률을 줄이자

MY_BUCKET_NAME_1=[BUCKET_NAME]
MY_BUCKET_NAME_2=[BUCKET_NAME_2]
MY_REGION=us-central1

b ) Move the credentials file you created earlier into Cloud Shell

📑 IAM service account 생성 시 다운로드 받은 KEY를 credentials.json으로 rename하여 VM에 업로드


c ) Create a second Cloud Storage bucket and verify it in the Cloud Console

📑 gsutil로 버킷 만들어서 확인하기

gsutil mb gs://$MY_BUCKET_NAME_2

d ) Use the gcloud command line to create a second virtual machine

📑 두 번째 VM 생성하기

Region에 할당된 모든 Zone list 확인

gcloud compute zones list | grep $MY_REGION

Zone 설정

MY_ZONE=[ZONE]
gcloud config set compute/zone $MY_ZONE

VM 이름 설정 및 생성

gcloud compute instances create $MY_VMNAME \
--machine-type "e2-standard-2" \
--image-project "debian-cloud" \
--image-family "debian-11" \
--subnet "default"

Instance 확인

e ) Use the gcloud command line to create a second service account

service account 생성

gcloud iam service-accounts create test-service-account2 --display-name "test-service-account2"

두 번째 service account에 권한 부여

gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT --member serviceAccount:test-service-account2@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com --role roles/viewer

Task 3. Work with Cloud Storage in Cloud Shell

📑 Cloud Shell에서 Cloud Storage 사용하기

a ) Download a file to Cloud Shell and copy it to Cloud Storage

이미지 다운로드

  • 구글에서 제공된 Cloud Storage에서 고양이 이미지를 Cloud Shell로 복사
gsutil cp gs://cloud-training/ak8s/cat.jpg cat.jpg

버킷으로 복사

gsutil cp cat.jpg gs://$MY_BUCKET_NAME_1

첫 번째에서 두 번째 버킷으로 복사

gsutil cp gs://$MY_BUCKET_NAME_1/cat.jpg gs://$MY_BUCKET_NAME_2/cat.jpg

b ) Set the access control list for a Cloud Storage object

object 접근 권한 확인

gsutil acl get gs://$MY_BUCKET_NAME_1/cat.jpg  > acl.txt
cat acl.txt

접근 권한을 private으로 변경하기

gsutil acl set private gs://$MY_BUCKET_NAME_1/cat.jpg

변경된 권환 확인

gsutil acl get gs://$MY_BUCKET_NAME_1/cat.jpg  > acl-2.txt
cat acl-2.txt

c ) Authenticate as a service account in Cloud Shell

gcloud config list
gcloud auth activate-service-account --key-file credentials.json
gcloud config list

Task 4. Explore the Cloud Shell code editor

📑 first-vm에 nginx 설정해서 메인 페이지에 cat.jpg 보여주기

index.html에 넣을 cat.jpg 이미지 경로 참고

  • 첫 번째 버킷의 이미지 경로 복사하기

    업로드중..
    실습 정리 진행중

0개의 댓글