CloudNetaStudy - Kubernets Networtk 3기 실습 스터디 게시글입니다. |
1. Istio 소개
[ 서비스 매시(Service Mesh) ☆ ]
- 등장 배경 : 마이크로서비스 아키텍처 환경의 시스템 전체 모니터링의 어려움, 운영 시 시스템 장애나 문제 발생할 때 원인과 병목 구간 찾기 어려움
- 내부망 진입점에 역할을 하는 GW(예. API Gateway) 경우 모든 동작 처리에 무거워지거나, 내부망 내부 통신 제어는 어려움
- 개념 : 마이크로서비스(파드) 간에 매시 형태의 통신이나 그 경로를 제어 - 예) 이스티오(Istio), 링커드(Linkerd) - 링크
- 기본 동작 : 파드 간 통신 경로에 프록시를 놓고 트래픽 모니터링이나 트래픽 컨트롤 → 기존 애플리케이션 코드에 수정 없이 구성 가능!
- Proxy 는 중앙에서 설정 관리가 잘되는 툴을 선택. 즉, 원격에서 동적인 설정 관리가 유연해야함 → 풍부한 API 지원이 필요 ⇒ Envoy
- '구글 IBM 리프트(Lyft)'가 중심이 되어 개발하고 있는 오픈 소스 소프트웨어이며, C++ 로 구현된 고성능 Proxy 인 엔보이(Envoy)
- 네트워크의 투명성을 목표, 다양한 필터체인 지원(L3/L4, HTTP L7), 동적 configuration API 제공, api 기반 hot reload 제공
- 중앙에서 어떤 동작/설정을 관리해야 될까? 라우팅, 보안 통신을 위한 mTLS 관련, 동기화 상태 정보 등
- Proxy 는 중앙에서 설정 관리가 잘되는 툴을 선택. 즉, 원격에서 동적인 설정 관리가 유연해야함 → 풍부한 API 지원이 필요 ⇒ Envoy
- 트래픽 모니터링 : 요청의 '에러율, 레이턴시, 커넥션 개수, 요청 개수' 등 메트릭 모니터링, 특정 서비스간 혹은 특정 요청 경로로 필터링 → 원인 파악 용이!
- 트래픽 컨트롤 : 트래픽 시프팅(Traffic shifting), 서킷 브레이커(Circuit Breaker), 폴트 인젝션(Fault Injection), 속도 제한(Rate Limit)
- 트래픽 시프팅(Traffic shifting) : 예시) 99% 기존앱 + 1% 신규앱 , 특정 단말/사용자는 신규앱에 전달하여 단계적으로 적용하는 카니리 배포 가능
- 서킷 브레이커(Circuit Breaker) : 목적지 마이크로서비스에 문제가 있을 시 접속을 차단하고 출발지 마이크로서비스에 요청 에러를 반환 (연쇄 장애, 시스템 전제 장애 예방)
- 폴트 인젝션(Fault Injection) : 의도적으로 요청을 지연 혹은 실패를 구현
- 속도 제한(Rate Limit) : 요청 개수를 제한
[ 이스티오 소개 ☆ ]
- 파일럿(Pilot): 모든 Envoy 사이드카에서 프록시 라우팅 규칙을 관리하며, 서비스 디스커버리와 로드 밸런싱 설정을 제공합니다.
- 갤리(Galley): Istio와 쿠버네티스(TLS 연결 및 파일럿에 필요한 설정)를 연결해 주는 역할을 합니다. 서비스 메시 구성 데이터를 검증하고 변환합니다.
- 시타델(Citadel): 보안 기능을 담당하며, TLS 인증서 발급 및 관리를 통해 서비스 간 통신의 암호화를 수행합니다.
- Istio 구성요소와 envoy : 컨트롤 플레인(istiod) , 데이터 플레인(istio-proxy > envoy)
- istiod : Pilot(데이터 플레인과 통신하면서 라우팅 규칙을 동기화, ADS), Gally(Istio 와 K8S 연동, Endpoint 갱신 등), Citadel(연결 암호화, 인증서 관리 등)
출처 : https://istio.io/latest/docs/concepts/security/ - Istio proxy : Golang 으로 작성되었고 envoy 래핑한 Proxy, istiod와 통신하고 서비스 트래픽을 통제, 옵저버빌리티를 위한 메트릭 제공
- istiod : Pilot(데이터 플레인과 통신하면서 라우팅 규칙을 동기화, ADS), Gally(Istio 와 K8S 연동, Endpoint 갱신 등), Citadel(연결 암호화, 인증서 관리 등)
1. 이스티오는 각 파드 안에 사이드카로 엔보이 프록시가 들어가 있는 형태
2. 모든 마이크로서비스간 통신은 엔보이를 통과하여, 메트릭을 수집하거나 트래픽 컨트롤을 할 수 있음.
3. 트래픽 컨트롤을 하기위해 엔보이 프록시에 전송 룰을 설정 → 컨트롤 플레인의 이스티오가 정의된 정보를 기반으로 엔보이 설정을 하게 함.
4. 마이크로서비스 간의 통신을 mutual TLS 인증(mTLS)으로 서로 TLS 인증으로 암호화 할 수 있음.
5. 각 애플리케이션은 파드 내의 엔보이 프록시에 접속하기 위해 localhost 에 TCP 접속을 함
[ 서비스 매시가 필요한가 관련 좋은 글 공유 (2023.01) ]
더보기
실무자를 위한 서비스 메시 - 지금 서비스 메시가 의미 있는 이유 - Link , 실무자를 위한 서비스 메시 - 이스티오가 해답인가 - Link
- 서비스 메시 프록시는 가볍지 않다
- 프록시 자원은 인프라과 관련하여 리소스를 소비하고 및 네트워크 지연을 유발합니다. 메모리와 CPU를 소비하는 프록시를 사용하는 서비스 개수가 늘어남에 따라서 리소스 사용량이 증가하는 사례를 경험했습니다. 또한 서비스 간에 위치한 두 개의 프록시 자원은 네트워크 지연을 발생시킵니다.
- 일반 컨테이너 통신에서는 소스 컨테이너와 대상 컨테이너 사이에 커넥션 풀이 1개만 있지만 서비스 메시에서는 3개의 커넥션 풀이 있습니다.
출처 : https://karlstoney.com/istio-503s-ucs-and-tcp-fun-times/ - 소스 컨테이너 → 소스 사이드카 프록시
- 소스 사이드카 프록시 → 타켓 사이드카 프록시
- 타켓 사이드카 프록시 → 타켓 컨테이너
- 커넥션 풀이 늘어남으로 인해, 트러블 슈팅 구간(point of failure)도 확장됩니다. 서비스 메시를 운영하는 플랫폼 운영자는 이러한 비용을 직접적으로 감수해야 하고, 비즈니스 개발자 및 최종 사용자(End User)에게도 간접적으로 영향을 미칩니다.
2. Envoy
[ Istio 구성요소와 envoy ]
: 컨트롤 플레인(istiod) - ADS 를 이용한 Configuration 동기화 - 데이터 플레인(istio-proxy → envoy)
- Cluster : envoy 가 트래픽을 포워드할 수 있는 논리적인 서비스 (엔드포인트 세트), 실제 요청이 처리되는 IP 또는 엔드포인트의 묶음을 의미.
- Endpoint : IP 주소, 네트워크 노드로 클러스터로 그룹핑됨, 실제 접근이 가능한 엔드포인트를 의미. 엔드포인트가 모여서 하나의 Cluster 가 된다.
- Listener : 무엇을 받을지 그리고 어떻게 처리할지 IP/Port 를 바인딩하고, 요청 처리 측면에서 다운스트림을 조정하는 역할.
- Route : Listener 로 들어온 요청을 어디로 라우팅할 것인지를 정의. 라우팅 대상은 일반적으로 Cluster 라는 것에 대해 이뤄지게 된다.
- Filter : Listener 로부터 서비스에 트래픽을 전달하기까지 요청 처리 파이프라인
- UpStream : envoy 요청을 포워딩해서 연결하는 백엔드 네트워크 노드 - 사이드카일때 application app, 아닐때 원격 백엔드
- DownStream : An entity connecting to envoy, In non-sidecar models this is a remote client
Envoy는 구성을 동적으로 관리하기 위한 강력한 API를 제공이 중요하다.
- Service Mesh 솔루션이나, Gateway API 구현체들을 Enovy를 내부적으로 사용하고 있으며, Envoy가 제공하는 동적 구성을 위한 API (xDS Sync API)를 이용하여 다양한 네트워크 정책을 구성하게 됩니다.
- Envoy의 xDS Sync API는 아래와 같은 레이어에서 동작하게 됩니다.
- LDS - Listener Discovery Service
- RDS - Route Discovery Service
- CDS - Cluseter Discovery Service
- EDS - Endpoint Discovery Service
출처 : https://blog.naver.com/yu3papa/223614975957
- testpc 에 Envoy 설치 - 링크
# 설치 # echo "deb [signed-by=/etc/apt/keyrings/envoy-keyring.gpg] https://apt.envoyproxy.io focal main" | sudo tee /etc/apt/sources.list.d/envoy.list wget -O- https://apt.envoyproxy.io/signing.key | sudo gpg --dearmor -o /etc/apt/keyrings/envoy-keyring.gpg echo "deb [signed-by=/etc/apt/keyrings/envoy-keyring.gpg] https://apt.envoyproxy.io jammy main" | sudo tee /etc/apt/sources.list.d/envoy.list sudo apt-get update && sudo apt-get install envoy -y # 확인 envoy --version # 도움말 envoy --help
- Envoy proxy 실습 - Link
출처 : https://kschoi728.tistory.com/268 - envoy-demo.yaml
# (터미널1) 데모 config 적용하여 실행 curl -O https://www.envoyproxy.io/docs/envoy/latest/_downloads/92dcb9714fb6bc288d042029b34c0de4/envoy-demo.yaml envoy -c envoy-demo.yaml # (터미널2) 정보 확인 ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 4096 0.0.0.0:10000 0.0.0.0:* users:(("envoy",pid=8007,fd=18),("envoy",pid=8007,fd=16)) # 접속 테스트 curl -s http://127.0.0.1:10000 | grep -o "<title>.*</title>" # 외부 접속 정보 출력 echo -e "http://$(curl -s ipinfo.io/ip):10000" http://54.180.243.135:10000 -------------------- # 자신의 PC 웹브라우저에서 외부 접속 정보 접속 확인! # k3s-s 에서 접속 테스트 curl -s http://192.168.10.200:10000 | grep -o "<title>.*</title>" -------------------- # 연결 정보 확인 ss -tnp # (터미널1) envoy 실행 취소(CTRL+C) 후 (관리자페이지) 설정 덮어쓰기 - 링크 cat <<EOT> envoy-override.yaml admin: address: socket_address: address: 0.0.0.0 port_value: 9902 EOT envoy -c envoy-demo.yaml --config-yaml "$(cat envoy-override.yaml)" # envoy 관리페이지 외부 접속 정보 출력 echo -e "http://$(curl -s ipinfo.io/ip):9902" http://54.180.243.135:9902 -------------------- # 자신의 PC 웹브라우저에서 관리 페이지 외부 접속 정보 접속 확인!
- url 접속
- envoy proxy가 urlRewrite : envoy proxy가 L7 대리자 역할
http://52.79.212.26:10000 -> http://52.79.212.26:10000/training로 url은 유지되면서 뒷단만 변경되는 것 확인
- envoy 관리 서비스 포트로 접속 (clusters 클릭 확인, logging , listeners, stats 클릭 확인)
- envoy를 통해 mutual TLS 통신
3. Istio 설치 (Sidecar mode)
- Istio Docs - Docs
- Istio Sidecar mode 설치 : v1.23.2 - 버전 설치 , without GwApi - Docs
- https://istio.io/latest/docs/setup/install/operator/
The Istio operator is deprecated. Operator-based Installations of Istio will continue to run indefinitely,
but cannot be upgraded past 1.23.x. Please see the announcement to learn how to upgrade to a supported installation method.https://istio.io/latest/blog/2024/in-cluster-operator-deprecation-announcement/
1.23 이후부터는 업그레이드 지원x -> helm 으로 지원하기 때문에 이후에는 helm 으로 배포 해야함.출처 : https://istio.io/latest/docs/setup/additional-setup/config-profiles/ - 새로운 sail operator 설치 방법 소개 : https://istio.io/latest/blog/2024/introducing-sail-operator/
# k3s-s # istioctl 설치 export ISTIOV=1.23.2 echo "export ISTIOV=1.23.2" >> /etc/profile curl -s -L https://istio.io/downloadIstio | ISTIO_VERSION=$ISTIOV TARGET_ARCH=x86_64 sh - tree istio-$ISTIOV -L 2 # sample yaml 포함 cp istio-$ISTIOV/bin/istioctl /usr/local/bin/istioctl istioctl version --remote=false # (demo 프로파일) 컨트롤 플레인 배포 - 링크 Customizing # The istioctl command supports the full IstioOperator API via command-line options for individual settings or for passing a yaml file containing an IstioOperator custom resource (CR). istioctl profile list istioctl profile dump default istioctl profile dump --config-path components.ingressGateways istioctl profile dump --config-path values.gateways.istio-ingressgateway istioctl profile dump demo istioctl profile dump demo > demo-profile.yaml vi demo-profile.yaml # 복잡성을 줄이게 실습 시나리오 환경 맞춤 -------------------- egressGateways: - enabled: false -------------------- istioctl install -f demo-profile.yaml -y ✔ Istio core installed ⛵️ ✔ Istiod installed 🧠 ✔ Ingress gateways installed 🛬 ✔ Installation complete # 설치 확인 : istiod, istio-ingressgateway kubectl get all,svc,ep,sa,cm,secret,pdb -n istio-system kubectl get crd | grep istio.io | sort # istio-ingressgateway 의 envoy 버전 확인 kubectl exec -it deploy/istio-ingressgateway -n istio-system -c istio-proxy -- envoy --version envoy version: 6c72b2179f5a58988b920a55b0be8346de3f7b35/1.31.2-dev/Clean/RELEASE/BoringSSL # istio-ingressgateway 서비스 NodePort로 변경 kubectl patch svc -n istio-system istio-ingressgateway -p '{"spec":{"type":"NodePort"}}' # istio-ingressgateway 서비스 확인 kubectl get svc,ep -n istio-system istio-ingressgateway ## istio-ingressgateway 서비스 포트 정보 확인 kubectl get svc -n istio-system istio-ingressgateway -o jsonpath={.spec.ports[*]} | jq ## istio-ingressgateway 디플로이먼트 파드의 포트 정보 확인 kubectl get deploy/istio-ingressgateway -n istio-system -o jsonpath={.spec.template.spec.containers[0].ports[*]} | jq kubectl get deploy/istio-ingressgateway -n istio-system -o jsonpath={.spec.template.spec.containers[0].readinessProbe} | jq # istiod(컨트롤플레인) 디플로이먼트 정보 확인 kubectl exec -it deployment.apps/istiod -n istio-system -- ss -tnlp kubectl exec -it deployment.apps/istiod -n istio-system -- ss -tnp kubectl exec -it deployment.apps/istiod -n istio-system -- ps -ef UID PID PPID C STIME TTY TIME CMD istio-p+ 1 0 0 05:27 ? 00:00:07 /usr/local/bin/pilot-discovery discovery --monitoringAddr=:15014 --log_output_l # istio-ingressgateway 디플로이먼트 정보 확인 kubectl exec -it deployment.apps/istio-ingressgateway -n istio-system -- ss -tnlp kubectl exec -it deployment.apps/istio-ingressgateway -n istio-system -- ss -tnp kubectl exec -it deployment.apps/istio-ingressgateway -n istio-system -- ps -ef istio-p+ 1 0 0 05:27 ? 00:00:01 /usr/local/bin/pilot-agent proxy router --domain istio-system.svc.cluster.local istio-p+ 15 1 0 05:27 ? 00:00:11 /usr/local/bin/envoy -c etc/istio/proxy/envoy-rev.json --drain-time-s 45 --drai kubectl exec -it deployment.apps/istio-ingressgateway -n istio-system -- cat /etc/istio/proxy/envoy-rev.json kubectl exec -it deployment.apps/istio-ingressgateway -n istio-system -- ss -xnlp kubectl exec -it deployment.apps/istio-ingressgateway -n istio-system -- ss -xnp
egressGateway : false 로 수정 - Auto Injection with namespace label : 해당 네임스페이스에 생성되는 모든 파드들은 istio 사이드카가 자동으로 injection 됨
# mutating Webhook admisstion controller 사용 kubectl label namespace default istio-injection=enabled kubectl get ns -L istio-injection NAME STATUS AGE ISTIO-INJECTION default Active 58m enabled ...
- https://istio.io/latest/docs/setup/install/operator/
- Istio 접속 테스트를 위한 변수 지정★
mypc) ## istio-ingressgateway 파드가 배치된 노드의 유동 공인 IP 확인 aws ec2 describe-instances --query "Reservations[*].Instances[*].{PublicIPAdd:PublicIpAddress,InstanceName:Tags[?Key=='Name']|[0].Value,Status:State.Name}" --filters Name=instance-state-name,Values=running --output text k3s-s 3.38.151.222 running k3s-w1 15.165.75.117 running k3s-w2 3.39.223.99 running testpc 54.180.243.135 running k3s-s) # istio ingress gw NodePort(HTTP 접속용) 변수 지정 : 아래 ports[0] 은 어떤 용도의 포트일까요? export IGWHTTP=$(kubectl get service -n istio-system istio-ingressgateway -o jsonpath='{.spec.ports[1].nodePort}') echo $IGWHTTP IGWHTTP=<각자 자신의 NodePort> # /etc/hosts 파일 수정 MYDOMAIN=<각자 자신의 www 도메인> # 단, 사용하고 있지 않는 공인 도메인을 사용 할 것 MYDOMAIN=www.gasida.dev echo "<istio-ingressgateway 파드가 있는 워커 노드> $MYDOMAIN" >> /etc/hosts MYDOMAIN=<각자 자신의 www 도메인> export MYDOMAIN=www.gasida.dev echo -e "192.168.10.10 $MYDOMAIN" >> /etc/hosts echo -e "export MYDOMAIN=$MYDOMAIN" >> /etc/profile # istio ingress gw 접속 테스트 : 아직은 설정이 없어서 접속 실패가 된다 curl -v -s $MYDOMAIN:$IGWHTTP
- testpc
# 아래 변수는 각자 자신의 값을 직접 입력 할 것 IGWHTTP=<각자 출력된 NodePort> IGWHTTP=32759 export MYDOMAIN=www.gasida.dev echo -e "192.168.10.10 $MYDOMAIN" >> /etc/hosts echo -e "export MYDOMAIN=$MYDOMAIN" >> /etc/profile # istio ingress gw 접속 테스트 : 아직은 설정이 없어서 접속 실패가 된다 curl -v -s $MYDOMAIN:$IGWHTTP
- 자신의 PC
# 아래 변수는 각자 자신의 값을 직접 입력 할 것 : ISTIONODEIP는 3개의 노드 중 아무거나 입력 IGWHTTP=<각자 출력된 NodePort> IGWHTTP=32759 ISTIONODEIP=<k3s-s 의 유동 공인 IP> ISTIONODEIP=3.38.208.153 MYDOMAIN=www.gasida.dev echo "$ISTIONODEIP $MYDOMAIN" | sudo tee -a /etc/hosts # istio ingress gw 접속 테스트 : 아직은 설정이 없어서 접속 실패가 된다 curl -v -s $MYDOMAIN:$IGWHTTP
4. Istio 통한 외부 노출
- 로그 모니터링
# 로그 모니터링 kubectl get pod -n istio-system -l app=istiod kubetail -n istio-system -l app=istiod -f kubectl get pod -n istio-system -l app=istio-ingressgateway kubetail -n istio-system -l app=istio-ingressgateway -f
cat <<EOF | kubectl create -f - apiVersion: v1 kind: ServiceAccount metadata: name: kans-nginx --- apiVersion: apps/v1 kind: Deployment metadata: name: deploy-websrv spec: replicas: 1 selector: matchLabels: app: deploy-websrv template: metadata: labels: app: deploy-websrv spec: serviceAccountName: kans-nginx terminationGracePeriodSeconds: 0 containers: - name: deploy-websrv image: nginx:alpine ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: svc-clusterip spec: ports: - name: svc-webport port: 80 targetPort: 80 selector: app: deploy-websrv type: ClusterIP EOF
# 사이드카 컨테이너 배포 확인 kubectl get pod,svc,ep,sa -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES deploy-websrv-7d7cf8586c-rhhv8 2/2 Running 0 29s 172.16.2.6 k3s-w2 <none> <none> ... kc describe pod
- Istio Gateway/VirtualService 설정 - Host 기반 트래픽 라우팅 설정 - Gateway
- 클라이언트 PC → (Service:NodePort) Istio ingressgateway 파드 → (Gateway, VirtualService, Service 는 Bypass) → Endpoint(파드 : 사이드카 - Application 컨테이너)
- Gateway : 지정한 인그레스 게이트웨이로부터 트래픽이 인입, 프로토콜 및 포트, HOSTS, Proxy 등 설정 가능
- VirtualService : 인입 처리할 hosts 설정, L7 PATH 별 라우팅, 목적지에 대한 정책 설정 가능 (envoy route config)
- (참고) Introducing Istio v1 APIs - Blog
- [Istio Gateway]
cat <<EOF | kubectl create -f - apiVersion: networking.istio.io/v1 kind: Gateway metadata: name: test-gateway spec: selector: istio: ingressgateway servers: - port: number: 80 name: http protocol: HTTP hosts: - "*" --- apiVersion: networking.istio.io/v1 kind: VirtualService metadata: name: nginx-service spec: hosts: - "$MYDOMAIN" gateways: - test-gateway http: - route: - destination: host: svc-clusterip port: number: 80 EOF
# Istio Gateway(=gw)/VirtualService(=vs) 설정 정보를 확인 kc explain gateways.networking.istio.io kc explain virtualservices.networking.istio.io kubectl api-resources | grep istio # virtual service 는 다른 네임스페이스의 서비스(ex. svc-nn.<ns>)도 참조할 수 있다 kubectl get gw,vs NAME AGE gateway.networking.istio.io/test-gateway 21s NAME GATEWAYS HOSTS AGE virtualservice.networking.istio.io/nginx-service ["test-gateway"] ["www.gasida.dev"] 4m9s # Retrieves last sent and last acknowledged xDS sync from Istiod to each Envoy in the mesh # istioctl proxy-status command was improved to include the time since last change, and more relevant status values. istioctl proxy-status # 단축어 ps istioctl ps
- Istio 를 통한 Nginx 파드 접속 테스트
- (심화 옵션) debug : 파드 디버깅
더보기
# kubectl get pod kc describe pod # 방안1 : 파드의 복제본을 이용 kubectl debug $(kubectl get pod -l app=deploy-websrv -oname) -it --image=nicolaka/netshoot -c netdebug --share-processes --copy-to=websrv-debug --profile='sysadmin' ----- ip -c addr curl localhost ps axf PID USER TIME COMMAND 1 65535 0:00 /pause 26 root 0:00 nginx: master process nginx -g daemon off; 57 101 0:00 nginx: worker process 58 101 0:00 nginx: worker process 59 root 0:01 zsh 89 1337 0:00 /usr/local/bin/pilot-agent proxy sidecar --domain default.svc.cluster.local --proxyLogLevel=warning --proxyC 137 1337 0:00 /usr/local/bin/envoy -c etc/istio/proxy/envoy-rev0.json --restart-epoch 0 --drain-time-s 45 --drain-strategy 188 root 0:00 ps axf ss ss -l ss -4tpl ss -4tp ss -xpl ss -xp netstat -n exit ----- kubectl delete pod websrv-debug # 방안2 : 동작 중인 파드 내 컨테이너 삽입 kubectl debug $(kubectl get pod -l app=deploy-websrv -oname) -it --image=nicolaka/netshoot -c netdebug --profile='netadmin' ----- ip -c addr curl localhost ps axf ss ss -l ss -4tpl ss -4tp ss -xpl ss -xp tcpdump -i. .. 네트워크 툴... exit -----
- (심화 옵션) IPC & UDS 관련 정보 링크 - UDS 소개2 IPC방법들
- Istio - Envoy xDS (x Discovery Service, Dynamic API Configuration) - 링크
- 동적으로 각 영역의 설정을 로드하는 방법
- Management 서비스(Istiod)와 통신하면서 configuration 을 갱신 : Istod - [Istop-proxy ↔ envoy]
- gRPC, REST 방식 모두 지원
- CDS(Clusters) , LDS(Listeners) , EDS(Endpoints), RDS(Routes) → Discovery Service ⇒ ADS (Aggregation Discovery Service) ↔ Istiod
# proxy 상태 확인 istioctl proxy-status NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION deploy-websrv-7d7cf8586c-tvzk6.default Kubernetes SYNCED (55s) SYNCED (55s) SYNCED (55s) SYNCED (55s) IGNORED istiod-7f8b586864-mv944 1.23.2 istio-ingressgateway-5f9f654d46-c4g7s.istio-system Kubernetes SYNCED (4m1s) SYNCED (4m1s) SYNCED (55s) SYNCED (4m1s) IGNORED istiod-7f8b586864-mv944 1.23.2 ...
- ADS 를 통해 다양한 타입의 리소스를 싱글 스트림에서 해결
- https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#aggregated-discovery-service
- Incremental xDS https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#incremental-xds
- Delta xDS now on by default https://istio.io/latest/news/releases/1.22.x/announcing-1.22/#delta-xds-now-on-by-default
- Istio - Istio proxy 와 Envoy 프로세스간 ‘유닉스 도메인 소켓 통신’ 확인
# 파드 확인 kubectl get pod # istio 컨테이너 접속 kubectl exec -it deploy/deploy-websrv -c istio-proxy -- bash --------------------------------------------------------------- # SDS, XDS 는 소켓 타입 ls -al /etc/istio/proxy total 28 drwxrwsrwt 2 root istio-proxy 120 Dec 13 13:03 . drwxr-xr-x 1 root root 4096 Dec 13 13:03 .. srw-rw-rw- 1 istio-proxy istio-proxy 0 Dec 13 13:03 SDS srw-rw-rw- 1 istio-proxy istio-proxy 0 Dec 13 13:03 XDS -rw-r--r-- 1 istio-proxy istio-proxy 17409 Dec 13 13:03 envoy-rev.json -rw-r--r-- 1 istio-proxy istio-proxy 2967 Dec 13 13:03 grpc-bootstrap.json # .json 파일 확인 more /etc/istio/proxy/envoy-rev.json { "node": { "id": "sidecar~172.16.228.67~netpod-866d9d7765-tw7xd.default~default.svc.cluster.local", "cluster": "netpod.default", ... "admin": { "access_log_path": "/dev/null", "profile_path": "/var/lib/istio/data/envoy.prof", "address": { "socket_address": { "address": "127.0.0.1", "port_value": 15000 } ... "dynamic_resources": { "lds_config": { "ads": {}, "initial_fetch_timeout": "0s", "resource_api_version": "V3" }, "cds_config": { "ads": {}, "initial_fetch_timeout": "0s", "resource_api_version": "V3" }, "ads_config": { "api_type": "GRPC", "set_node_on_first_message_only": true, "transport_api_version": "V3", "grpc_services": [ { "envoy_grpc": { "cluster_name": "xds-grpc" ... "static_resources": { "clusters": [ { ... "name": "xds-grpc", "type" : "STATIC", "connect_timeout": "1s", "lb_policy": "ROUND_ROBIN", "load_assignment": { "cluster_name": "xds-grpc", "endpoints": [{ "lb_endpoints": [{ "endpoint": { "address":{ "pipe": { "path": "./etc/istio/proxy/XDS" } ... "listeners":[ ... "address": { "socket_address": { "protocol": "TCP", "address": "0.0.0.0", "port_value": 15021 } "filter_chains": [ { "filters": [ { "name": "envoy.filters.network.http_connection_manager", "typed_config": { "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager" , "codec_type": "AUTO", "stat_prefix": "agent", "route_config": { "virtual_hosts": [ { "name": "backend", "domains": [ "*" ], "routes": [ { "match": { "prefix": "/healthz/ready" }, "route": { "cluster": "agent" ... more /etc/istio/proxy/grpc-bootstrap.json # display only Unix domain sockets : Listener 과 ESTAB 상태 정보 확인 ss -xpl Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process u_str LISTEN 0 4096 etc/istio/proxy/SDS 446191 * 0 users:(("pilot-agent",pid=1,fd=13)) u_str LISTEN 0 4096 etc/istio/proxy/XDS 446192 * 0 users:(("pilot-agent",pid=1,fd=14)) ss -xp Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process u_str ESTAB 0 0 etc/istio/proxy/XDS 446483 * 446482 users:(("pilot-agent",pid=1,fd=16)) u_str ESTAB 0 0 etc/istio/proxy/SDS 446267 * 446266 users:(("pilot-agent",pid=1,fd=18)) u_str ESTAB 0 0 * 446482 * 446483 users:(("envoy",pid=16,fd=20)) u_str ESTAB 0 0 * 446266 * 446267 users:(("envoy",pid=16,fd=19)) # display only TCP sockets and display only IP version 4 sockets ss -4tpl
- 삭제 kubectl delete gw,vs,deploy,svc --all
- (심화 옵션) debug : 파드 디버깅
'Kubernetes' 카테고리의 다른 글
[ Kans 3 Study - 7w ] 3. Istio 트래픽 흐름 (0) | 2024.10.19 |
---|---|
[ Kans 3 Study - 7w ] 2. Bookinfo 실습 & Istio 기능 (1) | 2024.10.19 |
[ Kans 3 Study - 7w ] 실습환경 구성 (1) | 2024.10.19 |
[ Kans 3 Study - 6w ] 4. Gateway API (0) | 2024.10.13 |
[ Kans 3 Study - 6w ] 4. HTTPS 처리(TLS 종료) (0) | 2024.10.13 |