Home Cloud-Data-Infra - (Day1)
Post
Cancel

Cloud-Data-Infra - (Day1)

Amazon Glue

  • AWS Glue는 분석 사용자가 여러 소스의 데이터를 쉽게 검색, 준비, 이동, 통합할 수 있도록 하는 서버리스 데이터 통합 서비스입니다. 분석, 기계 학습 및 애플리케이션 개발에 사용할 수 있습니다. 또한 작성, 작업 실행, 비즈니스 워크플로 구현을 위한 추가 생산성 및 데이터 운영 도구도 포함됩니다.

AWS Glue를 사용하면 70개 이상의 다양한 데이터 소스를 검색하여 연결하고 중앙 집중식 데이터 카탈로그에서 데이터를 관리할 수 있습니다. 추출, 변환, 로드(ETL) 파이프라인을 시각적으로 생성, 실행, 모니터링하여 데이터 레이크에 데이터를 로드할 수 있습니다. 또한 Amazon Athena, Amazon EMR, Amazon Redshift Spectrum을 사용하여 카탈로그화된 데이터를 즉시 검색하고 쿼리할 수 있습니다.

Amazon EMR, Glue Catalog

wget https://aws-dojo.com/ws41/customers.csv

aws s3 cp ./customers.csv s3://glue-demo-kbi-0127/customers/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys
from datetime import datetime
from pyspark.sql import SparkSession
from pyspark.sql.functions import *

