Skip to content

Commit b1e9544

Browse files
authored
Adding Contour Ingress support (#82)
1 parent 11b5e9a commit b1e9544

File tree

20 files changed

+9579
-58
lines changed

20 files changed

+9579
-58
lines changed

api/v1beta1/kafkacluster_types.go

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ type KafkaClusterSpec struct {
155155
RollingUpgradeConfig RollingUpgradeConfig `json:"rollingUpgradeConfig"`
156156
// Selector for broker pods that need to be recycled/reconciled
157157
TaintedBrokersSelector *metav1.LabelSelector `json:"taintedBrokersSelector,omitempty"`
158-
// +kubebuilder:validation:Enum=envoy;istioingress
158+
// +kubebuilder:validation:Enum=envoy;contour;istioingress
159159
// IngressController specifies the type of the ingress controller to be used for external listeners. The `istioingress` ingress controller type requires the `spec.istioControlPlane` field to be populated as well.
160160
IngressController string `json:"ingressController,omitempty"`
161161
// IstioControlPlane is a reference to the IstioControlPlane resource for envoy configuration. It must be specified if istio ingress is used.
@@ -167,13 +167,14 @@ type KafkaClusterSpec struct {
167167
// when false, they will be kept so the Kafka cluster remains available for those Kafka clients which are still using the previous ingress setting.
168168
// +kubebuilder:default=false
169169
// +optional
170-
RemoveUnusedIngressResources bool `json:"removeUnusedIngressResources,omitempty"`
171-
PropagateLabels bool `json:"propagateLabels,omitempty"`
172-
CruiseControlConfig CruiseControlConfig `json:"cruiseControlConfig"`
173-
EnvoyConfig EnvoyConfig `json:"envoyConfig,omitempty"`
174-
MonitoringConfig MonitoringConfig `json:"monitoringConfig,omitempty"`
175-
AlertManagerConfig *AlertManagerConfig `json:"alertManagerConfig,omitempty"`
176-
IstioIngressConfig IstioIngressConfig `json:"istioIngressConfig,omitempty"`
170+
RemoveUnusedIngressResources bool `json:"removeUnusedIngressResources,omitempty"`
171+
PropagateLabels bool `json:"propagateLabels,omitempty"`
172+
CruiseControlConfig CruiseControlConfig `json:"cruiseControlConfig"`
173+
EnvoyConfig EnvoyConfig `json:"envoyConfig,omitempty"`
174+
ContourIngressConfig ContourIngressConfig `json:"contourIngressConfig,omitempty"`
175+
MonitoringConfig MonitoringConfig `json:"monitoringConfig,omitempty"`
176+
AlertManagerConfig *AlertManagerConfig `json:"alertManagerConfig,omitempty"`
177+
IstioIngressConfig IstioIngressConfig `json:"istioIngressConfig,omitempty"`
177178
// Envs defines environment variables for Kafka broker Pods.
178179
// Adding the "+" prefix to the name prepends the value to that environment variable instead of overwriting it.
179180
// Add the "+" suffix to append.
@@ -593,6 +594,10 @@ func (c IngressServiceSettings) GetServiceType() corev1.ServiceType {
593594
return c.ServiceType
594595
}
595596

597+
func (c ContourIngressConfig) GetBrokerFqdn(brokerId int32) string {
598+
return strings.Replace(c.BrokerFQDNTemplate, "%id", strconv.Itoa(int(brokerId)), 1)
599+
}
600+
596601
// Replace %id in brokerHostnameTemplate with actual broker id
597602
func (c EnvoyConfig) GetBrokerHostname(brokerId int32) string {
598603
return strings.Replace(c.BrokerHostnameTemplate, "%id", strconv.Itoa(int(brokerId)), 1)
@@ -673,7 +678,7 @@ type ExternalListenerConfig struct {
673678
// IngressControllerTargetPort defines the container port that the ingress controller uses for handling external traffic.
674679
// If not defined, 29092 will be used as the default IngressControllerTargetPort value.
675680
IngressControllerTargetPort *int32 `json:"ingressControllerTargetPort,omitempty"`
676-
// +kubebuilder:validation:Enum=LoadBalancer;NodePort
681+
// +kubebuilder:validation:Enum=LoadBalancer;NodePort;ClusterIP
677682
// accessMethod defines the method which the external listener is exposed through.
678683
// Two types are supported LoadBalancer and NodePort.
679684
// The recommended and default is the LoadBalancer.
@@ -696,8 +701,16 @@ type Config struct {
696701

697702
type IngressConfig struct {
698703
IngressServiceSettings `json:",inline"`
699-
IstioIngressConfig *IstioIngressConfig `json:"istioIngressConfig,omitempty"`
700-
EnvoyConfig *EnvoyConfig `json:"envoyConfig,omitempty"`
704+
IstioIngressConfig *IstioIngressConfig `json:"istioIngressConfig,omitempty"`
705+
EnvoyConfig *EnvoyConfig `json:"envoyConfig,omitempty"`
706+
ContourIngressConfig *ContourIngressConfig `json:"contourIngressConfig,omitempty"`
707+
}
708+
709+
type ContourIngressConfig struct {
710+
// TLS secret used for Contour IngressRoute resource
711+
TLSSecretName string `json:"tlsSecretName"`
712+
// Broker hostname template for Contour IngressRoute resource to generate broker hostnames.
713+
BrokerFQDNTemplate string `json:"brokerFQDNTemplate"`
701714
}
702715

703716
// InternalListenerConfig defines the internal listener config for Kafka

api/v1beta1/zz_generated.deepcopy.go

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

charts/kafka-operator/crds/kafkaclusters.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12899,6 +12899,19 @@ spec:
1289912899
type: string
1290012900
clusterWideConfig:
1290112901
type: string
12902+
contourIngressConfig:
12903+
properties:
12904+
brokerFQDNTemplate:
12905+
description: Broker hostname template for Contour IngressRoute
12906+
resource to generate broker hostnames.
12907+
type: string
12908+
tlsSecretName:
12909+
description: TLS secret used for Contour IngressRoute resource
12910+
type: string
12911+
required:
12912+
- brokerFQDNTemplate
12913+
- tlsSecretName
12914+
type: object
1290212915
cruiseControlConfig:
1290312916
description: CruiseControlConfig defines the config for Cruise Control
1290412917
properties:
@@ -18817,6 +18830,7 @@ spec:
1881718830
as well.
1881818831
enum:
1881918832
- envoy
18833+
- contour
1882018834
- istioingress
1882118835
type: string
1882218836
istioControlPlane:
@@ -19171,6 +19185,7 @@ spec:
1917119185
enum:
1917219186
- LoadBalancer
1917319187
- NodePort
19188+
- ClusterIP
1917419189
type: string
1917519190
anyCastPort:
1917619191
description: configuring AnyCastPort allows kafka cluster
@@ -19190,6 +19205,21 @@ spec:
1919019205
ingressConfig:
1919119206
additionalProperties:
1919219207
properties:
19208+
contourIngressConfig:
19209+
properties:
19210+
brokerFQDNTemplate:
19211+
description: Broker hostname template for
19212+
Contour IngressRoute resource to generate
19213+
broker hostnames.
19214+
type: string
19215+
tlsSecretName:
19216+
description: TLS secret used for Contour IngressRoute
19217+
resource
19218+
type: string
19219+
required:
19220+
- brokerFQDNTemplate
19221+
- tlsSecretName
19222+
type: object
1919319223
envoyConfig:
1919419224
description: EnvoyConfig defines the config for
1919519225
Envoy

config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12899,6 +12899,19 @@ spec:
1289912899
type: string
1290012900
clusterWideConfig:
1290112901
type: string
12902+
contourIngressConfig:
12903+
properties:
12904+
brokerFQDNTemplate:
12905+
description: Broker hostname template for Contour IngressRoute
12906+
resource to generate broker hostnames.
12907+
type: string
12908+
tlsSecretName:
12909+
description: TLS secret used for Contour IngressRoute resource
12910+
type: string
12911+
required:
12912+
- brokerFQDNTemplate
12913+
- tlsSecretName
12914+
type: object
1290212915
cruiseControlConfig:
1290312916
description: CruiseControlConfig defines the config for Cruise Control
1290412917
properties:
@@ -18817,6 +18830,7 @@ spec:
1881718830
as well.
1881818831
enum:
1881918832
- envoy
18833+
- contour
1882018834
- istioingress
1882118835
type: string
1882218836
istioControlPlane:
@@ -19171,6 +19185,7 @@ spec:
1917119185
enum:
1917219186
- LoadBalancer
1917319187
- NodePort
19188+
- ClusterIP
1917419189
type: string
1917519190
anyCastPort:
1917619191
description: configuring AnyCastPort allows kafka cluster
@@ -19190,6 +19205,21 @@ spec:
1919019205
ingressConfig:
1919119206
additionalProperties:
1919219207
properties:
19208+
contourIngressConfig:
19209+
properties:
19210+
brokerFQDNTemplate:
19211+
description: Broker hostname template for
19212+
Contour IngressRoute resource to generate
19213+
broker hostnames.
19214+
type: string
19215+
tlsSecretName:
19216+
description: TLS secret used for Contour IngressRoute
19217+
resource
19218+
type: string
19219+
required:
19220+
- brokerFQDNTemplate
19221+
- tlsSecretName
19222+
type: object
1919319223
envoyConfig:
1919419224
description: EnvoyConfig defines the config for
1919519225
Envoy

0 commit comments

Comments
 (0)