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

스키마 레지스트리

원문 보기 위키 갱신

스키마 레지스트리 (Schema registry)

스키마 레지스트리는 스키마 검증 정책에서 메시지를 검증할 때 사용하는 리소스예요. Avro와 JSON Schema 유형을 지원하고, Konnect API, Terraform, kongctl, UI를 통해 설정할 수 있어요. 이 문서에서는 스키마 레지스트리의 개념과 설정 방법을 설명해요.

출처: 문서

본문

스키마 레지스트리란 무엇인가요?

스키마 레지스트리는 Schema Validation 정책에서 Confluent 스키마 레지스트리에 대해 메시지를 검증하는 데 사용할 수 있는 리소스예요.

Event Gateway는 다음 레지스트리 유형을 지원해요:

  • Avro
  • JSON Schema

스키마 레지스트리 설정하기

Konnect API

스키마 레지스트리를 생성하려면 Event Gateway API의 /schema-registries 엔드포인트를 호출하세요.

curl -X POST https://{region}.api.konghq.com/v1/event-gateways/{eventGatewayId}/schema-registries \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $KONNECT_TOKEN" \
    --data '
    {
      "name": "my-schema-registry",
      "type": "confluent",
      "config": {
        "schema_type": "avro",
        "endpoint": "endpoint",
        "timeout_seconds": 10,
        "authentication": {
          "type": "basic",
          "username": "username",
          "password": "'$MY_PASSWORD'"
        }
      }
    }
    '

꼭 다음 플레이스홀더를 자신의 값으로 바꾸세요:

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

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

  • virtualClusterId: Virtual Cluster의 id예요.

  • eventGatewayId: Event Gateway의 id예요.

  • eventGatewayListenerId: Event Gateway Listener의 id예요.

리전별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Event Gateway API 참조를 확인하세요.

Terraform

사전 요구 사항: 개인 액세스 토큰 설정하기
terraform {
  required_providers {
    konnect-beta = {
      source  = "kong/konnect-beta"
    }
  }
}

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

다음을 Terraform 구성에 추가하세요:

resource "konnect_event_gateway_schema_registry" "my_schema_registry" {
  provider = konnect-beta
  type = "confluent"
  config = {
    schema_type = "avro"
    endpoint = "endpoint"
    timeout_seconds = 10

    authentication = {
      type = "basic"
      username = "username"
      password = "$MY_PASSWORD"
    }
  }



  gateway_id = konnect_event_gateway.my_event_gateway.id
}

kongctl

다음은 my-schema-registry라는 새 스키마 레지스트리를 생성해요.

event_gateways:
  - ref: eventGatewayName
    name: eventGatewayName
    schema_registries:
    - ref: my-schema-registry
      name: my-schema-registry
      type: confluent
      config:
        schema_type: avro
        endpoint: endpoint
        timeout_seconds: 10
        authentication:
          type: basic
          username: username
          password: !env MY_PASSWORD

{: data-file="schema_registry.yaml" data-tool="kongctl" }

꼭 다음 플레이스홀더를 자신의 값으로 바꾸세요:

  • eventGatewayName: Event Gateway의 name이에요.

UI

다음은 기본 구성으로 my-schema-registry라는 새 스키마 레지스트리를 생성해요.

  1. Konnect에서 사이드바의 Event Gateway로 이동하세요.
  2. Event Gateway를 클릭하세요.
  3. Resources 탭을 클릭하세요.
  4. New Schema Registry를 클릭하세요.
  5. Name 필드에 my-schema-registry를 입력하세요.
  6. 스키마 레지스트리를 구성하세요.
  7. Create를 클릭하세요.

스키마

{
  "description": "A schema registry that contains schemas.",
  "type": "object",
  "properties": {
    "name": {
      "description": "The unique name of the schema registry.",
      "type": "string",
      "maxLength": 255,
      "minLength": 1,
      "x-unicode-pattern": "^[\\p{L}\\p{N}][\\p{L}\\p{N} _\\-\\.:/+']*[\\p{L}\\p{N}]$"
    },
    "description": {
      "description": "A human-readable description of the virtual cluster.",
      "type": "string",
      "default": "",
      "maxLength": 512
    },
    "type": {
      "description": "The type of the schema registry.",
      "type": "string"
    },
    "config": {
      "description": "The configuration of the schema registry.",
      "type": "object"
    },
    "labels": {
      "$ref": "#/components/schemas/Labels"
    },
    "id": {
      "description": "The unique identifier of the schema registry.",
      "type": "string",
      "format": "uuid"
    },
    "created_at": {
      "$ref": "#/components/schemas/CreatedAt"
    },
    "updated_at": {
      "$ref": "#/components/schemas/UpdatedAt"
    }
  },
  "required": [
    "name",
    "type",
    "id",
    "created_at",
    "updated_at"
  ]
}

관련 리소스

더 알아보기 (Learn more)