Terraform으로 구성하는 Istio Sidecar Mesh + ALB Ingress on EKS

목차

Istio의 사이드카(Sidecar) 기반 아키텍처는 각 Pod 옆에 Envoy Proxy를 배치해 트래픽을 제어합니다.

이 패턴은 관찰성과 보안을 높이지만, 리소스 오버헤드가 있습니다.

이 글에서는 Terraform으로 AWS EKS 클러스터에 사이드카 모드 Istio를 설치하고, ALB Ingress Controller와 연동해 외부 트래픽을 받는 구조를 구성합니다.


설치 개요

컴포넌트 설명
istio-base Istio 공통 리소스 설치 (CRDs 등)
istiod 사이드카 기반 Istio 제어 플레인
istio-ingressgateway 외부 진입점 게이트웨이 (NodePort로 배포)
Gateway 리소스 Istio Gateway CR
ALB용 Ingress 리소스 서비스/모니터링용 ALB Ingress 정의

Istio Sidecar와 ALB Ingress의 Terraform 리소스 관계

선 설명

  • Terraform depends_on 순서
  • Ingress 템플릿이 값을 가져오는 data source

Istio Sidecar와 ALB Ingress의 Terraform 리소스 관계

Istio Sidecar와 ALB Ingress의 Terraform 리소스 관계istio-base 다음에 istiod, 그다음 NodePort Service로 배포하는 istio-ingress, Istio Gateway CR, 서비스용과 Addons용 ALB Ingress가 depends_on으로 이어진다. 두 Ingress 템플릿은 istio-ingressgateway Service의 15021 포트 NodePort를 헬스체크 포트 값으로 받는다.Istioistio-baseCRDs 등 공통 리소스istiod사이드카 제어 플레인istio-ingressgateway 차트, Service NodePortIstio Gateway CRistio-gateway.yamlALB Ingress: Services용퍼블릭 서브넷, ACM 인증서ALB Ingress: Addons용퍼블릭 서브넷, ACM 인증서depends_ondepends_ondepends_ondepends_ondepends_on헬스체크 포트:15021의 NodePort헬스체크 포트:15021의 NodePort
istio-base, istiod, istio-ingress, Gateway CR로 이어지는 Terraform depends_on 순서 위에 Services용·Addons용 ALB Ingress 두 개가 놓인다. 두 Ingress는 헬스체크 포트 값을 istio-ingress Service의 node_port에서 가져온다.
그림 관계를 글로 읽기
  1. istiod는 istio-base에 의존한다.
  2. istio-ingress(gateway 차트, Service NodePort)는 istio-base와 istiod에 의존한다.
  3. Istio Gateway CR(istio-gateway.yaml)은 istio-base, istiod, istio-ingress에 의존한다.
  4. Services용 ALB Ingress는 앞의 네 리소스에 의존한다. 템플릿에 퍼블릭 서브넷과 ACM 인증서를 넘긴다.
  5. Addons용 ALB Ingress도 같은 네 리소스에 의존한다.
  6. Services용 Ingress 템플릿의 헬스체크 포트 값은 istio-ingressgateway Service 15021 포트의 node_port다.
  7. Addons용 Ingress 템플릿도 같은 값을 받는다.

1. istio-base 및 istiod 설치

hcl
resource "helm_release" "istio_base" {
  namespace        = "istio-system"
  create_namespace = true
  name             = "istio-base"
  repository       = "https://istio-release.storage.googleapis.com/charts"
  chart            = "base"
  upgrade_install  = true

  values = [
    yamlencode({
      defaultRevision = "default"
    })
  ]
}

resource "helm_release" "istiod" {
  namespace        = "istio-system"
  create_namespace = true
  name             = "istiod"
  repository       = "https://istio-release.storage.googleapis.com/charts"
  chart            = "istiod"
  upgrade_install  = true

  depends_on = [ helm_release.istio_base ]
}

2. istio-ingressgateway 설치 (NodePort + ALB 연계 목적)

hcl
resource "helm_release" "istio_ingress" {
  namespace        = "istio-ingress"
  create_namespace = true
  name             = "istio-ingress"
  repository       = "https://istio-release.storage.googleapis.com/charts"
  chart            = "gateway"
  upgrade_install  = true

  values = [
    yamlencode({
      _internal_defaults_do_not_set = {
        service = {
          type = "NodePort"
        }
      }
      extraManifests = []
    })
  ]

  depends_on = [ helm_release.istio_base, helm_release.istiod ]
}

3. Istio Gateway 리소스 정의

hcl
resource "kubectl_manifest" "istio_gateway" {
  yaml_body = file("${path.module}/manifests/istio-gateway.yaml")

  depends_on = [
    helm_release.istio_base,
    helm_release.istiod,
    helm_release.istio_ingress
  ]
}

4. Ingress 리소스 (ALB 연동)

ALB와 연동되는 Ingress 템플릿 (Services용)

hcl
resource "kubectl_manifest" "ingress_for_services" {
  yaml_body = templatefile("${path.module}/manifests/ingress-for-serivces.yaml", {
    ALB_NAME_SVC                   = "${local.cluster_name}-svc-ingress"
    PUBLIC_SUBNET_IDS             = join(",", aws_subnet.public[*].id)
    ACM_CERT_ARN                  = data.aws_acm_certificate.cert.arn
    ISTIO_INGRESS_HEALTHCHECK_PORT = tostring([
      for p in data.kubernetes_service.istio_ingressgateway.spec[0].port :
        p.node_port if p.port == 15021
    ][0])
    WAF_ACL_ARN = ""
  })

  depends_on = [
    helm_release.istio_base,
    helm_release.istiod,
    helm_release.istio_ingress,
    kubectl_manifest.istio_gateway
  ]
}

ALB와 연동되는 Ingress 템플릿 (Addons용)

hcl
resource "kubectl_manifest" "ingress_for_addons" {
  yaml_body = templatefile("${path.module}/manifests/ingress-for-addons.yaml", {
    ALB_NAME_ADDON                = "${local.cluster_name}-addon-ingress"
    PUBLIC_SUBNET_IDS             = join(",", aws_subnet.public[*].id)
    ACM_CERT_ARN                  = data.aws_acm_certificate.cert.arn
    ISTIO_INGRESS_HEALTHCHECK_PORT = tostring([
      for p in data.kubernetes_service.istio_ingressgateway.spec[0].port :
        p.node_port if p.port == 15021
    ][0])
    WAF_ACL_ARN = ""
  })

  depends_on = [
    helm_release.istio_base,
    helm_release.istiod,
    helm_release.istio_ingress,
    kubectl_manifest.istio_gateway
  ]
}

마무리

이 구성의 특징은 아래와 같습니다.

실제 운영에도 활용할 수 있는 Sidecar + ALB 아키텍처입니다.


참고 링크

도식

100%

끌어서 이동, 두 손가락이나 휠로 확대·축소. 키보드: 화살표 이동, + − 확대·축소, 0 맞춤, Esc 닫기. 같은 내용은 그림 아래 “그림 관계를 글로 읽기”에 있다.