Skip to content

Commit ca84e5b

Browse files
authored
KongCertificate->Secret x-namespace reference (#2904)
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
1 parent c01fbe8 commit ca84e5b

34 files changed

+646
-87
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@
7171
`KonnectGatewayControlPlane`.
7272
[#2892](https://github.com/Kong/kong-operator/pull/2892)
7373
[#2913](https://github.com/Kong/kong-operator/pull/2913)
74+
- Added support for cross namespace references between the following Konnect
75+
entities and `core` `Secret`
76+
77+
- `KongCertificate`
78+
- `KongCACertificate`
79+
80+
To allow these references, users need to define a `KongReferenceGrant` resource
81+
in the namespace of the referenced resource, allowing access to the
82+
`Secret`.
83+
[#2904](https://github.com/Kong/kong-operator/pull/2904)
7484
- Hybrid Gateway: The operator now supports configuring TLS termination on Gateway listeners
7585
in hybrid mode.When you define a TLS listener on a Gateway resource, the operator will
7686
automatically create the necessary KongCertificate and KongSNI resources to configure the data plane.

api/common/v1alpha1/objectref_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ type NamespacedRef struct {
6161
// +kubebuilder:validation:MaxLength=253
6262
Name string `json:"name,omitempty"`
6363

64-
// TODO: Implement cross namespace references:
65-
// https://github.com/Kong/kubernetes-configuration/issues/36
66-
6764
// Namespace is the namespace of the referred resource.
6865
//
6966
// For namespace-scoped resources if no Namespace is provided then the

api/configuration/v1alpha1/conditions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const (
55
// whether a KongReferenceGrant is valid for cross-namespace references.
66
KongReferenceGrantConditionTypeResolvedRefs = "ResolvedRefs"
77

8+
// KongReferenceGrantReasonResolvedRefs is the reason used when a valid
9+
// KongReferenceGrant is found and it permits for a cross-namespace reference.
10+
KongReferenceGrantReasonResolvedRefs = "ResolvedRefs"
811
// KongReferenceGrantReasonRefNotPermitted is the reason used when a KongReferenceGrant
912
// is invalid or missing for a cross-namespace reference.
1013
KongReferenceGrantReasonRefNotPermitted = "RefNotPermitted"
11-
// KongReferenceGrantReasonResolvedRefs is the reason used when a valid
12-
// KongReferenceGrant is found and it permits for a cross-namespace reference.
13-
KongReferenceGrantReasonResolvedRefs = "RefNotPermitted"
1414
)

api/configuration/v1alpha1/kongcacertificate_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type KongCACertificate struct {
4949
// +kubebuilder:validation:XValidation:rule="self.type != 'inline' || (has(self.cert) && self.cert.size() != 0)", message="spec.cert is required when type is 'inline'"
5050
// +kubebuilder:validation:XValidation:rule="self.type != 'secretRef' || has(self.secretRef)", message="spec.secretRef is required when type is 'secretRef'"
5151
// +kubebuilder:validation:XValidation:rule="!(has(self.cert) && has(self.secretRef))", message="cert and secretRef cannot be set at the same time"
52-
// +kubebuilder:validation:XValidation:rule="!has(self.secretRef) || !has(self.secretRef.__namespace__) || self.secretRef.__namespace__.size() == 0", message="spec.secretRef.namespace is not allowed until ReferenceGrant support is implemented"
5352
// +apireference:kgo:include
5453
type KongCACertificateSpec struct {
5554
// Type indicates the source of the CA certificate data.

api/configuration/v1alpha1/kongreferencegrant_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type KongReferenceGrantSpec struct {
9191

9292
// ReferenceGrantFrom describes trusted namespaces and kinds.
9393
//
94-
// +kubebuilder:validation:XValidation:rule=".self.group != 'configuration.konghq.com' || .self.kind in ['KongService', 'KongCertificate' ]",message="Only KongCertificate and KongService kinds are supported for 'configuration.konghq.com' group"
94+
// +kubebuilder:validation:XValidation:rule=".self.group != 'configuration.konghq.com' || .self.kind in ['KongService', 'KongCertificate', 'KongCACertificate' ]",message="Only KongCertificate, KongCACertificate, and KongService kinds are supported for 'configuration.konghq.com' group"
9595
type ReferenceGrantFrom struct {
9696
// Group is the group of the referent.
9797
//

api/konnect/v1alpha1/konnect_conditions.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ const (
137137
KongUpstreamRefReasonInvalid = "Invalid"
138138
)
139139

140+
const (
141+
// SecretRefValidConditionType is the type of the condition that indicates
142+
// whether the Secret reference is valid and points to an existing Secret.
143+
SecretRefValidConditionType = "SecretRefValid"
144+
// SecretRefReasonValid is the reason used with the SecretRefValid
145+
// condition type indicating that the Secret reference is valid.
146+
SecretRefReasonValid = "Valid"
147+
// SecretRefReasonInvalid is the reason used with the SecretRefValid
148+
// condition type indicating that the Secret reference is invalid.
149+
SecretRefReasonInvalid = "Invalid"
150+
)
151+
140152
const (
141153
// KeySetRefValidConditionType is the type of the condition that indicates
142154
// whether the KeySet reference is valid and points to an existing

charts/kong-operator/charts/ko-crds/templates/ko-crds.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49042,10 +49042,6 @@ spec:
4904249042
rule: self.type != 'secretRef' || has(self.secretRef)
4904349043
- message: cert and secretRef cannot be set at the same time
4904449044
rule: '!(has(self.cert) && has(self.secretRef))'
49045-
- message: spec.secretRef.namespace is not allowed until ReferenceGrant
49046-
support is implemented
49047-
rule: '!has(self.secretRef) || !has(self.secretRef.__namespace__) ||
49048-
self.secretRef.__namespace__.size() == 0'
4904949045
status:
4905049046
default:
4905149047
conditions:
@@ -54424,10 +54420,10 @@ spec:
5442454420
- namespace
5442554421
type: object
5442654422
x-kubernetes-validations:
54427-
- message: Only KongCertificate and KongService kinds are supported
54428-
for 'configuration.konghq.com' group
54423+
- message: Only KongCertificate, KongCACertificate, and KongService
54424+
kinds are supported for 'configuration.konghq.com' group
5442954425
rule: .self.group != 'configuration.konghq.com' || .self.kind
54430-
in ['KongService', 'KongCertificate' ]
54426+
in ['KongService', 'KongCertificate', 'KongCACertificate' ]
5443154427
maxItems: 16
5443254428
minItems: 1
5443354429
type: array

charts/kong-operator/ci/__snapshots__/affinity-values.snap

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/controlplane-config-dump.snap

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/kong-operator/ci/__snapshots__/disable-gateway-controller-values.snap

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)