관리 메뉴

피터의 개발이야기

[EBS] gp2 생성, gp3 업그레이드, 포퍼먼스 테스트 본문

AWS

[EBS] gp2 생성, gp3 업그레이드, 포퍼먼스 테스트

기록하는 백앤드개발자 2022. 9. 21. 00:33
반응형

ㅁ 개요

 ㅇ 이글은 [EBS] EKS 생성, MongoDB 구성, gp2에서 gp3 EBS 볼륨으로 마이그레이션 에서 이어지는 글이다.

 ㅇ CSI Driver 설치 없이 AWS Console에서 gp2에서 gp3로 타입변경을 한 상태에서 포퍼먼스 테스트를 진행하려 한다.

 ㅇ 테스트를 위한 gp2 생성과 테스트 pod는 AWS 문서를 참조하였다.

 

 

ㅁ Storageclasses gp2에 대한 이해

[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl get sc gp2
NAME            PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
gp2 (default)   kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer   false                  24h

 ㅇ 기본 StorageClass(SC) gp2는 PersistentVolumeClaim(PVC) 을 생성하는 데 사용된다.

 ㅇ gp2 StorageClass에 volumeBindingMode가 있는데 아직 사용자가 없기 때문에 WaitForFirstConsumer속성을 가지고 있다.

 

ㅁ 테스트용 EBS(Elastic Block Store) GP2 생성

# gp2 yaml 생성 
[ec2-user@ip-172-31-43-214 gp3Test]$ cat ebs-gp2-claim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ebs-gp2-claim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: gp2
  
# apply
[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl apply -f ebs-gp2-claim.yaml
persistentvolumeclaim/ebs-gp2-claim created

 

 

ㅁ GP2 생성 확인

[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl get pvc ebs-gp2-claim
NAME            STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
ebs-gp2-claim   Pending                                      gp2            7h53m

 ㅇ 아직 PVC를 사용하는 포드가 없기 때문에 PVC는 "Pending" 상태로 생성된다. 

 

 

ㅁ PVC를 사용하는 데모 POD 생성

# test Pod yaml
[ec2-user@ip-172-31-43-214 gp3Test]$ cat test-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: app-gp2-in-tree
spec:
  containers:
  - name: app
    image: centos
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"]
    volumeMounts:
    - name: persistent-storage
      mountPath: /data
  volumes:
  - name: persistent-storage
    persistentVolumeClaim:
      claimName: ebs-gp2-claim
      
# apply
[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl apply -f test-pod.yaml
pod/app-gp2-in-tree created

 

 

ㅁ Pod 생성확인 및 PVC 상태 확인

# POD 생성확인
[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl get pods
NAME              READY   STATUS    RESTARTS   AGE
app-gp2-in-tree   1/1     Running   0          81s

# PVC 상태확인
[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl get pvc ebs-gp2-claim
NAME            STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
ebs-gp2-claim   Bound    pvc-8d2bad4c-8835-4145-ba85-c1045a1921d8   1Gi        RWO            gp2            8h

 ㅇ 위 파드는 현재 PVC "ebs-gp2-claim"에 바인딩된 기본 PV pvc-8d2bad4c-8835-4145-ba85-c1045a1921d8을 동적으로 프로비저닝하고 있다.

 

 

ㅁ app-gp2-in-tree에 테스트 데이터 확인

[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl exec app-gp2-in-tree -- sh -c "cat /data/out.txt"
Tue Sep 20 13:58:39 UTC 2022
Tue Sep 20 13:58:44 UTC 2022
Tue Sep 20 13:58:49 UTC 2022

 

 

ㅁ Volum ID 확인

[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl get pv pvc-8d2bad4c-8835-4145-ba85-c1045a1921d8 -o jsonpath='{.spec}'| jq '.awsElasticBlockStore'
{
  "fsType": "ext4",
  "volumeID": "aws://ap-northeast-2b/vol-07c6b8244593542af"
}

 

 

ㅁ 볼륨 타입 gp3 타입으로 변경

$ aws ec2 modify-volume \
--volume-id vol-07c6b8244593542af \
--volume-type gp3

{
    "VolumeModification": {
        "TargetSize": 1,
        "TargetVolumeType": "gp3",
        "ModificationState": "modifying",
        "VolumeId": "vol-07c6b8244593542af",
        "TargetIops": 3000,
        "StartTime": "2022-09-20T14:35:35.000Z",
        "Progress": 0,
        "OriginalVolumeType": "gp2",
        "OriginalIops": 100,
        "OriginalSize": 1
    }
}

 

 

ㅁ gp3 타입변경 확인

[ec2-user@ip-172-31-43-214 gp3Test]$ aws ec2 describe-volumes --volume-ids vol-07c6b8244593542af
{
    "Volumes": [
        {
            "AvailabilityZone": "ap-northeast-2b",
            "Attachments": [
                {
                    "AttachTime": "2022-09-20T13:58:19.000Z",
                    "InstanceId": "i-06f9bbf0ce3ce99b6",
                    "VolumeId": "vol-07c6b8244593542af",
                    "State": "attached",
                    "DeleteOnTermination": false,
                    "Device": "/dev/xvdbi"
                }
            ],
            "Tags": [
                {
                    "Value": "kubernetes-dynamic-pvc-8d2bad4c-8835-4145-ba85-c1045a1921d8",
                    "Key": "Name"
                },
                {
                    "Value": "ebs-gp2-claim",
                    "Key": "kubernetes.io/created-for/pvc/name"
                },
                {
                    "Value": "pvc-8d2bad4c-8835-4145-ba85-c1045a1921d8",
                    "Key": "kubernetes.io/created-for/pv/name"
                },
                {
                    "Value": "owned",
                    "Key": "kubernetes.io/cluster/k8s-peterica"
                },
                {
                    "Value": "default",
                    "Key": "kubernetes.io/created-for/pvc/namespace"
                }
            ],
            "Encrypted": false,
            "VolumeType": "gp3",  <<< 변경된 것을 확인 할 수 있다.
            "VolumeId": "vol-07c6b8244593542af",
            "State": "in-use",
            "Iops": 3000,
            "SnapshotId": "",
            "CreateTime": "2022-09-20T13:58:13.445Z",
            "MultiAttachEnabled": false,
            "Size": 1
        }
    ]
}

 ㅇ VolumeType이 gp3으로 변경된 것을 확인 할 수 있다.

 ㅇ aws CLI 명령어 상세보기 

 

 

ㅁ AWS Console 확인

 ㅇ AWS Console에서도 gp3로 변경되어 있다.

 

 

ㅁ GP3 타입 EBS 볼륨 퍼포먼스 테스트를  위한 FIO 설치

# pod 내부로 접속
[ec2-user@ip-172-31-43-214 gp3Test]$ kubectl exec -it app-gp2-in-tree /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.

# fio install
[root@app-gp2-in-tree /]# yum install -y fio
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream                                                                                                                              46  B/s |  38  B     00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

 ㅇ 문제가 생겼다.

 ㅇ 이 문제는 CentOS 패키지 리포지토리의 주소가 잘못되어 발생하는 문제이지만, 최근들어 CentOS 7/8의 공식 패키지의 지원 종료로 인해 깨끗한 OS에서도 빈번하게 발생하는 문제라고 한다. 참조

 

 

# 문제 해결 시도, 무슨 의미인지는 잘 모르겠다.
[root@app-gp2-in-tree /]# sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
[root@app-gp2-in-tree /]# sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
[root@app-gp2-in-tree /]# yum install -y fio
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream                                                                                                                              16 MB/s | 8.4 MB     00:00
CentOS Linux 8 - BaseOS                                                                                                                                 19 MB/s | 4.6 MB     00:00
CentOS Linux 8 - Extras                                                                                                                                191 kB/s |  10 kB     00:00
Dependencies resolved.
  ~~ 설치 로그 생략 ~~
  Upgraded:
  crypto-policies-20210617-1.gitc776d3e.el8.noarch                          libibverbs-35.0-1.el8.x86_64                          rdma-core-35.0-1.el8.x86_64
Installed:
  boost-atomic-1.66.0-10.el8.x86_64           boost-chrono-1.66.0-10.el8.x86_64                         boost-date-time-1.66.0-10.el8.x86_64  boost-iostreams-1.66.0-10.el8.x86_64
  boost-program-options-1.66.0-10.el8.x86_64  boost-random-1.66.0-10.el8.x86_64                         boost-regex-1.66.0-10.el8.x86_64      boost-system-1.66.0-10.el8.x86_64
  boost-thread-1.66.0-10.el8.x86_64           crypto-policies-scripts-20210617-1.gitc776d3e.el8.noarch  daxctl-libs-71.1-2.el8.x86_64         fio-3.19-3.el8.x86_64
  libaio-0.3.112-1.el8.x86_64                 libicu-60.3-2.el8_1.x86_64                                libpmem-1.6.1-1.el8.x86_64            libpmemblk-1.6.1-1.el8.x86_64
  librados2-1:12.2.7-9.el8.x86_64             librbd1-1:12.2.7-9.el8.x86_64                             librdmacm-35.0-1.el8.x86_64           ndctl-libs-71.1-2.el8.x86_64
  nspr-4.32.0-1.el8_4.x86_64                  nss-3.67.0-7.el8_5.x86_64                                 nss-softokn-3.67.0-7.el8_5.x86_64     nss-softokn-freebl-3.67.0-7.el8_5.x86_64
  nss-sysinit-3.67.0-7.el8_5.x86_64           nss-util-3.67.0-7.el8_5.x86_64                            numactl-libs-2.0.12-13.el8.x86_64

Complete!

# 설치 확인
[root@app-gp2-in-tree /]# fio -h
fio-3.19
fio [options] [job options] <job file(s)>
  --debug=options	Enable debug logging. May be one/more of:
			process,file,io,mem,blktrace,verify,random,parse,
			diskutil,job,mutex,profile,time,net,rate,compress,
			steadystate,helperthread,zbd
  --parse-only		Parse options only, don't start any IO
  --merge-blktrace-only	Merge blktraces only, don't start any IO
  --output		Write output to file
  --bandwidth-log	Generate aggregate bandwidth logs
  --minimal		Minimal (terse) output
  --output-format=type	Output format (terse,json,json+,normal)
  --terse-version=type	Set terse version output format (default 3, or 2 or 4)
  --version		Print version info and exit
  --help		Print this page
  --cpuclock-test	Perform test/validation of CPU clock
  --crctest=[type]	Test speed of checksum functions
  --cmdhelp=cmd		Print command help, "all" for all of them
  --enghelp=engine	Print ioengine help, or list available ioengines
  --enghelp=engine,cmd	Print help for an ioengine cmd
  --showcmd		Turn a job file into command line options
  --eta=when		When ETA estimate should be printed
            		May be "always", "never" or "auto"
  --eta-newline=t	Force a new line for every 't' period passed
  --status-interval=t	Force full status dump every 't' period passed
  --readonly		Turn on safety read-only checks, preventing writes
  --section=name	Only run specified section in job file, multiple sections can be specified
  --alloc-size=kb	Set smalloc pool to this size in kb (def 16384)
  --warnings-fatal	Fio parser warnings are fatal
  --max-jobs=nr		Maximum number of threads/processes to support
  --server=args		Start a backend fio server
  --daemonize=pidfile	Background fio server, write pid to file
  --client=hostname	Talk to remote backend(s) fio server at hostname
  --remote-config=file	Tell fio server to load this local job file
  --idle-prof=option	Report cpu idleness on a system or percpu basis
			(option=system,percpu) or run unit work
			calibration only (option=calibrate)
  --inflate-log=log	Inflate and output compressed log
  --trigger-file=file	Execute trigger cmd when file exists
  --trigger-timeout=t	Execute trigger at this time
  --trigger=cmd		Set this command as local trigger
  --trigger-remote=cmd	Set this command as remote trigger
  --aux-path=path	Use this path for fio state generated files

Fio was written by Jens Axboe <axboe@kernel.dk>

 ㅇ 구글링을 통해 문제를 해결하고 fio설치를 성공하였다.

 

 

ㅁ fio 테스트 폴더 생성

[root@app-gp2-in-tree data]# mkdir fiotest
[root@app-gp2-in-tree data]# cd fiotest
[root@app-gp2-in-tree fiotest]# pwd
/data/fiotest

 ㅇ 신규로 생성된 EBS 볼륨은  /data에 마운트되어 있다.

 ㅇ /data에 fiotest 폴더를 생성하였다.

 

 

ㅁ fio 부하 테스트 파라메터 세팅

# fio 테스트 파일 저장경로 설정
[root@app-gp2-in-tree fiotest]# TEST_DIR=/data/fiotest

# IOPS 퍼포먼스 측정 설정 파라미터
[root@app-gp2-in-tree fiotest]# fio \
> --directory=$TEST_DIR \
> --ioengine=psync \
> --name fio_test_file \
> --direct=1 \
> --rw=randwrite \
> --bs=16k \       << I/O 블록 크기를 16k로 설정
> --size=100M \
> --numjobs=8 \    << 여러 동시 스트림(8개 이상)
> --time_based \
> --runtime=60 \   << 60초동안
> --group_reporting \
> --norandommap

 ㅇ 파라메터에 대한 것은 이곳을 참고하였다.

 

 옵션  설명
 direct  작업할 폴더 경로
 name  테스트 명
 rw  테스트 종류
 ( read / write / randread / randwrite )
 bs  테스트 블락 크기
 size  생성되는 총 파일 크기
 numjobs  생성되는 파일 수
 time_based  시간 기반 테스트
 runtime  테스트 진행 시간
 threads  테스트 시 병렬 작업 수
 direct  1 인 경우 Direct I/O, 0 인 경우 Buffered I/O 모드
 norandommap  이전에 수행한 I/O 의 위치를 고려하지 않음
 group_reporting  하나의 그룹으로 결과치 출력
 

 

ㅁ 테스트 결과

 ㅇ IOPS가 3048이 측정되었다. 볼륨에 대한 포퍼먼스는 입증된 것이다.

 ㅇ 기간을 60초로 제한적으로 하였지만 보다 정확한 측정은 시간을 증가하여 측정하는 것이 좋다.

 ㅇ 이번 글은 방법에 대한 체험을 위한 것이라 60초도 충분하다고 생각한다.

 

 

ㅁ 결론

 ㅇ 쿠버네티스 환경에서는 볼륨 타입이 gp2이지만 포퍼먼스 테스트 결과 gp3의 성능을 보여주고 있다.

 ㅇ gp2 1GB에 기본 IOPS 100이지만 테스트 결과 IOPS 3000가 넘었다. 

 

 

ㅁ 함께 보면 좋은 사이트

 

Migrating Amazon EKS clusters from gp2 to gp3 EBS volumes | Amazon Web Services

Kubernetes (sometimes referred to as K8s) is an open-source container orchestration engine and a fast-growing project hosted by the Cloud Native Computing Foundation (CNCF). K8s has a massive adoption on premises and in the cloud for running stateless and

aws.amazon.com

 

AWS CLI 출력 필터링 - AWS Command Line Interface

AWS CLI 출력 필터링 AWS Command Line Interface(AWS CLI)에는 개별적으로 또는 함께 사용하여 AWS CLI 출력을 필터링할 수 있는 서버 측 필터링과 클라이언트 측 필터링이 둘 다 있습니다. 서버 측 필터링이

docs.aws.amazon.com

 

영구 디스크 성능 벤치마킹  |  Compute Engine 문서  |  Google Cloud

의견 보내기 영구 디스크 성능 벤치마킹 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 영구 디스크 성능을 벤치마킹하려면 dd와 같은 다른 디스크 벤치마

cloud.google.com

반응형
Comments