크로스 네임스페이스 참조
크로스 네임스페이스 참조 (Cross namespace references)
Kong Operator는 일부 리소스에서 다른 네임스페이스에 있는 리소스를 참조할 수 있는 크로스 네임스페이스 참조 기능을 지원해요. 이 문서에서는 ControlPlane, 인증서, KongPlugin, KongRoute, Konnect 인증, Vault Config Store 설정처럼 리소스별로 네임스페이스를 넘어 참조하는 방법을 YAML 예시와 함께 소개해요. 참조를 안전하게 보호하려면 대상 리소스에 KongReferenceGrant로 허용을 명시해야 한다는 점과, 참조가 막혔을 때 문제를 해결하는 방법까지 짚어줘요
출처: 문서
본문
이를 통해 참조하는 리소스와 다른 네임스페이스에 위치한 리소스를 참조할 수 있어요.
ControlPlane 구성 v2.1+
KonnectGatewayControlPlane을 구성할 때, 다른 네임스페이스에 정의된 엔티티에서 이를 참조할 수 있어요.
이 참조는 spec.controlPlaneRef.konnectNamespacedRef.namespace 필드를 통해, KonnectGatewayControlPlane 리소스의 namespace를 지정해서 수행할 수 있어요.
apiVersion: configuration.konghq.com/v1alpha1
kind: KongService
metadata:
name: my-service
namespace: default
spec:
name: service-1
host: example.com
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: my-control-plane
namespace: kong
크로스 네임스페이스 참조를 보호하기 위해, KonnectGatewayControlPlane 리소스는 KongReferenceGrant 리소스를 지정해서 다른 네임스페이스에서 오는 참조를 명시적으로 허용해야 해요.
apiVersion: configuration.konghq.com/v1alpha1
kind: KongReferenceGrant
metadata:
name: allow-kongservice-to-konnectgatewaycontrolplane
namespace: kong
spec:
from:
- group: configuration.konghq.com
kind: KongService
namespace: default
to:
- group: konnect.konghq.com
kind: KonnectGatewayControlPlane
# Optionally specify a specific KonnectGatewayControlPlane name to allow
# only this specific resource to be referenced.
# name: my-control-plane
Certificate 구성 v2.1+
KongCertificate과 KongCACertificate 객체를 구성할 때, 다른 네임스페이스에 있는 실제 인증서 데이터를 담고 있는 Secret 리소스를 참조할 수 있어요.
spec.secretRef.namespace 및 spec.secretRefAlt.namespace 필드를 사용해서, Secret 리소스의 namespace를 지정하면 돼요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongCertificate
metadata:
name: dual-cert-cross-namespace
namespace: default
spec:
type: secretRef
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: my-control-plane
# Primary certificate (RSA) - cross-namespace reference
secretRef:
name: rsa-tls-secret
namespace: tls-secrets-namespace
# Alternative certificate (ECDSA) - cross-namespace reference
secretRefAlt:
name: ecdsa-tls-secret
namespace: tls-secrets-namespace
크로스 네임스페이스 참조를 보호하기 위해, Secret 리소스는 KongReferenceGrant 리소스를 사용해서 다른 네임스페이스에서 오는 참조를 명시적으로 허용해야 해요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongReferenceGrant
metadata:
name: allow-kongcertificate-to-secret
namespace: tls-secrets-namespace
spec:
from:
- group: configuration.konghq.com
kind: KongCertificate
namespace: default
to:
- group: core
kind: Secret
# Optionally specify a specific Secret name to allow
# only this specific resource to be referenced.
# name: my-secret-name
KongPlugin 구성 v2.1+
기존 KongPlugin에 타깃을 바인딩하기 위해 KongPluginBinding을 구성할 때, 다른 네임스페이스에 있는 KongPlugin 리소스를 참조할 수 있어요.
spec.pluginRef.namespace 필드를 사용해서, KongPlugin 리소스의 namespace를 지정하면 돼요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongPluginBinding
metadata:
name: plugin-binding-kongservice
namespace: default
spec:
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: demo-cp
pluginRef:
name: rate-limit-5-min
namespace: ns-plugin
targets:
serviceRef:
name: service-1
kind: KongService
group: configuration.konghq.com
크로스 네임스페이스 참조를 보호하기 위해, KongPlugin 리소스는 KongReferenceGrant 리소스를 사용해서 다른 네임스페이스에서 오는 참조를 명시적으로 허용해야 해요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongReferenceGrant
metadata:
name: allow-kongpluginbinding-to-kongplugin
namespace: ns-plugin
spec:
from:
- group: configuration.konghq.com
kind: KongPluginBinding
namespace: default
to:
- group: configuration.konghq.com
kind: KongPlugin
# Optionally specify a specific KongPlugin name to allow
# only this specific resource to be referenced.
# name: my-plugin-name
KongRoute 구성 v2.1+
KongService에 바인딩하기 위해 KongRoute를 구성할 때, 다른 네임스페이스에 있는 KongService를 참조할 수 있어요.
spec.serviceRef.namespacedRef.namespace 필드를 사용해서, KongService 리소스의 namespace를 지정하면 돼요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongRoute
metadata:
name: my-route
namespace: default
spec:
name: route-1
protocols:
- http
hosts:
- example.com
serviceRef:
type: namespacedRef
namespacedRef:
name: my-service-name
namespace: service-namespace
크로스 네임스페이스 참조를 보호하기 위해, KongPlugin 리소스는 KongReferenceGrant 리소스를 사용해서 다른 네임스페이스에서 오는 참조를 명시적으로 허용해야 해요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongReferenceGrant
metadata:
name: allow-kongroute-to-kongservice
namespace: service-namespace
spec:
from:
- group: configuration.konghq.com
kind: KongRoute
namespace: default
to:
- group: configuration.konghq.com
kind: KongService
# Optionally specify a specific KongService name to allow
# only this specific resource to be referenced.
# name: my-service-name
Konnect 인증 구성 v2.3+
spec.type: secretRef로 KonnectAPIAuthConfiguration을 구성할 때, 다른 네임스페이스에 있는 Konnect 토큰을 담고 있는 Secret을 참조할 수 있어요.
spec.secretRef.namespace 필드를 사용해서, Secret 리소스의 namespace를 지정하면 돼요:
apiVersion: konnect.konghq.com/v1alpha1
kind: KonnectAPIAuthConfiguration
metadata:
name: konnect-api-auth
namespace: default
spec:
type: secretRef
secretRef:
name: konnect-api-auth-secret
namespace: auth
serverURL: us.api.konghq.com
크로스 네임스페이스 참조를 보호하기 위해, Secret 리소스는 KongReferenceGrant 리소스를 사용해서 다른 네임스페이스에서 오는 참조를 명시적으로 허용해야 해요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongReferenceGrant
metadata:
name: allow-konnectapiauthconfiguration-to-secret
namespace: auth
spec:
from:
- group: konnect.konghq.com
kind: KonnectAPIAuthConfiguration
namespace: default
to:
- group: core
kind: Secret
# Optionally specify a specific Secret name to allow
# only this specific resource to be referenced.
# name: konnect-api-auth-secret
유효한 grant가 없으면, KonnectAPIAuthConfiguration은 reason RefNotPermitted와 함께 ResolvedRefs=False 및 APIAuthValid=False를 보고해요. 참조를 허용하는 KongReferenceGrant가 생성되면 객체가 리컨실되고 참조가 유효해져요.
Vault Config Store 구성 v2.3+
spec.backend: konnect로 KongVault를 구성할 때, Konnect Config Store ID를 spec.config.config_store_id에 복사하는 대신, Vault를 뒷받침하는 KonnectConfigStore를 참조할 수 있어요.
spec.configStoreRef 필드를 사용하면 돼요. KongVault는 클러스터 범위(cluster-scoped)이고 KonnectConfigStore는 네임스페이스 범위(namespaced)이기 때문에, spec.configStoreRef.namespace가 필수이며 참조는 항상 네임스페이스 경계를 넘어요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongVault
metadata:
name: certvault
spec:
backend: konnect
prefix: certvault
configStoreRef:
kind: KonnectConfigStore
name: cert-keys
namespace: kong
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: my-control-plane
namespace: kong
크로스 네임스페이스 참조를 보호하기 위해, KonnectConfigStore 리소스는 KongReferenceGrant 리소스를 사용해서 다른 네임스페이스에서 오는 참조를 명시적으로 허용해야 해요. KongVault는 클러스터 범위(cluster-scoped)이고 자체 네임스페이스가 없기 때문에, from 항목은 namespace: \"\"로 설정해야 해요:
apiVersion: configuration.konghq.com/v1alpha1
kind: KongReferenceGrant
metadata:
name: allow-kongvault-to-konnect-config-store
namespace: kong
spec:
from:
- group: configuration.konghq.com
kind: KongVault
namespace: ""
to:
- group: konnect.konghq.com
kind: KonnectConfigStore
# Optionally specify a specific KonnectConfigStore name to allow
# only this specific resource to be referenced.
# name: cert-keys
유효한 grant가 없으면, KongVault는 reason RefNotPermitted와 함께 ConfigStoreRefValid=False를 보고하며 Konnect로 푸시되지 않아요. 그래서 Config Store ID가 누락된 채로 Vault가 생성되는 일은 없어요. KongVault가 프로그래밍된 후에 grant가 제거되면, 이후 업데이트는 중단되지만 Konnect에 이미 존재하는 Vault는 롤백되거나 제거되지 않아요.
거부는 이 리소스에서 컨트롤 플레인 참조가 이미 사용하고 있는 ResolvedRefs가 아니라 ConfigStoreRefValid에 보고돼요.
문제 해결
크로스 네임스페이스 참조에 문제가 있다면, 더 자세한 정보를 위해 객체의 상태 조건(status conditions), 특히 ResolvedRefs 조건을 언제든 확인할 수 있어요:
kg kongservice -n kong service-1 -o jsonpath-as-json="{ .status.conditions[?(@.type=='ResolvedRefs')]}"
[
{
"lastTransitionTime": "2025-12-19T15:18:07Z",
"message": "KongReferenceGrant default/my-control-plane does not allow access to KonnectGatewayControlPlane <konnectNamespacedRef:default/my-control-plane>",
"observedGeneration": 2,
"reason": "RefNotPermitted",
"status": "False",
"type": "ResolvedRefs"
}
]
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.