본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Gateway 리소스 주석 살펴보기

원문 보기 위키 갱신

이 문서는 쿠버네티스 Gateway 리소스에 주석을 달아 Certificate 리소스를 자동으로 생성하는 방법을 설명해요. cert-manager가 Gateway 리소스에 대한 TLS 인증서를 자동으로 생성하도록 구성하는 방식이에요.

출처: 문서

본문

주석이 달린 Gateway 리소스

apiVersion: gateway.networking.k8s.io/v1

kind: Gateway

FEATURE STATE: cert-manager 1.15 [beta]

📌 이 페이지는 쿠버네티스 Gateway 리소스에 주석을 달아 Certificate 리소스를 자동으로 생성하는 방법에 초점을 맞춥니다. 쿠버네티스 Gateway API에서 HTTP-01 챌린지와 함께 ACME Issuer를 사용하는 방법을 찾고 있다면 ACME HTTP-01(/docs/configuration/acme/http01/)을 참조하세요.

🚧 cert-manager 1.14+는 v1 쿠버네티스 Gateway API로 테스트되었습니다. 리소스 변환 덕분에 v1beta1 및 v1alpha2에서도 작동해야 하지만, 테스트되지는 않았습니다.

cert-manager는 Gateway 리소스에 대한 TLS 인증서를 생성할 수 있습니다. 이는 Gateway에 주석을 추가하여 구성되며, Ingress 리소스 보호(/docs/usage/ingress/) 과정과 유사합니다.

