Let's Encrypt를 사용하도록 AKS(Azure Kubernetes Service) 인스턴스를 구성하고 도메인에 대한 TLS/SSL 인증서를 자동으로 가져올 수 있습니다. 인증서는 AKS 클러스터에 대한 TLS/SSL 종료를 수행하는 Azure 애플리케이션 Gateway에 설치됩니다.
이 문서에서 설명하는 설정은 인증서 생성 및 관리를 자동화하는 cert-manager Kubernetes 추가 기능을 사용합니다.
팁
Kubernetes 수신 솔루션에 대한 컨테이너용 Application Gateway를 고려합니다.
추가 기능 설치
다음 단계를 사용하여 기존 AKS 클러스터에 cert-manager를 설치합니다.
다음 스크립트를 실행하여 cert-manager Helm 차트를 설치합니다. 이 스크립트에서는 다음 작업을 수행합니다.
- AKS 클러스터에 새
cert-manager
네임스페이스를 만듭니다. - 다음과 같은 CRD(사용자 지정 리소스 정의)
Certificate
를 만듭니다. ,Challenge
,ClusterIssuer
,Issuer
Order
- cert-manager 사이트에서 cert-manager 차트를 설치합니다.
#!/bin/bash # Install the CustomResourceDefinition resources separately kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.crds.yaml # Create the namespace for cert-manager kubectl create namespace cert-manager # Label the cert-manager namespace to disable resource validation kubectl label namespace cert-manager cert-manager.io/disable-validation=true # Add the Jetstack Helm repository helm repo add jetstack https://charts.jetstack.io # Update your local Helm chart repository cache helm repo update # Install the cert-manager Helm chart # Helm v3+ helm install \ cert-manager jetstack/cert-manager \ --namespace cert-manager \ --version v1.16.1 \ # --set installCRDs=true # To automatically install and manage the CRDs as part of your Helm release, # you must add the --set installCRDs=true flag to your Helm installation command.
- AKS 클러스터에 새
ClusterIssuer
리소스를 만듭니다. 인증서 관리자는 서명된 인증서를 발급하는 Let's Encrypt 인증 기관을 나타내기 위해 이 리소스가 필요합니다.Cert-manager는 네임스페이스가 아닌
ClusterIssuer
리소스를 사용하여 여러 네임스페이스에서 사용할 수 있는 인증서를 발급합니다. 암호화는 ACME 프로토콜을 사용하여 특정 도메인 이름을 제어하고 인증서를 발급하는지 확인합니다. cert-manager 설명서에서 속성 구성ClusterIssuer
에 대한 자세한 내용을 확인할 수 있습니다.ClusterIssuer
는 테스트에 사용되는 Let's Encrypt 준비 환경을 사용하여 인증서를 발급하도록 인증서 관리자에게 지시합니다. (루트 인증서는 브라우저/클라이언트 트러스트 저장소에 없습니다.)아래 YAML의 기본 챌린지 형식은
http01
입니다. Let's Encrypt 설명서에서 다른 챌린지 유형을 찾을 수 있습니다.다음 YAML에서 사용자 정보로 바꿔
<YOUR.EMAIL@ADDRESS>
야 합니다.#!/bin/bash kubectl apply -f - <<EOF apiVersion: cert-manager.io/v1 kind: ClusterIssuer metadata: name: letsencrypt-staging spec: acme: # You must replace this email address with your own. # Let's Encrypt uses this to contact you about expiring # certificates, and issues related to your account. email: <YOUR.EMAIL@ADDRESS> # ACME server URL for Let's Encrypt's staging environment. # The staging environment won't issue trusted certificates but is # used to ensure that the verification process is working properly # before moving to production server: https://acme-staging-v02.api.letsencrypt.org/directory privateKeySecretRef: # Secret resource used to store the account's private key. name: example-issuer-account-key # Enable the HTTP-01 challenge provider # you prove ownership of a domain by ensuring that a particular # file is present at the domain solvers: - http01: ingress: # class: azure/application-gateway ingressTemplate: metadata: annotations: kubernetes.io/ingress.class: azure/application-gateway EOF
Let's Encrypt 인증서와 함께 Application Gateway 배포를 사용하여 애플리케이션을 노출
guestbook
하는 수신 리소스를 만듭니다.Application Gateway 배포에 DNS 이름이 있는 공용 프런트 엔드 IP 구성이 있는지 확인합니다. 기본
azure.com
도메인을 사용하거나 Azure DNS 영역을 프로비전한 다음 사용자 지정 도메인을 할당합니다. 주석certmanager.k8s.io/cluster-issuer: letsencrypt-staging
은 cert-manager에게 태그가 지정된 수신 리소스를 처리하도록 지시합니다.다음 YAML에서는 사용자 고유의 도메인 또는 Application Gateway 도메인(예:
kh-aks-ingress.westeurope.cloudapp.azure.com
)으로 바꿔<PLACEHOLDERS.COM>
야 합니다.kubectl apply -f - <<EOF apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: guestbook-letsencrypt-staging annotations: kubernetes.io/ingress.class: azure/application-gateway cert-manager.io/cluster-issuer: letsencrypt-staging spec: tls: - hosts: - <PLACEHOLDERS.COM> secretName: guestbook-secret-name rules: - host: <PLACEHOLDERS.COM> http: paths: - backend: serviceName: frontend servicePort: 80 EOF
몇 초 후에 자동으로 발급된 Let's Encrypt 인증서를 준비에 사용하여 Application Gateway HTTPS URL을 통해 서비스에 액세스할
guestbook
수 있습니다.브라우저에서 잘못된 인증 기관에 대해 경고할 수 있습니다. 그 이유는 스테이
CN=Fake LE Intermediate X1
징 인증서를 발급하기 때문입니다. 이 경고는 시스템이 예상대로 작동하고 프로덕션 인증서에 대한 준비가 되었음을 의미합니다.스테이징 인증서를 성공적으로 설정한 후 프로덕션 ACME 서버로 전환할 수 있습니다.
- 수신 리소스
cert-manager.io/cluster-issuer: letsencrypt-prod
의 스테이징 주석을 . - 이전에 만든 기존 스테이징
ClusterIssuer
리소스를 삭제합니다. 이전ClusterIssuer
YAMLhttps://acme-v02.api.letsencrypt.org/directory
의 ACME 서버를 .로 바꿔서 새 스테이징 리소스를 만듭니다.
- 수신 리소스
Let's Encrypt 인증서가 만료되기 cert-manager
전에 Kubernetes 비밀 저장소에서 인증서를 자동으로 업데이트합니다. 이 시점에서 Application Gateway 수신 컨트롤러는 Application Gateway를 구성하는 데 사용하는 수신 리소스에서 참조되는 업데이트된 비밀을 적용합니다.