카테고리 없음

[ITExam-CKA] 4. Kubernetes ETCD - etcd 백업 실습

토끼C 2025. 2. 17. 19:10
반응형

 

https://www.itexams.com/exam/CKA

 

CKA Exam - Free Questions and Answers - ITExams.com

 

www.itexams.com

ITExams에서 CKA 자격증 취득을 위한 무료 문제를 제공한다.

 

오늘은 4번 문항 etcd 백업 문제에 대한 풀이 방법을 공유하고자 한다.

 

 

가장 먼저 아래처럼 exit 하라는 내용을 볼 수 있다.

 


SIMULATION -

No configuration context change required for this task. Ensure, however, that you have returned to the base node before starting to work on this task:

[student@mk8s-master-0] $ | exit

 

위의 내용은 현재 원격서버에 접속되어 있다면 exit 명령으로 로그아웃 하라는 내용이다.

예시처럼 exit 명령어를 사용하는 곳이 mk8s-master-0이라면 현재 내가 mk8s-master-0이라는 노드에 접속한 상태이기 때문에 이를 exit 명령어로 빠져나가야 한다.

 

아래부터는 문제 내용이다.

 


[문제]

 

Task -
First, create a snapshot of the existing etcd instance running at https://127.0.0.1:2379, saving the snapshot to /var/lib/backup/etcd-snapshot.db.

The following TLS certificates/key are supplied foe connecting to the server with etcdctl:- CA certificate: /opt/KUIN00601/ca.crt- Client certificate: /otp/KUIN00601/etcd-client.crt- Client key: /opt/KUIN00601/etcd-client.key

Creating a snapshot of the given instance is expected to complete in seconds.If the operation seems to hang, something's likely wrong with your command. Use CTRL+C to cancel the operation and try again.

 

 


[해설]

https://127.0.0.1:2379에서 실행 중인 기존 etcd 인스턴스의 스냅샷을 생성하고 해당 스냅샷을 /var/lib/backup/etcd-snapshot.db에 저장한다.

etcdctl을 사용하여 서버에 연결하는 경우 다음 TLS 인증서/키가 제공된다.
- CA 인증서: /opt/KUIN00601/ca.crt
- 클라이언트 인증서: /opt/KUIN00601/etcd-client.crt
- 클라이언트 키: /opt/KUIN00601/etcd-client.key

특정 인스턴스의 스냅샷 생성은 몇 초 안에 완료될 것이다.
작업이 중단된 것처럼 보이면 명령에 문제가 있을 수 있다. Ctrl+C를 사용하여 작업을 취소하고 다시 시도해라.

 


[작업 목록]

1. 명령어 검색
2. etcd  스냅샷 생성 및 저장
- 문제 내용을 보고, 어떤 작업을 수행해야 하는지 작업 목록을 정리했다.

 


 

1. 명령어 검색

[https://kubernetes.io/docs/]

- 문제 내용 중 주요 단어를 유추해서 검색한다.

- 나의 경우 etcd snapshot으로 검색했다.

 

 

[검색 내용]

- Discuss Kubernetes > 의 경우 커뮤니티이기 때문에 Kubernetes > 로 시작하는 페이지를 찾아서 들어가준다.

- 제목만 봤을 때는 마땅한게 맨 위의 글 말고는 없어서 맨 위의 글을 선택했다.

 

 

[Ctrl + f]

https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/#snapshot-using-etcdctl-options

 

Operating etcd clusters for Kubernetes

etcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data. If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for the data. You can find in-depth information a

kubernetes.io

- Ctrl+f 로 검색 눌러서 내가 사용해야 하는 조건 중 인증서인 cert를 단어로 하여 검색했다.

 

 

 

2. etcd  스냅샷 생성 및 저장

스냅샹 생성 및 저장 명령어이다.

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=/opt/KUIN00601/ca.crt --cert=/opt/KUIN00601/etcd-client.crt --key=/opt/KUIN00601/etcd-client.key \
  snapshot save /var/lib/backup/etcd-snapshot.db

- 위에서 검색한 예제 명령어를 참고해서 작성한다.

 

아래는 동일한 페이지에 있는 status 명령어이다.

ETCDCTL_API=3 etcdctl --write-out=table snapshot status /var/lib/backup/etcd-snapshot.db

https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/#built-in-snapshot

- 추가적으로 명령어로 스냅샷이 정상적으로 생성되었는지 확인할 수 있다.

 

itexams의 정답을 보면 restore명령어도 나와있는데, 실제 문제에서는 복구관련 내용은 없기에 수행하지 않았다.

 

 

여기까지가 문제 풀이다.


 

요약하면 이렇다.

 

1. 명령어 검색

https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/#snapshot-using-etcdctl-options

 

Operating etcd clusters for Kubernetes

etcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data. If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for the data. You can find in-depth information a

kubernetes.io

 

 

2. etcd  스냅샷 생성 및 저장

 

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=/opt/KUIN00601/ca.crt --cert=/opt/KUIN00601/etcd-client.crt --key=/opt/KUIN00601/etcd-client.key \
  snapshot save /var/lib/backup/etcd-snapshot.db

- etcd 스냅샷 생성 및 저장

ETCDCTL_API=3 etcdctl --write-out=table snapshot status /var/lib/backup/etcd-snapshot.db

- 생성한 스냅샷 결과물을 테이블로 출력

 

 

 

끝~

반응형