1. Linux 노드에 대한 대화형 셸 연결
1) 하기 명령어로 접근하고자 하는 Node의 이름을 확인한다.
kubectl get nodes
2) 하기 명령어로 노드에서 컨테이너 이미지를 실행하여 연결한다. 해당 Pod는 노드에 대한 액세스를 제공한다.
kubectl debug node/aks-nodepool1-37663765-vmss000000 -it --image=mcr.microsoft.com/dotnet/runtime-deps:6.0
3) chroot /host 명령어를 입력하여 root 권한으로 Node에 접근한다.
4) exit 명령어로 대화형 셸 세션을 종료하는 명령을 입력한다.
5) 대화형 컨테이너 세션이 닫히면 kubectl delete pod <pod 이름> 명어를 통해 노드 접속에 사용된 Pod를 삭제한다.
kubectl delete pod node-debugger-aks-agentpool-36512578-vmss000004-m2r77
2. SSH로 클러스터 노드 접속
- AKS (Azure kubernetes Service)의 노드들은 Azure VMSS(Azure Virtual Machine Scale Sets)로 구성되어 있다.
- Azure VMSS: VM에서 실행되는 애플리케이션, 리소스의 자동 크기 조정 및 트래픽 부하 분산에 대한 관리 기능을 제공한다.
- Azure Portal에서 VMSS의 암호를 재 설정할 수 있지만 변경된 암호가 제대로 반영 되지 않는다.
- ssh private key로 접근 해야한다.
- ssh-keygen -t rsa 2048 명령어를 입력하여 public key와 private key를 생성한다.
- vmss의 [지원 및 문제 해결] 블레이드 > [암호 다시 설정] 탭에 사용자 이름 및 생성한 key 중 public key를 SSH 공개키 란에 복사 붙여 넣기 후 [저장]한다.
- node에 접속하여 cat /home/azureuser/.ssh/authorized_keys 명령어를 입력하여 public key를 확인한다. (결과 값이 portal에서 등록한 public key와 일치하지 않는 것 확인 가능하다.)
- node의 authorized_keys를 생성한 public key의 내용으로 변경한다.
- public key 변경 후 ssh -i /home/azureuser/.ssh/aks-test azureuser@10.10.1.4 입력 시 정상 접속되는 것을 확인할 수 있다.
'Container > Kubernetes' 카테고리의 다른 글
[Kubernetes] MSA 및 Service Mash 소개 (0) | 2024.04.03 |
---|---|
[Kubernetes] Prometheus & Grafana를 통한 Kubernetes 모니터링 설정 (0) | 2024.03.18 |
[AKS] Azure Key Vault Provider for Secrets Store CSI Driver 테스트 (0) | 2024.01.22 |
[Kubernetes] Network Policy 개념 및 적용 방법 (0) | 2024.01.09 |
[Kubernetes] Docker 및 Container 개념 정리 (1) | 2024.01.04 |