Gateway 리소스는 Gateway API(https://gateway-api.sigs.k8s.io)의 일부입니다. 이는 쿠버네티스 클러스터에 설치하는 CRD 집합으로, Ingress API에 비해 다양한 개선 사항을 제공합니다.

⚠️ ListenerSet 지원은 이제 cert-manager v1.20.0-beta.0+에서 사용할 수 있습니다. 이는 Gateway 리소스에 대한 편집 권한을 요구하지 않고 애플리케이션 개발자에게 셀프 서비스 TLS 구성을 가능하게 합니다. 자세한 내용은 아래의 ListenerSet 섹션(/docs/usage/gateway/#listenerset)을 참조하세요.

Gateway 리소스는 다음 다이어그램에 설명된 것처럼 TLS 구성을 보유합니다(출처: https://gateway-api.sigs.k8s.io (https://gateway-api.sigs.k8s.io)):

📌 이 기능을 사용하려면 Gateway API 번들(https://gateway-api.sigs.k8s.io/guides/getting-started/#installing-gateway-api) 설치와 cert-manager 컨트롤러에 추가 플래그 전달이 필요합니다.

v1.4.1 Gateway API 번들(Gateway API 버전과 연결된 CRD)을 설치하려면 다음 명령을 실행하세요:

kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/standard-install.yaml

cert-manager 1.15부터 Gateway API 지원은 더 이상 기능 플래그 뒤에 숨겨져 있지 않지만, 여전히 Gateway API 지원을 활성화해야 합니다.

Gateway API 지원을 활성화하려면 다음 config Helm 값을 사용해 파일 기반 구성(/docs/installation/configuring-components/#configuration-file)을 사용하세요:

config:
  gatewayAPI:
    enabled: true

해당하는 Helm 명령은 다음과 같습니다:

helm upgrade --install cert-manager oci://quay.io/jetstack/charts/cert-manager --namespace cert-manager \
  --set config.gatewayAPI.enabled=true

Gateway API CRD는 cert-manager가 시작되기 전에 설치하거나, Gateway API CRD를 설치한 후 cert-manager Deployment를 재시작해야 합니다. 일부 cert-manager 구성 요소는 시작 시에만 Gateway API 검사를 수행하기 때문에 이것이 중요합니다. 다음 명령으로 cert-manager를 재시작할 수 있습니다:

kubectl rollout restart deployment cert-manager -n cert-manager

cert-manager.io/issuer 또는 cert-manager.io/cluster-issuer 주석은 cert-manager에게 Gateway에 대한 Certificate를 생성하라고 지시합니다. 예를 들어 다음 Gateway는 example-com-tls라는 이름의 Certificate 생성을 트리거합니다:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: example
  annotations:
    cert-manager.io/issuer: foo
spec:
  gatewayClassName: foo
  listeners:
    - name: http
      hostname: example.com
      port: 443
      protocol: HTTPS
      allowedRoutes:
        namespaces:
          from: All
      tls:
        mode: Terminate
        certificateRefs:
          - name: example-com-tls

몇 순간 후 cert-manager가 Certificate를 생성합니다. Certificate는 Secret 이름 example-com-tls에서 이름을 따옵니다. dnsNames 필드는 Gateway 스펙의 hostname 필드로 설정됩니다.

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: example-com-tls
spec:
  issuerRef:
    name: my-issuer
    kind: Issuer
    group: cert-manager.io
  dnsNames:
    - example.com # ✅ Copied from the `hostname` field.
  secretName: example-com-tls

🚧 이 메커니즘은 Gateway와 같은 네임스페이스에서만 Secret을 생성하는 데 사용할 수 있습니다. cert-manager#5610 (https://github.com/cert-manager/cert-manager/issues/5610) 참조

사용 사례

선택한 TLS 블록에 대한 TLS 인증서 생성

cert-manager는 Certificate 생성에 사용할 수 없는 리스너 블록은 건너뜁니다. 리스너 블록이 Certificate 생성에 사용되려면 다음 요구 사항을 충족해야 합니다:

Field | Requirement | hostname | Must not be empty. | tls.mode | Must be set to Terminate. Passthrough is not supported. | tls.certificateRef.name | Cannot be left empty. | tls.certificateRef.kind | If specified, must be set to Secret. | tls.certificateRef.group | If specified, must be set to core. | tls.certificateRef.namespace | If specified, must be the same as the Gateway. |

다음 예시에서 처음 네 개의 리스너 블록은 Certificate 리소스를 생성하는 데 사용되지 않습니다:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: my-gateway
  namespace: default
  annotations:
    cert-manager.io/issuer: my-issuer
spec:
  gatewayClassName: foo
  listeners:
    # ❌  Missing "tls" block, the following listener is skipped.
    - name: example-1
      port: 80
      protocol: HTTP
      hostname: example.com

    # ❌  Missing "hostname", the following listener is skipped.
    - name: example-2
      port: 443
      protocol: HTTPS
      tls:
        certificateRefs:
          - name: example-com-tls
            kind: Secret
            group: ""

    # ❌  "mode: Passthrough" is not supported, the following listener is skipped.
    - name: example-3
      hostname: example.com
      port: 8443
      protocol: HTTPS
      tls:
        mode: Passthrough
        certificateRefs:
          - name: example-com-tls
            kind: Secret
            group: ""

    # ❌  Cross-namespace secret references are not supported, the following listener is skipped.
    - name: example-4
      hostname: foo.example.com
      port: 8443
      protocol: HTTPS
      allowedRoutes:
        namespaces:
          from: All
      tls:
        mode: Terminate
        certificateRefs:
          - name: example-com-tls
            kind: Secret
            group: ""
            namespace: other-namespace

    # ✅  The following listener is valid.
    - name: example-5
      hostname: bar.example.com # ✅ Required.
      port: 8443
      protocol: HTTPS
      allowedRoutes:
        namespaces:
          from: All
      tls:
        mode: Terminate # ✅ Required. "Terminate" is the only supported mode.
        certificateRefs:
          - name: example-com-tls # ✅ Required.
            kind: Secret  # ✅ Optional. "Secret" is the only valid value.
            group: "" # ✅ Optional. "" is the only valid value.

cert-manager는 처음 네 개의 리스너 블록을 건너뛰고 마지막 리스너 블록에 대해 example-com-tls라는 단일 Certificate를 생성했습니다:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: example-com-tls
spec:
  issuerRef:
    name: my-issuer
    kind: Issuer
    group: cert-manager.io
  dnsNames:
    - bar.example.com
  secretName: example-com-tls

동일한 Secret 이름을 가진 두 개의 리스너

호스트 이름과 관계없이 동일한 Secret 이름을 여러 TLS 블록에서 재사용할 수 있습니다. 다음과 같은 두 개의 리스너가 있다고 가정해 봅시다:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: example
  annotations:
    cert-manager.io/issuer: my-issuer
spec:
  gatewayClassName: foo
  listeners:
    # Listener 1.
    - name: example-1
      hostname: example.com
      port: 443
      protocol: HTTPS
      tls:
        mode: Terminate
        certificateRefs:
          - name: example-com-tls

    # Listener 2: Same Secret name as Listener 1, with a different hostname.
    - name: example-2
      hostname: "*.example.com"
      port: 443
      protocol: HTTPS
      tls:
        mode: Terminate
        certificateRefs:
          - name: example-com-tls

    # Listener 3: also same Secret name, except the hostname is also the same.
    - name: example-3
      hostname: "*.example.com"
      port: 8443
      protocol: HTTPS
      tls:
        mode: Terminate
        certificateRefs:
          - name: example-com-tls

   # Listener 4: different Secret name.
    - name: example-4
      hostname: site.org
      port: 443
      protocol: HTTPS
      tls:
        mode: Terminate
        certificateRefs:
          - name: site-org-tls

cert-manager는 두 개의 Secret 이름이 사용되므로 두 개의 Certificate를 생성합니다: example-com-tls와 site-org-tls. Certificate의 dnsNames는 리스너 2와 3 모두에 대해 *.example.com 이 단 한 번 포함됩니다( hostname 값이 중복 제거됩니다).

두 Certificate는 다음과 같습니다:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: example-com-tls
spec:
  issuerRef:
    name: my-issuer
    kind: Issuer
    group: cert-manager.io
  dnsNames:
    - example.com # From listener 1.
    - *.example.com # From listener 2 and 3.
  secretName: example-com-tls
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: site-org-tls
spec:
  issuerRef:
    name: my-issuer
    kind: Issuer
    group: cert-manager.io
  dnsNames:
    - site.org # From listener 4.
  secretName: site-org-tls

지원되는 주석

Ingress 리소스에서 Gateway 및 ListenerSet 리소스로 마이그레이션하는 경우 Ingress 리소스의 주석(/docs/usage/ingress/#supported-annotations)과 Gateway 및 ListenerSet 리소스의 주석 사이에는 몇 가지 차이점이 있음에 유의하세요.

Gateway 및 ListenerSet 리소스는 Certificate 리소스 생성에 대해 다음 주석을 지원합니다:

cert-manager.io/issuer: 이 Gateway에 필요한 인증서를 발급해야 하는 Issuer의 이름입니다. Issuer는 Gateway 리소스와 같은 네임스페이스에 있어야 합니다.

cert-manager.io/cluster-issuer: 이 Gateway에 필요한 인증서를 획득할 cert-manager.io ClusterIssuer의 이름입니다. ClusterIssuer는 네임스페이스 범위가 아닌 리소스이므로 Gateway가 어느 네임스페이스에 있든 상관없습니다.

cert-manager.io/issuer-kind: 외부 issuer 리소스의 종류입니다. 예를 들어 AWSPCAIssuer. 이는 out-of-tree issuer에만 필요합니다.

cert-manager.io/issuer-group: 외부 issuer 컨트롤러의 API 그룹입니다. 예를 들어 awspca.cert-manager.io. 이는 out-of-tree issuer에만 필요합니다.

cert-manager.io/common-name: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.commonName을 구성할 수 있습니다.

cert-manager.io/email-sans: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.emailAddresses 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "me@example.com (mailto:me@example.com),you@example.com (mailto:you@example.com)"

cert-manager.io/subject-organizations: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.organizations 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "Company 1,Company 2"

cert-manager.io/subject-organizationalunits: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.organizationalUnits 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "IT Services,Cloud Services"

cert-manager.io/subject-countries: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.countries 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "Country 1,Country 2"

cert-manager.io/subject-provinces: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.provinces 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "Province 1,Province 2"

cert-manager.io/subject-localities: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.localities 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "City 1,City 2"

cert-manager.io/subject-postalcodes: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.postalCodes 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "123ABC,456DEF"

cert-manager.io/subject-streetaddresses: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.streetAddresses 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "123 Example St,456 Other Blvd"

cert-manager.io/subject-serialnumber: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.subject.serialNumber 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 지원합니다. 예: "10978342379280287615,1111144445555522228888"

cert-manager.io/duration: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.duration 필드를 구성할 수 있습니다.

cert-manager.io/renew-before: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.renewBefore 필드를 구성할 수 있습니다.

cert-manager.io/usages: (선택 사항) 이 주석을 사용하면 생성될 Certificate의 spec.usages 필드를 구성할 수 있습니다. 쉼표로 구분된 값을 가진 문자열을 전달합니다. 예: "key agreement,digital signature, server auth"

cert-manager.io/revision-history-limit: (선택 사항) 이 주석을 사용하면 Certificate에 대해 유지할 CertificateRequests 수를 제한하도록 spec.revisionHistoryLimit 필드를 구성할 수 있습니다. 최소값은 1입니다. 설정하지 않으면 모든 CertificateRequests가 유지됩니다.

cert-manager.io/private-key-algorithm: (선택 사항) 이 주석을 사용하면 Certificate의 개인 키 생성을 위한 알고리즘을 설정하도록 spec.privateKey.algorithm 필드를 구성할 수 있습니다. 유효한 값은 RSA, ECDSA, Ed25519입니다. 설정하지 않으면 RSA 알고리즘이 사용됩니다.

cert-manager.io/private-key-encoding: (선택 사항) 이 주석을 사용하면 Certificate의 개인 키 생성을 위한 인코딩을 설정하도록 spec.privateKey.encoding 필드를 구성할 수 있습니다. 유효한 값은 PKCS1과 PKCS8입니다. 설정하지 않으면 PKCS1 알고리즘이 사용됩니다.

cert-manager.io/private-key-size: (선택 사항) 이 주석을 사용하면 Certificate의 개인 키 크기를 설정하도록 spec.privateKey.size 필드를 구성할 수 있습니다. 알고리즘이 RSA로 설정된 경우 유효한 값은 2048, 4096, 8192이며, 지정하지 않으면 2048이 기본값입니다. 알고리즘이 ECDSA로 설정된 경우 유효한 값은 256, 384, 521이며, 지정하지 않으면 256이 기본값입니다. 알고리즘이 Ed25519로 설정된 경우 크기는 무시됩니다.

cert-manager.io/private-key-rotation-policy: (선택 사항) 이 주석을 사용하면 Certificate의 개인 키 회전 정책을 설정하도록 spec.privateKey.rotationPolicy 필드를 구성할 수 있습니다. 유효한 값은 Never와 Always입니다. 설정하지 않으면 Always 회전 정책이 사용됩니다.

주석을 Certificate로 복사

ℹ️ 이 기능은 cert-manager v1.18.0에 추가되었습니다.

특정 커스텀 주석을 생성된 Certificate 객체에 복사하는 것이 가능합니다. 예를 들어 Gateway에서 Certificate로 venafi.cert-manager.io/custom-fields 주석을 복사하려면 먼저 다음 추가 인수로 cert-manager 컨트롤러를 다시 배포해야 합니다:

--extra-certificate-annotations=venafi.cert-manager.io/custom-fields

또는 Helm을 사용한다면 다음 값을 제공하세요:

# values.yaml
config:
  ingressShimConfig:
    extraCertificateAnnotations:
    - venafi.cert-manager.io/custom-fields

그런 다음 Gateway 리소스에 주석을 추가할 수 있습니다:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: example
  annotations:
    # custom configuration
    venafi.cert-manager.io/custom-fields: `[ {"name": "field-name", "value": "field value"}]`

ListenerSet

FEATURE STATE: cert-manager 1.20 [alpha]

ListenerSet이란 무엇인가?

ListenerSet은 GEP-1713(https://gateway-api.sigs.k8s.io/geps/gep-1713/)에서 도입된 Gateway API 리소스로, Ingress에서 Gateway API로 마이그레이션할 때의 핵심 제한 사항, 즉 애플리케이션 개발자의 셀프 서비스 TLS 구성 상실을 해결합니다.

Ingress 리소스를 사용하면 개발자가 cert-manager 주석을 사용해 라우팅과 TLS 인증서를 모두 독립적으로 구성할 수 있었습니다. Gateway API로 마이그레이션하면 TLS 구성이 일반적으로 클러스터 운영자가 제어하는 Gateway 리소스로 이동합니다. 이로 인해 개발자는 자신이 소유하지 않은 리소스에 변경을 요청해야 하며, Ingress에서 가졌던 자율성을 잃게 됩니다.

ListenerSet은 개발자가 HTTPRoute와 함께 ListenerSet 리소스를 만들 수 있게 하여 셀프 서비스를 복원합니다. Gateway와 동일한 주석을 ListenerSet에서 사용해 Certificate 리소스 생성을 트리거할 수 있습니다.

ListenerSet 지원 활성화

ListenerSet 지원에는 Gateway API v1.5+(표준 채널)가 필요합니다. CRD 설치 지침은 Gateway API 문서에서 확인할 수 있습니다: Installing Gateway API (https://gateway-api.sigs.k8s.io/guides/getting-started/#installing-gateway-api).

ListenerSet을 사용하려면 cert-manager에서 기능을 활성화해야 합니다. 파일 기반 구성(/docs/installation/configuring-components/#configuration-file)을 사용하는 것을 권장합니다. values.yaml에 다음을 추가하세요:

# values.yaml
config:
  gatewayAPI:
    enabled: true
    enableListenerSet: true
  featureGates:
    ListenerSets: true

gatewayAPI.enabled 설정은 cert-manager가 Gateway 리소스를 조정하도록 지시하고, gatewayAPI.enableListenerSet은 cert-manager가 ListenerSet 리소스도 조정하도록 지시합니다.

해당하는 Helm 명령은 다음과 같습니다:

helm upgrade --install cert-manager oci://quay.io/jetstack/charts/cert-manager \
  --namespace cert-manager \
  --set config.gatewayAPI.enabled=true \
  --set config.gatewayAPI.enableListenerSet=true \
  --set config.featureGates.ListenerSets=true

설치 후 cert-manager를 재시작하여 새 CRD를 인식하는지 확인하세요:

kubectl rollout restart deployment cert-manager -n cert-manager

예제: ListenerSet과 HTTP-01을 사용한 셀프 서비스 TLS

다음은 애플리케이션 개발자가 자신의 TLS 구성을 관리할 수 있는 방법을 보여주는 완전한 예입니다. 클러스터 운영자가 만든 공유 ClusterIssuer와 Gateway부터 시작해 봅시다:

kind: ClusterIssuer
apiVersion: cert-manager.io/v1
metadata:
  name: letsencrypt
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: platformteam@example.com
    privateKeySecretRef:
      name: letsencrypt-acc-key
    solvers:
      - http01:
          gatewayHTTPRoute: {}
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: eg
  namespace: envoy-gateway-system
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      hostname: dummy
      protocol: HTTP
      port: 80
  allowedListeners:
    namespaces:
      from: All

dummy 리스너는 listeners를 비워 둘 수 없기 때문에 필요합니다. 자세한 내용은 Gateway API 프로젝트의 이슈 4425(https://github.com/kubernetes-sigs/gateway-api/issues/4425)를 참조하세요.

개발자는 자신의 네임스페이스에서 애플리케이션을 위한 Service, ListenerSet, HTTPRoute를 만듭니다:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
  namespace: dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - image: gcr.io/k8s-staging-gateway-api/echo-basic:v20231214-v1.0.0-140-gf544a46e
          imagePullPolicy: IfNotPresent
          name: backend
          ports:
            - name: http
              containerPort: 3000
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
---
apiVersion: v1
kind: Service
metadata:
  name: backend
  namespace: dev
spec:
  ports:
    - name: http
      port: 3000
      targetPort: 3000
  selector:
    app: backend
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: backend
  namespace: dev
spec:
  parentRefs:
    - kind: ListenerSet
      name: backend
      namespace: dev
  hostnames:
    - echo.example.com
  rules:
    - backendRefs:
        - kind: Service
          name: backend
          port: 3000
          weight: 1
      matches:
        - path:
            type: PathPrefix
            value: /
---
kind: ListenerSet
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: backend
  namespace: dev
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
spec:
  parentRef:
    name: eg
    namespace: envoy-gateway-system
  listeners:
    - name: https
      hostname: echo.example.com
      port: 443
      protocol: HTTPS
      tls:
        mode: Terminate
        certificateRefs:
          - name: backend-tls
    - name: http
      hostname: echo.example.com
      port: 80
      protocol: HTTP

cert-manager는 ListenerSet을 기반으로 Certificate 리소스를 자동으로 만듭니다:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  annotations:
    acme.cert-manager.io/http01-parentrefkind: ListenerSet
    acme.cert-manager.io/http01-parentrefname: backend
  name: backend-tls
  namespace: dev
spec:
  dnsNames:
  - echo.example.com
  issuerRef:
    kind: ClusterIssuer
    name: letsencrypt
  secretName: backend-tls
  usages:
  - digital signature
  - key encipherment

ListenerSet에서 지원되는 주석

Gateway와 ListenerSet 모두 cert-manager 주석을 가질 때, 해당 ListenerSet에 정의된 리스너에 대해서는 ListenerSet 주석이 Gateway 주석보다 우선합니다.

ListenerSet 리소스는 Gateway 리소스와 동일한 cert-manager 주석을 지원합니다. 위의 지원되는 주석(/docs/usage/gateway/#supported-annotations) 섹션을 참조하세요.

추가로 ListenerSet은 다음 주석을 지원합니다:

  • acme.cert-manager.io/http01-parentreffallback: "true"로 설정하면 cert-manager는 ListenerSet 자체 대신 ListenerSet의 spec.parentRef(상위 Gateway)를 ACME HTTP-01 챌린지를 제공하기 위해 생성하는 HTTPRoute의 parentRef로 사용합니다.

공유 Gateway HTTP 리스너를 사용한 HTTPS 전용 ListenerSet

Self-Service TLS with ListenerSet and HTTP-01(/docs/usage/gateway/#example-self-service-tls-with-listenerset-and-http-01) 예제에서 ListenerSet은 ACME HTTP-01 챌린지를 위한 자체 HTTP 리스너를 포함합니다.

대안으로 ListenerSet에서 HTTP 리스너를 생략하고 상위 Gateway의 단일 HTTP 리스너에 의존할 수 있습니다. 이 경우 Gateway의 HTTP 리스너에서 dummy 호스트 이름을 제거해 실제 트래픽을 제공할 수 있게 하고, ListenerSet에 acme.cert-manager.io/http01-parentreffallback: "true" 주석을 추가하세요:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: eg
  namespace: envoy-gateway-system
spec:
  gatewayClassName: eg
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      allowedRoutes:
        namespaces:
          from: All
  allowedListeners:
    namespaces:
      from: All
---
kind: ListenerSet
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: backend
  namespace: dev
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
    acme.cert-manager.io/http01-parentreffallback: "true"
spec:
  parentRef:
    name: eg
    namespace: envoy-gateway-system
  listeners:
    - name: https
      hostname: echo.example.com
      port: 443
      protocol: HTTPS
      tls:
        mode: Terminate
        certificateRefs:
          - name: backend-tls

이 주석을 사용하면 cert-manager는 ListenerSet 자체가 아닌 상위 Gateway를 ACME HTTP-01 챌린지를 제공하기 위해 생성하는 HTTPRoute의 parentRef로 사용합니다. Gateway의 HTTP 리스너는 모든 테넌트 ListenerSet에 대한 ACME HTTP-01 챌린지를 제공합니다. 결과 Certificate는 Gateway를 참조합니다:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  annotations:
    acme.cert-manager.io/http01-parentrefkind: Gateway
    acme.cert-manager.io/http01-parentrefname: eg
    acme.cert-manager.io/http01-parentrefnamespace: envoy-gateway-system
  name: backend-tls
  namespace: dev
spec:
  dnsNames:
  - echo.example.com
  issuerRef:
    kind: ClusterIssuer
    name: letsencrypt
  secretName: backend-tls
  usages:
  - digital signature
  - key encipherment

개발자를 위한 내부 작동 다이어그램

[1] https://cert-manager.io/docs/usage/certificate (https://cert-manager.io/docs/usage/certificate)

더 알아보기 (Learn more)