Istio Service Mesh 를 클러스터에 배포하기
이 포스트에서는 쿠버네티스 환경에서 Istio Service Mesh 를 클러스터에 배포하는 간단한 방법을 안내합니다.
Istio Service Mesh란:
Istio Service Mesh는 마이크로서비스 아키텍처에서 발생하는 복잡한 서비스 간 통신 문제를 해결하기 위한 Open Source Service Mesh 솔루션입니다. Istio Service Mesh는 각 서비스에 프록시 “SideCar”를 추가하여 애플리케이션 인식 트래픽 관리, 관찰성, 보안 기능을 제공합니다. 이를 통해 개발자는 서비스 코드를 변경하지 않고도 서비스 간 통신을 쉽게 할 수 있습니다.
주요 기능:
- 트래픽 관리 – 로드 밸런싱, 라우팅, 장애 주입 등을 통해 서비스 간 트래픽을 제어할 수 있습니다.
- 관찰성 – 분산 추적, 메트릭 수집, 로깅 등을 통해 서비스 상태를 모니터링할 수 있습니다.
- 보안 – mTLS, 인증, 권한 부여 등의 기능으로 서비스 간 통신을 보호할 수 있습니다.
- 정책 적용 – 속도 제한, 할당량, 액세스 제어 등의 정책을 서비스에 적용할 수 있습니다.
목차
1. Istio 배포 전 준비
2. Istio Profile List
3. Istio 설치
4. Namespace에 Auto Sidecar Injection
1. Istio Service Mesh 배포 전 준비
Istio Service Mesh 를 배포하기 전 Istio의 CLI 도구인 istioctl을 설치합니다(이 포스트에서는 Istio-1.21.2):
$ curl -L https://istio.io/downloadIstio | sh -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 101 100 101 0 0 271 0 --:--:-- --:--:-- --:--:-- 271
100 4899 100 4899 0 0 5979 0 --:--:-- --:--:-- --:--:-- 5979
Downloading istio-1.21.2 from https://github.com/istio/istio/releases/download/1.21.2/istio-1.21.2-linux-amd64.tar.gz ...
Istio 1.21.2 Download Complete!
Istio has been successfully downloaded into the istio-1.21.2 folder on your system.
Next Steps:
See https://istio.io/latest/docs/setup/install/ to add Istio to your Kubernetes cluster.
To configure the istioctl client tool for your workstation,
add the /root/istio-1.21.2/bin directory to your environment path variable with:
export PATH="$PATH:/root/istio-1.21.2/bin"
Begin the Istio pre-installation check by running:
istioctl x precheck
Need more information? Visit https://istio.io/latest/docs/setup/install/
Istio 패키지 디렉토리로 이동합니다:
$ cd istio-1.21.2
istioctl 명령을 사용하기 위해 경로를 추가한 뒤 istioctl 명령어를 확인합니다.
$ export PATH=$PWD/bin:$PATH
$ istioctl version
no ready Istio pods in "istio-system"
1.21.2
2. Istio Service Mesh Profile List
Istio를 설치하기 전 profile list를 확인하여 알맞는 profile을 선택합니다:
$ istioctl profile list
Istio configuration profiles:
ambient
default
demo
empty
minimal
preview
remote
각 profile은 다음과 같습니다:
- ambient – 주변 메시를 시작하는 데 도움이 되도록 설계되었습니다.
- default – IstioOperator API의 기본 설정에 따라 구성 요소를 활성화합니다. 이 profile은 프로덕션 배포와 멀티 클러스터 메시의 기본 클러스터에 권장됩니다.
- demo – 적절한 리소스 요구사항으로 Istio 기능을 선보이도록 설계된 구성입니다. Bookinfo 애플리케이션 및 관련 작업을 실행하는 데 적합합니다.
- empty – 아무것도 배포하지 않습니다. 이는 사용자 정의 구성을 위한 기본 profile로 유용할 수 있습니다.
- minimal – default profile과 동일하지만 control plane 구성 요소만 설치됩니다. 이를 통해 별도의 profile을 사용하여 control plane 및 data plane요소(예: Gateway)를 구성할 수 있습니다.
- preview – preview profile에는 실험적인 기능이 포함되어 있습니다. 이는 Istio에 재공되는 새로운 기능을 탐색하기 위한 것입니다. 안정성, 보안 및 성능은 보장되지 않습니다. 사용에 따른 책임은 사용자 본인에게 있습니다.
- remote – 외부 control plane 또는 multicluster mesh의 기본 클러스터에 있는 control plane에서 관리되는 원격 클러스터를 구성하는 데 사용됩니다.
각 profile 별 구성 요소는 다음과 같습니다:
| ambient | default | demo | empty | minimal | preview | remote | |
| Core components | |||||||
| istio-egressgateway | ✅ | ||||||
| istio-ingressgateway | ✅ | ✅ | ✅ | ||||
| istiod | ✅ | ✅ | ✅ | ✅ | ✅ | ||
| CNI | ✅ | ||||||
| Ztunnel | ✅ |
Istio를 추가로 사용자 정의하기 위해 여러 애드온 구성요소를 설치할 수도 있습니다. 자세한 내용은 통합을 참조하세요.
3. Istio 설치
위의 profile list에서 설치할 profile을 지정했다면 다음과 같이 설치할 수 있습니다:
# istioctl install --set profile={profile 명} -y
$ istioctl install --set profile=minimal -y
✔ Istio core installed
✔ Istiod installed
✔ Installation complete Made this installation the default for injection and validation.
4. Namespace에 Auto Sidecar Injection
Istio를 사용하여 서비스 간 통신을 관리하려면, 각 서비스의 파트에 Istio Service Mesh 의 사이드카 프록시(Envoy)가 주입되어야 합니다. 이 과정을 자동화하려면 사이드카 주입을 활성화하고자 하는 namespace에 istio-injection=enabled label을 추가합니다. 여기서는 NGINX Ingress Controller의 namespace인 nginx-ingress에 주입합니다:
$ kubectl label namespace nginx-ingress istio-injection=enabled
namespace/nginx-ingress labeled
다음과 같이 nginx-ingress라는 namespace에 Label이 추가되었는지 확인합니다.
$ kubectl describe namespace nginx-ingress
Name: nginx-ingress
Labels: istio-injection=enabled
kubernetes.io/metadata.name=nginx-ingress
Annotations: <none>
Status: Active
No resource quota.
No LimitRange resource.
위처럼 Labels에 istio-injection=enabled가 추가되었다면 nginx-ingress라는 namespace로 배포되는 모든 파드에 사이드카가 주입되어 배포됩니다.
Istio Sidecar를 주입한 뒤, 파드를 생성해보면 다음과 같이 READY의 상태가 2/2가 되는 것을 확인할 수 있습니다.
$ kubectl get pods -n nginx-ingress
NAME READY STATUS RESTARTS AGE
nginx-ingress-8446cbf644-fmqsk 2/2 Running 2 (33s ago) 57s
Describe를 사용하여 파드의 내용을 확인합니다.
$ kubectl describe pods nginx-ingress-8446cbf644-fmqsk -n nginx-ingress
...
Conatiners:
...
istio-proxy:
Container ID: containerd://8da70f28afb0e386ad89202b66a2b977cb72d49b3dd092bbd708f64934272390
Image: docker.io/istio/proxyv2:1.21.2
Image ID: docker.io/istio/proxyv2@sha256:15f2457e7cf6a88d99f9de38ef714304699478d645b8aab9cdad906402938f54
Port: 15090/TCP
Host Port: 0/TCP
Args:
proxy
sidecar
--domain
$(POD_NAMESPACE).svc.cluster.local
--proxyLogLevel=warning
--proxyComponentLogLevel=misc:error
--log_output_level=default:info
State: Running
...
위와 같이 Istio Service Mesh 가 istio-proxy라는 컨테이너가 추가된 상태로 배포된 것을 확인할 수 있습니다.
NGINX Plus를 직접 사용해 보시려면 30일 무료 평가판을 신청하거나 NGINX STORE에 연락하여 논의하십시오.