Terraform으로 구성하는 Istio Ambient Mesh + Gateway API on EKS

목차

Istio Ambient Mesh는 사이드카(Sidecar) 없이 서비스 메시를 구성할 수 있는 새로운 아키텍처입니다.
운영 오버헤드를 줄이고, 필요한 컴포넌트만 점진적으로 도입할 수 있다는 점에서 기존 Istio 구조보다 효율적입니다.

또한, Kubernetes Gateway API는 기존 Ingress의 단점을 보완하는 네트워크 표준으로, Istio Ambient Mesh와 자연스럽게 결합됩니다.

이 글에서는 Terraform으로 AWS EKS 클러스터에 Istio Ambient Mesh와 Gateway API를 설치하고, ALB와 연동해 외부 트래픽을 받는 환경을 구성합니다.


설치 개요

Terraform으로 아래 컴포넌트를 설치합니다.

컴포넌트 설명
istio-base Istio 공통 리소스 설치 (CRDs 등)
gateway-api CRDs Gateway API 리소스 정의
istiod (ambient) Ambient Mesh 전용 제어 플레인
istio-cni Ambient Mesh용 CNI
ztunnel L4 터널링 기능을 수행하는 Proxy
gateway-api.yaml Gateway + HTTPRoute 정의, ACM 인증서 기반 ALB 연동

Istio Ambient Mesh와 Gateway API의 Terraform 리소스 관계

선 설명

  • Terraform depends_on 순서
  • Gateway 설정이 참조하거나 허용하는 대상

Istio Ambient Mesh와 Gateway API의 Terraform 리소스 관계

Istio Ambient Mesh와 Gateway API의 Terraform 리소스 관계istio-base 다음에 Gateway API CRD, istiod ambient, istio-cni ambient, ztunnel이 depends_on으로 이어진다. Gateway 리소스는 Gateway API CRD에 의존하고 ACM 인증서 ARN을 주석으로 받는다. 리스너의 allowedRoutes는 shared-gateway-access 라벨이 있는 Namespace만 허용한다.Istioistio-baseCRDs 등 공통 리소스istiodprofile = ambientistio-cniprofile = ambientztunnelL4 프록시Gateway API CRDsv1.2.1 standard-installGateway gatewaygatewayClassName: istio리스너 http 80, https 443ACM 인증서ACM_CERT_ARN라벨이 맞는 Namespaceshared-gateway-access: truedepends_ondepends_ondepends_ondepends_ondepends_onssl-cert 주석allowedRoutes selector
istio-base, Gateway API CRD, istiod, istio-cni, ztunnel 순서로 ambient 구성을 설치하고, CRD 위에 Gateway 리소스를 만든다. Gateway는 ACM 인증서를 주석으로 받고 shared-gateway-access 라벨이 있는 Namespace의 Route만 허용한다.
그림 관계를 글로 읽기
  1. Gateway API CRD는 istio-base에 의존한다.
  2. istiod(profile ambient)는 istio-base와 Gateway API CRD에 의존한다.
  3. istio-cni(profile ambient)는 istio-base, CRD, istiod에 의존한다.
  4. ztunnel(L4 프록시)은 istio-base, CRD, istiod, istio-cni에 의존한다.
  5. Gateway 리소스(gateway-api.yaml)는 Gateway API CRD에 의존한다.
  6. Gateway는 ACM_CERT_ARN을 aws-load-balancer-ssl-cert 주석으로 받는다.
  7. 리스너 allowedRoutes는 shared-gateway-access: "true" 라벨이 있는 Namespace만 허용한다.

1. istio-base 설치

Ambient Mesh 설치의 기본이 되는 Helm 차트입니다.

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"
    })
  ]
}

2. Gateway API CRD 설치

Gateway API는 Ingress를 대체할 수 있는 API이며, Istio가 공식 지원합니다.

hcl
data "http" "gateway_api_crds" {
  url = "https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml"
}

data "kubectl_file_documents" "gateway_api_docs" {
  content = data.http.gateway_api_crds.response_body
}

resource "kubectl_manifest" "gateway_api_crds" {
  for_each  = data.kubectl_file_documents.gateway_api_docs.manifests
  yaml_body = each.value

  depends_on = [ helm_release.istio_base ]
}

3. istiod 설치 (Ambient 모드)

사이드카가 없는 Ambient Mesh용으로 profile = "ambient" 옵션을 사용합니다.

hcl
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

  values = [
    yamlencode({
      profile = "ambient"
    })
  ]

  depends_on = [ helm_release.istio_base, kubectl_manifest.gateway_api_crds ]
}

4. Istio CNI 및 Ztunnel 설치

Ztunnel은 L4 프록시 역할을 하는 Ambient Mesh의 핵심 구성요소입니다.

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

  values = [
    yamlencode({
      profile = "ambient"
    })
  ]

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

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

  depends_on = [
    helm_release.istio_base,
    kubectl_manifest.gateway_api_crds,
    helm_release.istiod,
    helm_release.istio_cni
  ]
}

5. Gateway API 리소스 설치

ALB를 통해 외부에서 접근 가능한 Gateway를 구성합니다. 이때 ACM 인증서를 활용합니다.

hcl
resource "kubectl_manifest" "gateway" {
  yaml_body = templatefile("${path.module}/manifests/gateway-api.yaml", {
    ACM_CERT_ARN = data.aws_acm_certificate.cert.arn
  })

  depends_on = [
    kubectl_manifest.gateway_api_crds
  ]
}

위 gateway-api.yaml은 GatewayClass, Gateway, HTTPRoute 등을 포함하며 ALB와 트래픽 라우팅 설정을 구성합니다.

gateway-api.yaml

yaml
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
  name: gateway
  namespace: istio-system
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
    service.beta.kubernetes.io/aws-load-balancer-attributes: "load_balancing.cross_zone.enabled=true"
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "${ACM_CERT_ARN}"
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
spec:
  gatewayClassName: istio
  listeners:
  - name: http
    hostname: "*.dongdorrong.com"
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: Selector
        selector:
          matchLabels:
            shared-gateway-access: "true"
  - name: https
    hostname: "*.dongdorrong.com"
    port: 443
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: Selector
        selector:
          matchLabels:
            shared-gateway-access: "true"

마무리

Terraform으로 자동화한 구성은 아래와 같습니다.

이후에는 서비스 네임스페이스에 istio.io/dataplane-mode=ambient 라벨을 붙이고, Waypoint Proxy, HTTPRoute 등으로 L7 제어까지 확장할 수 있습니다.


참고 링크

도식

100%

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