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

ACME: Redis 스토리지와 Azure Managed Redis 인스턴스 인증을 사용하는 ACME

원문 보기 위키 갱신

ACME: Redis 스토리지와 Azure Managed Redis 인스턴스 인증을 사용하는 ACME (ACME with Redis storage and Azure Managed Redis instance auth)

이 문서에서는 Azure Managed Redis 인스턴스 인증을 활용해 Redis를 스토리지 백엔드로 사용하도록 ACME 플러그인을 구성하는 방법을 안내해요. 먼저 공개 IP와 DNS, 포트 80 프록시 트래픽 같은 사전 준비 사항과 EMAIL, KEY_ID 같은 환경 변수를 짚어 줄게요. 이어서 decK 설정 파일과 Admin API를 이용해 플러그인을 전역으로 설정하는 방법을 차근차근 살펴봐요

출처: 문서

본문

Redis 스토리지 및 Azure Managed Redis 인스턴스 인증을 사용하는 ACME v2.0+

Azure Managed Redis 인스턴스 인증을 사용하고, Redis를 스토리지 백엔드로 사용하도록 ACME 플러그인을 구성해요

사전 준비

환경 변수

  • EMAIL: 계정 식별자예요.

  • KEY_ID: Key의 kid예요.

  • KEY_SET: Key ID를 연결할 Key Set의 이름이에요.

  • DOMAIN: 호스트를 나타내는 문자열 배열이에요.

  • INSTANCE_ADDRESS: Azure Managed Redis 인스턴스 주소예요.

  • INSTANCE_USERNAME: 필수 액세스 권한을 가진 Principal/Identity의 개체(보안 주체) ID예요.

  • AZURE_CLIENT_ID: Principal/Identity의 클라이언트 ID예요.

  • AZURE_CLIENT_SECRET: (선택 사항) Principal/Identity의 클라이언트 시크릿이에요.

  • AZURE_TENANT_ID: (선택 사항) Principal/Identity의 테넌트 ID예요.

플러그인 설정

글로벌

decK

다음 섹션을 kong.yaml 구성 파일에 추가하세요:

_format_version: "3.0"
plugins:
  - name: acme
    config:
      account_email: ${{ env "DECK_EMAIL" }}
      account_key:
        key_id: ${{ env "DECK_KEY_ID" }}
        key_set: ${{ env "DECK_KEY_SET" }}
      domains:
      - ${{ env "DECK_DOMAIN" }}
      tos_accepted: true
      storage: redis
      storage_config:
        redis:
          host: ${{ env "DECK_INSTANCE_ADDRESS" }}
          username: ${{ env "DECK_INSTANCE_USERNAME" }}
          port: 10000
          cloud_authentication:
            auth_provider: azure
            azure_client_id: ${{ env "DECK_AZURE_CLIENT_ID" }}
            azure_client_secret: ${{ env "DECK_AZURE_CLIENT_SECRET" }}
            azure_tenant_id: ${{ env "DECK_AZURE_TENANT_ID" }}

{: data-file="kong.yaml" data-tool="deck" }

Admin API

다음 요청을 보내세요:

curl -i -X POST http://localhost:8001/plugins/ \
    --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --data '
    {
      "name": "acme",
      "config": {
        "account_email": "'$EMAIL'",
        "account_key": {
          "key_id": "'$KEY_ID'",
          "key_set": "'$KEY_SET'"
        },
        "domains": [
          "'$DOMAIN'"
        ],
        "tos_accepted": true,
        "storage": "redis",
        "storage_config": {
          "redis": {
            "host": "'$INSTANCE_ADDRESS'",
            "username": "'$INSTANCE_USERNAME'",
            "port": 10000,
            "cloud_authentication": {
              "auth_provider": "azure",
              "azure_client_id": "'$AZURE_CLIENT_ID'",
              "azure_client_secret": "'$AZURE_CLIENT_SECRET'",
              "azure_tenant_id": "'$AZURE_TENANT_ID'"
            }
          }
        }
      }
    }
    '
Konnect API

다음 요청을 보내세요:

curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/plugins/ \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $KONNECT_TOKEN" \
    --data '
    {
      "name": "acme",
      "config": {
        "account_email": "'$EMAIL'",
        "account_key": {
          "key_id": "'$KEY_ID'",
          "key_set": "'$KEY_SET'"
        },
        "domains": [
          "'$DOMAIN'"
        ],
        "tos_accepted": true,
        "storage": "redis",
        "storage_config": {
          "redis": {
            "host": "'$INSTANCE_ADDRESS'",
            "username": "'$INSTANCE_USERNAME'",
            "port": 10000,
            "cloud_authentication": {
              "auth_provider": "azure",
              "azure_client_id": "'$AZURE_CLIENT_ID'",
              "azure_client_secret": "'$AZURE_CLIENT_SECRET'",
              "azure_tenant_id": "'$AZURE_TENANT_ID'"
            }
          }
        }
      }
    }
    '

다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:

  • region: Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요.

  • KONNECT_TOKEN: Konnect 계정에 연결된 개인 액세스 토큰(PAT)이에요.

  • controlPlaneId: 컨트롤 플레인의 id예요.

지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스를 확인하세요.

KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
  name:
  namespace: kong
  annotations:
    kubernetes.io/ingress.class: kong
  labels:
    global: 'true'
config:
  account_email: '$EMAIL'
  account_key:
    key_id: '$KEY_ID'
    key_set: '$KEY_SET'
  domains:
  - '$DOMAIN'
  tos_accepted: true
  storage: redis
  storage_config:
    redis:
      host: '$INSTANCE_ADDRESS'
      username: '$INSTANCE_USERNAME'
      port: 10000
      cloud_authentication:
        auth_provider: azure
        azure_client_id: '$AZURE_CLIENT_ID'
        azure_client_secret: '$AZURE_CLIENT_SECRET'
        azure_tenant_id: '$AZURE_TENANT_ID'
plugin: acme
" | kubectl apply -f -
Terraform
사전 준비: 개인 액세스 토큰 구성
terraform {
  required_providers {
    konnect = {
      source  = "kong/konnect"
    }
  }
}

provider "konnect" {
  personal_access_token = "$KONNECT_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}

Konnect Gateway Plugin을 생성하려면 Terraform 구성에 다음을 추가하세요:

resource "konnect_gateway_plugin_acme" "my_acme" {
  enabled = true

  config = {
    account_email = var.email

    account_key = {
      key_id = var.key_id
      key_set = var.key_set
    }
    domains = [var.domain]
    tos_accepted = true
    storage = "redis"

    storage_config = {

      redis = {
        host = var.instance_address
        username = var.instance_username
        port = 10000

        cloud_authentication = {
          auth_provider = "azure"
          azure_client_id = var.azure_client_id
          azure_client_secret = var.azure_client_secret
          azure_tenant_id = var.azure_tenant_id
        }
      }
    }
  }

  control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}

이 예제에서는 다음 변수를 매니페스트에 추가해야 해요. TF_VAR_name=value를 설정하면 런타임에 값을 지정할 수 있어요.

variable "email" {
  type = string
}
variable "key_id" {
  type = string
}
variable "key_set" {
  type = string
}
variable "domain" {
  type = string
}
variable "instance_address" {
  type = string
}
variable "instance_username" {
  type = string
}
variable "azure_client_id" {
  type = string
}
variable "azure_client_secret" {
  type = string
}
variable "azure_tenant_id" {
  type = string
}

관련 리소스

더 알아보기 (Learn more)

  • ACME 계정 키의 kid로 지정하는 Key 엔티티의 개념을 확인해 보세요 — Key
  • Key ID와 연결되는 Key Set 엔티티의 역할을 이해하는 데 도움이 돼요 — Key Set
  • decK로 플러그인을 구성할 때 작성하는 kong.yaml 설정 파일의 기본 사용법을 배워요 — kong.yaml
  • Konnect 환경에서 Control Plane 설정 API로 플러그인을 구성할 때 참고할 수 있는 레퍼런스예요 — Konnect Control Planes Config API reference
  • ngrok과 ACME 플러그인으로 로컬에서 인증서 발급을 테스트하는 실습 가이드예요 — Test certificate generation locally with ngrok and the ACME plugin