Skip to content

Commit d5724af

Browse files
committed
feat(gateway): expose sectionName and port
Allow KamajiControlPlane.spec.network.gateway to target a specific listener of a multi-listener Gateway by exposing two optional fields: - sectionName: mapped to ParentReference.SectionName of the generated kube-apiserver TLSRoute; - port: mapped to ParentReference.Port of the generated TLSRoute. The TCP renderer propagates them onto the ParentReference when set. Both fields are optional, so existing KamajiControlPlane objects keep rendering unchanged. This should unblock Kamaji gateway access-points status publishing, which requires ParentReference.SectionName to resolve the Gateway listener when publishing status on multi-listener Gateways. Signed-off-by: Pierre Cheynier <p.cheynier@criteo.com>
1 parent 2cc43b8 commit d5724af

5 files changed

Lines changed: 72 additions & 7 deletions

api/v1alpha2/kamajicontrolplane_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ type GatewayComponent struct {
4545
// +kubebuilder:required
4646
// +kubebuilder:validation:MinLength=1
4747
Hostname string `json:"hostname"`
48+
// SectionName selects a specific listener on the target Gateway for the
49+
// kube-apiserver TLSRoute to attach to (mapped to ParentReference.SectionName
50+
// of the generated TLSRoute). Required when the Gateway exposes multiple
51+
// listeners: the upstream Kamaji controller needs it to resolve the
52+
// Gateway listener when publishing the kube-apiserver access point status.
53+
// +kubebuilder:validation:MinLength=1
54+
// +kubebuilder:validation:MaxLength=253
55+
SectionName string `json:"sectionName,omitempty"`
56+
// Port selects the listener port on the target Gateway (mapped to
57+
// ParentReference.Port of the generated TLSRoute). When unset, the first
58+
// listener of the Gateway that accepts the Route is used. When set together
59+
// with SectionName, both must match the target listener.
60+
// +kubebuilder:validation:Minimum=1
61+
// +kubebuilder:validation:Maximum=65535
62+
Port *int32 `json:"port,omitempty"`
4863
// Defines the extra labels for the Gateway object.
4964
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
5065
// Defines the extra annotations for the Gateway object.

api/v1alpha2/zz_generated.deepcopy.go

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

config/crd/bases/controlplane.cluster.x-k8s.io_kamajicontrolplanes.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7455,6 +7455,26 @@ spec:
74557455
object.
74567456
minLength: 1
74577457
type: string
7458+
port:
7459+
description: |-
7460+
Port selects the listener port on the target Gateway (mapped to
7461+
ParentReference.Port of the generated TLSRoute). When unset, the first
7462+
listener of the Gateway that accepts the Route is used. When set together
7463+
with SectionName, both must match the target listener.
7464+
format: int32
7465+
maximum: 65535
7466+
minimum: 1
7467+
type: integer
7468+
sectionName:
7469+
description: |-
7470+
SectionName selects a specific listener on the target Gateway for the
7471+
kube-apiserver TLSRoute to attach to (mapped to ParentReference.SectionName
7472+
of the generated TLSRoute). Required when the Gateway exposes multiple
7473+
listeners: the upstream Kamaji controller needs it to resolve the
7474+
Gateway listener when publishing the kube-apiserver access point status.
7475+
maxLength: 253
7476+
minLength: 1
7477+
type: string
74587478
required:
74597479
- hostname
74607480
- name

config/crd/bases/controlplane.cluster.x-k8s.io_kamajicontrolplanetemplates.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7547,6 +7547,26 @@ spec:
75477547
the Gateway object.
75487548
minLength: 1
75497549
type: string
7550+
port:
7551+
description: |-
7552+
Port selects the listener port on the target Gateway (mapped to
7553+
ParentReference.Port of the generated TLSRoute). When unset, the first
7554+
listener of the Gateway that accepts the Route is used. When set together
7555+
with SectionName, both must match the target listener.
7556+
format: int32
7557+
maximum: 65535
7558+
minimum: 1
7559+
type: integer
7560+
sectionName:
7561+
description: |-
7562+
SectionName selects a specific listener on the target Gateway for the
7563+
kube-apiserver TLSRoute to attach to (mapped to ParentReference.SectionName
7564+
of the generated TLSRoute). Required when the Gateway exposes multiple
7565+
listeners: the upstream Kamaji controller needs it to resolve the
7566+
Gateway listener when publishing the kube-apiserver access point status.
7567+
maxLength: 253
7568+
minLength: 1
7569+
type: string
75507570
required:
75517571
- hostname
75527572
- name

controllers/kamajicontrolplane_controller_tcp.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,19 @@ func (r *KamajiControlPlaneReconciler) createOrUpdateTenantControlPlane(ctx cont
173173
host = kcp.Spec.Network.Gateway.Hostname
174174
}
175175
tcp.Spec.NetworkProfile.CertSANs = append(tcp.Spec.NetworkProfile.CertSANs, host)
176+
parentRef := gatewayv1.ParentReference{
177+
Name: gatewayv1.ObjectName(kcp.Spec.Network.Gateway.Name),
178+
Namespace: ptr.To(gatewayv1.Namespace(kcp.Spec.Network.Gateway.Namespace)),
179+
}
180+
if sectionName := kcp.Spec.Network.Gateway.SectionName; sectionName != "" {
181+
parentRef.SectionName = ptr.To(gatewayv1.SectionName(sectionName))
182+
}
183+
if port := kcp.Spec.Network.Gateway.Port; port != nil {
184+
parentRef.Port = ptr.To(gatewayv1.PortNumber(*port))
185+
}
176186
tcp.Spec.ControlPlane.Gateway = &kamajiv1alpha1.GatewaySpec{
177-
Hostname: gatewayv1.Hostname(host),
178-
GatewayParentRefs: []gatewayv1.ParentReference{
179-
{
180-
Name: gatewayv1.ObjectName(kcp.Spec.Network.Gateway.Name),
181-
Namespace: ptr.To(gatewayv1.Namespace(kcp.Spec.Network.Gateway.Namespace)),
182-
},
183-
},
187+
Hostname: gatewayv1.Hostname(host),
188+
GatewayParentRefs: []gatewayv1.ParentReference{parentRef},
184189
AdditionalMetadata: kamajiv1alpha1.AdditionalMetadata{
185190
Labels: kcp.Spec.Network.Gateway.ExtraLabels,
186191
Annotations: kcp.Spec.Network.Gateway.ExtraAnnotations,

0 commit comments

Comments
 (0)