본문 바로가기
클라우드/Azure

[Kubernetes] AKS Custom Worker Node Image

by worldcenter 2025. 1. 23.

 

AKS는 매주 새 노드 이미지를 릴리스 합니다. 모든 새 클러스터, 새 노드 풀 또는 업그레이드 클러스터는 항상 최신 이미지를 수신하므로 일관성을 유지하기 어렵고 반복 가능한 환경을 가질 수 있습니다.

Worker Node는 장애가 발생하여 재생성 되는 경우 Microsoft에서 제공하는 관리되는 이미지로 생성이 됩니다.

그에 따라, 고객사에서 보안 솔루션을 Worker Node에 설치하는 것이 필요한 경우나 특정 솔루션이 설치되어 있어야 하는 경우 가상머신이 재생성될 때마다 솔루션을 설치하기에는 많은 공수가 발생합니다.

이를 해결하기 위해 Azure에서는 AKS 노드풀 스냅샷 기능을 제공합니다. 관련 내용은 다음 링크에서 확인 가능합니다.

 

 

사전 환경 설정

  • Azure Kubernetes Service 1.27.3
  • Worker Node : Ubuntu 22.04LTS

 

 

제한 사항

  • 스냅샷에서 만든 모든 노드 풀 또는 클러스터는 스냅샷과 동일한 가상 머신 패밀리의 VM을 사용해야 합니다.
    노드 이미지가 구조적으로 다르기 때문에 D 시리즈 노드 풀에서 캡처된 스냅샷을 기반으로 새 N 시리즈 노드 풀을 만들 수 없습니다.
  • 스냅샷은 원본 노드 풀과 동일한 지역에서 생성되어야 합니다. 

 

 

노드풀 스냅샷 만들기

1. 기존 Node Pool Resource ID를 확인합니다.

NODEPOOL_ID=$(az aks nodepool show --name nodepool1 --cluster-name myAKSCluster --resource-group myResourceGroup --query id -o tsv)

 

2. Worker Node에 테스트 용도로 net-tools를 설치하기 위해서 Debug 모드로 Worker Node에 접속합니다. Worker Node Debug 접속 방법은 다음 링크를 참조하세요

# Debug Pod 생성 후 접속
kubectl debug <NodeName> -it --image=mcr.microsoft.com/dotnet/runtime-deps:6.0

# Pod안에서
chroot /host

# Worker Node 안에서 net-tools 설치
apt update
apt install net-tools

 

3. 노드풀에서 스냅샷을 생성합니다.

az aks nodepool snapshot create --name MySnapshot --resource-group MyResourceGroup --nodepool-id $NODEPOOL_ID --location eastus

 

 

스냅샷에서 NodePool 만들기

1. 이전에 만든 스냅샷 리소스 ID를 불러옵니다.

SNAPSHOT_ID=$(az aks nodepool snapshot show --name MySnapshot --resource-group myResourceGroup --query id -o tsv)

 

2. 해당 스냅샷을 기반으로 새로운 노드풀을 추가합니다.

az aks nodepool add \
--resource-group <ResourceGroupName> \
--cluster-name <KubernetesClusterName> \
--name <NodepoolName> \
--node-vm-size Standard_B2ms \
--node-count 3 \
--max-pods 30 \
--zones 2 \
--kubernetes-version 1.27.3 \
--mode User \
--os-sku Ubuntu \
--vnet-subnet-id /subscriptions/fd581787-... \
--pod-subnet-id /subscriptions/fd581787-... \
--snapshot-id $SNAPSHOT_ID

 

3. 노드풀이 정상적으로 추가 생성되면 다음과 확인이 됩니다.

 

 

결론

스냅샷을 통해서 배포한 노드풀에 들어가서 확인해보면 스냅샷 원본 노드풀에서 설치했던 net-tools가 보이지 않습니다.

AKS NodePool Snapshot 기능은 고객이 커스텀하게 설치한 프로그램은 캡처하지 못합니다.

 

[원문]

The AKS Node Pool Snapshot feature allows you to take a configuration snapshot of your node pool, including the node image version, Kubernetes version, OS type, and OS SKU. However, it does not capture any custom installations or modifications made on the worker nodes. When you create a new node pool from a snapshot, it will have the same base configuration as the original node pool, but any custom installations or modifications will not be present. If you need to install a security solution on the worker nodes, you will need to perform the installation after creating the new node pool from the snapshot.