spark = SparkSession.builder.appName("SparkETL").getOrCreate()
sark.catalog.setCurrentDatabase(demodb")
df = spark.sql("select * from customers_csv")
df.show()

spark.catalog.setCurrentDatabase(”demodb")
df = spark.sql("select * from customers_csv")
df.show()

df = df.select("CUSTOMERNAME","EMAIL")
df.show()

df.write.format("json").mode("overwrite").save(" s3://glue-demo-kbi-0127/output/") 

Data-Pipeline

https://catalog.us-east-1.prod.workshops.aws/workshops/a861fb26-12b0-4669-b3c3-ae1def49735d/ko-KR/introduction

Access key : AKIAY2QOD2KKB5SDBL7G Secret Access key : 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

Kubernetes

https://catalog.us-east-1.prod.workshops.aws/workshops/9c0aa9ab-90a9-44a6-abe1-8dff360ae428/ko-KR

Container, Kubernetes 입문

컨테이너

  • 운영체제 레벨의 가상화를 제공
  • 초단위로 올라가기 때문에 굉장히 빠르게 수정할 수 있다.
  • 어플리케이션과 바이너리만을 패키징한다.
  • 작은 용량, 작은리소스, 빠른 시간

OCI () 로 통일되어 관리된다.

docker

  • 레지스트리로부터 로컬에 없는 Layer 만 받아온다.
  • VM은 hypervisor 가 떠서 돌리지만, Container 의 경우에는 각각 올라간다.
  • docker 에서 run은 pull + start 를 의미한다.
  • layer 를 줄이기 위해 한번에 만들기 위해, DockerFile의 명령어들을 &&으로 묶어 사용한다.

Kubernetes workshop

Kubernetes 란?

kubernetes : 쿠버네티스는 컨테이너화된 워크로드와 서비스를 관리하기 위한 이식성이 있고, 확장가능한 오픈소스 플랫폼이다. 쿠버네티스는 선언적 구성과 자동화를 모두 용이하게 해주는 컨테이너 오케스트레이션 툴이다.

  • 노드들은 크게 두 가지 유형으로 나뉜다.
    • 컨트롤 플레인(Control Plane)은 워커 노드와 클러스터 내 파드를 관리하고 제어합니다.
    • 데이터 플레인(Data Plane)은 워커 노드들로 구성되어 있으며 컨테이너화된 애플리케이션의 구성 요소인 파드를 호스트합니다.
  • kubernetes objects
    • 쿠버네티스의 오브젝트는 바라는 상태(desired state)를 담은 레코드입니다.
    • 오브젝트를 생성하면 쿠버네티스의 컨트롤 플레인에서 오브젝트의 현재 상태(current state) 와 바라는 상태를 일치시키기 위해 끊임없이 관리합니다.
    • 쿠버네티스의 오브젝트에는 파드(pod), 서비스(service), 디플로이먼트(Deployment) 등이 있습니다.
  • EKS 클러스터 배포방식
    • AWS 콘솔 창 에서 클릭으로 배포하는 방법
      • AWS CloudFormation 혹은 AWS CDK 와 같은 IaC(Infrastructure as Code) 도구를 사용해 배포하는 방법
      • EKS의 공식 CLI인 eksctl 로 배포하는 방법 -> 현재 사용중인 방식
      • Terraform, Pulumi, Rancher 등으로 배포하는 방법
    • ECS를 마찬가지로 사용한다 (사용할 코드)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    
      kbi0127:~/environment $ eksctl create cluster -f eks-demo-cluster.yaml
      2023-04-16 07:59:53 [!]  SSM is now enabled by default; `ssh.enableSSM` is deprecated and will be removed in a future release
      2023-04-16 07:59:53 [ℹ]  eksctl version 0.137.0
      2023-04-16 07:59:53 [ℹ]  using region ap-northeast-2
      2023-04-16 07:59:53 [ℹ]  setting availability zones to [ap-northeast-2d ap-northeast-2b ap-northeast-2c]
      2023-04-16 07:59:53 [ℹ]  subnets for ap-northeast-2d - public:10.0.0.0/19 private:10.0.96.0/19
      2023-04-16 07:59:53 [ℹ]  subnets for ap-northeast-2b - public:10.0.32.0/19 private:10.0.128.0/19
      2023-04-16 07:59:53 [ℹ]  subnets for ap-northeast-2c - public:10.0.64.0/19 private:10.0.160.0/19
      2023-04-16 07:59:53 [ℹ]  nodegroup "node-group" will use "" [AmazonLinux2/1.23]
      2023-04-16 07:59:53 [ℹ]  using Kubernetes version 1.23
      2023-04-16 07:59:53 [ℹ]  creating EKS cluster "eks-demo" in "ap-northeast-2" region with managed nodes
      2023-04-16 07:59:53 [ℹ]  1 nodegroup (node-group) was included (based on the include/exclude rules)
      2023-04-16 07:59:53 [ℹ]  will create a CloudFormation stack for cluster itself and 0 nodegroup stack(s)
      2023-04-16 07:59:53 [ℹ]  will create a CloudFormation stack for cluster itself and 1 managed nodegroup stack(s)
      2023-04-16 07:59:53 [ℹ]  if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-2 --cluster=eks-demo'
      2023-04-16 07:59:53 [ℹ]  Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "eks-demo" in "ap-northeast-2"
      2023-04-16 07:59:53 [ℹ]  configuring CloudWatch logging for cluster "eks-demo" in "ap-northeast-2" (enabled types: api, audit, authenticator, controllerManager, scheduler & no types disabled)
      2023-04-16 07:59:53 [ℹ]  
      2 sequential tasks: { create cluster control plane "eks-demo", 
          2 sequential sub-tasks: { 
              4 sequential sub-tasks: { 
                  wait for control plane to become ready,
                  associate IAM OIDC provider,
                  2 sequential sub-tasks: { 
                      create IAM role for serviceaccount "kube-system/aws-node",
                      create serviceaccount "kube-system/aws-node",
                  },
                  restart daemonset "kube-system/aws-node",
              },
              create managed nodegroup "node-group",
          } 
      }
      2023-04-16 07:59:53 [ℹ]  building cluster stack "eksctl-eks-demo-cluster"
      2023-04-16 07:59:54 [ℹ]  deploying stack "eksctl-eks-demo-cluster"
      2023-04-16 08:00:24 [ℹ]  waiting for CloudFormation stack "eksctl-eks-demo-cluster"
    
  • Kubernetes AutoScaling

    • HPA(Horizontal Pod AutoScaler) : HPA는 CPU 사용량 또는 사용자 정의 메트릭을 관찰하여 파드 개수를 자동으로 스케일
    • Cluster Autoscaler : HPA는 CPU 사용량 또는 사용자 정의 메트릭을 관찰하여 파드 개수를 자동으로 스케일
  • EKS Workshop

ECS + CI/CD WorkShop

This post is licensed under CC BY 4.0 by the author.