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

리소스 레이블링 및 태깅

원문 보기 위키 갱신

리소스 레이블링 및 태깅 (Labelling and Tagging resources)

태그와 레이블은 리소스를 정리하고 분류하는 데 활용하는 방법이에요. 이 문서에서는 Kong Operator가 관리하는 Konnect 엔티티에 엔티티별 지원 범위에 맞게 레이블과 태그를 지정하는 방법을 설명해요. 레이블은 키-값 쌍 형태로 현재는 KonnectGatewayControlPlane에 지정할 수 있고, 태그는 컨트롤 플레인에 연결되는 모든 Konnect 엔티티에 추가할 수 있어요

출처: 문서

본문

태그와 라벨은 리소스를 정리하고 분류하는 방법이에요. 이 문서에서는 각 엔티티의 지원 여부에 따라 Kong Operator가 관리하는 Konnect 엔티티에 태그와 라벨을 지정하는 방법을 설명해요.

라벨링

라벨은 특정 객체에 붙일 수 있는 키-값 쌍이에요. 현재 라벨을 지원하는 Konnect 엔티티는 KonnectGatewayControlPlane이 유일해요. spec 섹션에 labels 필드를 지정해서 KonnectGatewayControlPlane 객체에 라벨을 추가할 수 있어요.

echo '
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha2
metadata:
  name: gateway-control-plane
  namespace: default
spec:
  createControlPlaneRequest:
    labels: # Arbitrary key-value pairs
      environment: production
      team: devops
    name: gateway-control-plane
  konnect:
    authRef:
      name: konnect-api-auth # Reference to the KonnectAPIAuthConfiguration object
  ' | kubectl apply -f -

Programmed 조건을 확인해서 KonnectGatewayControlPlane이 성공적으로 조정됐는지 검증할 수 있어요.

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

출력은 다음과 비슷하게 보일 거예요:

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

{:.no-copy-code}

이 시점에서 라벨이 Konnect UI에 표시돼야 해요.

태깅

태그는 객체에 붙일 수 있는 값이에요. KonnectGatewayControlPlane 객체에 붙일 수 있는 모든 Kong Konnect 엔티티는 태깅을 지원해요. 해당 엔티티들의 spec 섹션에 tags 필드를 지정해서 태그를 추가할 수 있어요.

예를 들어, KongService 객체에 태그를 추가하려면 다음 YAML 매니페스트를 적용하면 돼요:

echo '
kind: KongService
apiVersion: configuration.konghq.com/v1alpha1
metadata:
  name: service
  namespace: default
spec:
  tags: # Arbitrary list of strings
    - production
    - devops
  name: service
  host: example.com
  controlPlaneRef:
    type: konnectNamespacedRef
    konnectNamespacedRef:
      name: gateway-control-plane # Reference to the KonnectGatewayControlPlane object
  ' | kubectl apply -f -

Programmed 조건을 확인해서 KongService가 성공적으로 조정됐는지 검증할 수 있어요.

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

출력은 다음과 비슷하게 보일 거예요:

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

{:.no-copy-code}

이 시점에서 태그가 Konnect UI에 표시돼야 해요.

konghq.com/tags 어노테이션

또는 konghq.com/tags 어노테이션을 사용해서 태깅을 지원하는 모든 Kong Konnect 엔티티에 태그를 추가할 수도 있어요.

이 어노테이션의 값은 쉼표로 구분된 태그 목록으로 처리돼요.

예를 들어, konghq.com/tags 어노테이션을 사용해서 KongService 객체에 태그를 추가하려면 다음 YAML 매니페스트를 적용하면 돼요:

echo '
kind: KongService
apiVersion: configuration.konghq.com/v1alpha1
metadata:
  name: service
  namespace: default
  annotations:
    konghq.com/tags: "production,devops" # Arbitrary list of strings as comma-separated values
spec:
  name: service
  host: example.com
  controlPlaneRef:
    type: konnectNamespacedRef
    konnectNamespacedRef:
      name: gateway-control-plane # Reference to the KonnectGatewayControlPlane object
  ' | kubectl apply -f -

더 알아보기 (Learn more)