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

서비스와 라우트 생성

원문 보기 위키 갱신

서비스와 라우트 생성 (Create a Service and Route)

이 문서에서는 Kong Operator(KGO)를 사용해서 Konnect에 서비스와 라우트를 만드는 방법을 안내해요. Kubernetes 클러스터에 KongService와 KongRoute를 정의하면 Konnect에 게이트웨이 엔티티가 프로비저닝되고 설정돼요. Konnect 인증 설정과 컨트롤 플레인 생성 같은 사전 준비부터 서비스·라우트 생성, 검증까지 단계별로 따라 하며 배워요

출처: 문서

본문

TL;DR

KGO를 사용해서 Konnect용 Service와 Route는 어떻게 만들 수 있어요? Kubernetes 클러스터에 KongService와 KongRoute를 정의하면 Konnect에서 Gateway 엔티티를 프로비저닝하고 구성할 수 있어요.

사전 준비

Kong Konnect

Konnect 계정이 아직 없다면 온보딩 마법사를 통해 빠르게 시작할 수 있어요.

  1. 이 튜토리얼을 완료하려면 다음의 Konnect 항목들이 필요해요:

    • 개인 액세스 토큰(PAT): Konnect PAT 페이지를 열고 Generate Token을 선택해서 새 개인 액세스 토큰을 만드세요.
  2. 개인 액세스 토큰을 환경 변수로 설정하세요:

    export KONNECT_TOKEN='YOUR KONNECT TOKEN'
    

Kong Operator 실행

  1. Kong Helm 차트를 추가하세요:

    helm repo add kong https://charts.konghq.com
    helm repo update
    
  2. Helm으로 Kong Operator를 설치하세요:

    helm upgrade --install kong-operator kong/kong-operator -n kong-system \
      --create-namespace \
      --set image.tag=2.3 \
      --set env.ENABLE_CONTROLLER_KONNECT=true
    

    cert-manager가 어드미션 및 컨버전 웹훅 인증서를 발급하고 갱신하도록 하려면 클러스터에 cert-manager를 설치하고, 다음 단계에서 설치할 때 아래 인자를 전달해서 cert-manager 통합을 활성화하세요:

    --set global.webhooks.options.certManager.enabled=true
    

    이 옵션을 활성화하지 않으면 차트가 자동으로 자체 서명된 인증서를 생성해 주입해요. 이 인증서들의 수명 주기를 관리하려면 cert-manager를 활성화하는 걸 추천해요. Kong Operator는 컨트롤 플레인과 데이터 플레인 간 mTLS 통신용 인증서에 서명해 줄 인증 기관(CA)이 필요해요. 이 부분은 Helm 차트가 자동으로 처리해요. 커스텀 CA 인증서를 제공해야 한다면 Helm 차트의 values.yaml에 있는 certificateAuthority 섹션을 참고해서 자체 CA 인증서를 만들고 참조하는 방법을 확인하세요.

KonnectAPIAuthConfiguration 리소스 만들기

kubectl create namespace kong --dry-run=client -o yaml | kubectl apply -f -
echo '
kind: KonnectAPIAuthConfiguration
apiVersion: konnect.konghq.com/v1alpha1
metadata:
  name: konnect-api-auth
  namespace: kong
spec:
  type: token
  token: "'$KONNECT_TOKEN'"
  serverURL: us.api.konghq.com
' | kubectl apply -f -

KonnectGatewayControlPlane 리소스 만들기

echo '
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha2
metadata:
  name: gateway-control-plane
  namespace: kong
spec:
  createControlPlaneRequest:
    name: gateway-control-plane
  konnect:
    authRef:
      name: konnect-api-auth
' | kubectl apply -f -

KongService 만들기

Konnect에 Gateway Service를 만드세요. Service는 기존 KonnectGatewayControlPlane을 참조해야 해요.

echo '
kind: KongService
apiVersion: configuration.konghq.com/v1alpha1
metadata:
  name: service
  namespace: kong
spec:
  name: service
  host: example.com
  controlPlaneRef:
    type: konnectNamespacedRef
    konnectNamespacedRef:
      name: gateway-control-plane
' | kubectl apply -f -

KongRoute 만들기

Service를 노출하려면, 위에서 정의한 KongService에 연결되는 KongRoute를 만드세요.

echo '
kind: KongRoute
apiVersion: configuration.konghq.com/v1alpha1
metadata:
  name: route-with-service
  namespace: kong
spec:
  name: route-with-service
  protocols:
  - http
  hosts:
  - example.com
  serviceRef:
    type: namespacedRef
    namespacedRef:
      name: service
' | kubectl apply -f -

검증

Programmed 조건을 확인하면 KongService가 성공적으로 리컨실(reconcile)됐는지 검증할 수 있어요.

kubectl get -n kong kongservice service \
  -o=jsonpath='{.status.conditions[?(@.type=="Programmed")]}' | jq

출력은 다음과 비슷하게 나타나요:

{
  "observedGeneration": 1,
  "reason": "Programmed",
  "status": "True",
  "type": "Programmed"
}

{:.no-copy-code}

더 알아보기 (Learn more)

  • Konnect 계정이 없다면 온보딩 마법사로 빠르게 가입하고 시작할 수 있어요 — onboarding wizard
  • 튜토리얼에 필요한 Konnect 개인 액세스 토큰(PAT)은 이 페이지에서 직접 발급할 수 있어요 — Konnect PAT page