|
| 1 | +--- |
| 2 | +title: "Cross namespace references" |
| 3 | +description: "How do I use cross namespace references with {{ site.operator_product_name }}?" |
| 4 | +content_type: reference |
| 5 | +layout: reference |
| 6 | +products: |
| 7 | + - operator |
| 8 | +breadcrumbs: |
| 9 | + - /operator/ |
| 10 | + - index: operator |
| 11 | + group: Konnect |
| 12 | + - index: operator |
| 13 | + group: Konnect |
| 14 | + section: Key Concepts |
| 15 | + |
| 16 | +min_version: |
| 17 | + operator: '2.1' |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +{{ site.operator_product_name }} supports cross namespace references for certain resources. |
| 22 | +This allows you to reference resources that are located in different namespaces than the resource that is referencing them. |
| 23 | + |
| 24 | +## ControlPlane configuration {% new_in 2.1 %} |
| 25 | + |
| 26 | +When configuring a `KonnectGatewayControlPlane`, you can reference it from entities defined ain a different namespace. |
| 27 | + |
| 28 | +This reference can be done via the `spec.controlPlaneRef.konnectNamespacedRef.namespace` field, by specifying the `namespace` of the `KonnectGatewayControlPlane` resource. |
| 29 | + |
| 30 | +```yaml |
| 31 | +apiVersion: configuration.konghq.com/{{ site.operator_kongservice_api_version }} |
| 32 | +kind: KongService |
| 33 | +metadata: |
| 34 | + name: my-service |
| 35 | + namespace: default |
| 36 | +spec: |
| 37 | + name: service-1 |
| 38 | + host: example.com |
| 39 | + controlPlaneRef: |
| 40 | + type: konnectNamespacedRef |
| 41 | + konnectNamespacedRef: |
| 42 | + name: my-control-plane |
| 43 | + namespace: kong |
| 44 | +``` |
| 45 | +
|
| 46 | +In order to protect cross namespace references, the `KonnectGatewayControlPlane` resource must explicitly allow references from other namespaces by specifying `KongReferenceGrant` resources. |
| 47 | + |
| 48 | +```yaml |
| 49 | +apiVersion: configuration.konghq.com/{{ site.operator_kongreferencegrant_api_version }} |
| 50 | +kind: KongReferenceGrant |
| 51 | +metadata: |
| 52 | + name: allow-kongservice-to-konnectgatewaycontrolplane |
| 53 | + namespace: kong |
| 54 | +spec: |
| 55 | + from: |
| 56 | + - group: configuration.konghq.com |
| 57 | + kind: KongService |
| 58 | + namespace: default |
| 59 | + to: |
| 60 | + - group: konnect.konghq.com |
| 61 | + kind: KonnectGatewayControlPlane |
| 62 | + # Optionally specify a specific KonnectGatewayControlPlane name to allow |
| 63 | + # only this specific resource to be referenced. |
| 64 | + # name: my-control-plane |
| 65 | +``` |
| 66 | + |
| 67 | +## Troubleshooting |
| 68 | + |
| 69 | +If you're having issues with cross namespace references, you can always check your |
| 70 | +object's status conditions - specifically the `ResolvedRefs` condition - for more information: |
| 71 | + |
| 72 | +```bash |
| 73 | +kg kongservice -n kong service-1 -o jsonpath-as-json="{ .status.conditions[?(@.type=='ResolvedRefs')]}" |
| 74 | +``` |
| 75 | + |
| 76 | +```json |
| 77 | +[ |
| 78 | + { |
| 79 | + "lastTransitionTime": "2025-12-19T15:18:07Z", |
| 80 | + "message": "KongReferenceGrant default/my-control-plane does not allow access to KonnectGatewayControlPlane <konnectNamespacedRef:default/my-control-plane>", |
| 81 | + "observedGeneration": 2, |
| 82 | + "reason": "RefNotPermitted", |
| 83 | + "status": "False", |
| 84 | + "type": "ResolvedRefs" |
| 85 | + } |
| 86 | +] |
| 87 | +``` |
0 commit comments