Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contour #2

Merged
merged 20 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions api/v1beta1/kafkacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type KafkaClusterSpec struct {
RollingUpgradeConfig RollingUpgradeConfig `json:"rollingUpgradeConfig"`
// Selector for broker pods that need to be recycled/reconciled
TaintedBrokersSelector *metav1.LabelSelector `json:"taintedBrokersSelector,omitempty"`
// +kubebuilder:validation:Enum=envoy;istioingress
// +kubebuilder:validation:Enum=envoy;contour;istioingress
// 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.
IngressController string `json:"ingressController,omitempty"`
// IstioControlPlane is a reference to the IstioControlPlane resource for envoy configuration. It must be specified if istio ingress is used.
Expand All @@ -167,13 +167,14 @@ type KafkaClusterSpec struct {
// when false, they will be kept so the Kafka cluster remains available for those Kafka clients which are still using the previous ingress setting.
// +kubebuilder:default=false
// +optional
RemoveUnusedIngressResources bool `json:"removeUnusedIngressResources,omitempty"`
PropagateLabels bool `json:"propagateLabels,omitempty"`
CruiseControlConfig CruiseControlConfig `json:"cruiseControlConfig"`
EnvoyConfig EnvoyConfig `json:"envoyConfig,omitempty"`
MonitoringConfig MonitoringConfig `json:"monitoringConfig,omitempty"`
AlertManagerConfig *AlertManagerConfig `json:"alertManagerConfig,omitempty"`
IstioIngressConfig IstioIngressConfig `json:"istioIngressConfig,omitempty"`
RemoveUnusedIngressResources bool `json:"removeUnusedIngressResources,omitempty"`
PropagateLabels bool `json:"propagateLabels,omitempty"`
CruiseControlConfig CruiseControlConfig `json:"cruiseControlConfig"`
EnvoyConfig EnvoyConfig `json:"envoyConfig,omitempty"`
ContourIngressConfig ContourIngressConfig `json:"contourIngressConfig,omitempty"`
MonitoringConfig MonitoringConfig `json:"monitoringConfig,omitempty"`
AlertManagerConfig *AlertManagerConfig `json:"alertManagerConfig,omitempty"`
IstioIngressConfig IstioIngressConfig `json:"istioIngressConfig,omitempty"`
// Envs defines environment variables for Kafka broker Pods.
// Adding the "+" prefix to the name prepends the value to that environment variable instead of overwriting it.
// Add the "+" suffix to append.
Expand Down Expand Up @@ -593,6 +594,10 @@ func (c IngressServiceSettings) GetServiceType() corev1.ServiceType {
return c.ServiceType
}

func (c ContourIngressConfig) GetBrokerFqdn(brokerId int32) string {
return strings.Replace(c.BrokerFQDNTemplate, "%id", strconv.Itoa(int(brokerId)), 1)
}

// Replace %id in brokerHostnameTemplate with actual broker id
func (c EnvoyConfig) GetBrokerHostname(brokerId int32) string {
return strings.Replace(c.BrokerHostnameTemplate, "%id", strconv.Itoa(int(brokerId)), 1)
Expand Down Expand Up @@ -673,7 +678,7 @@ type ExternalListenerConfig struct {
// IngressControllerTargetPort defines the container port that the ingress controller uses for handling external traffic.
// If not defined, 29092 will be used as the default IngressControllerTargetPort value.
IngressControllerTargetPort *int32 `json:"ingressControllerTargetPort,omitempty"`
// +kubebuilder:validation:Enum=LoadBalancer;NodePort
// +kubebuilder:validation:Enum=LoadBalancer;NodePort;ClusterIP
// accessMethod defines the method which the external listener is exposed through.
// Two types are supported LoadBalancer and NodePort.
// The recommended and default is the LoadBalancer.
Expand All @@ -696,8 +701,16 @@ type Config struct {

type IngressConfig struct {
IngressServiceSettings `json:",inline"`
IstioIngressConfig *IstioIngressConfig `json:"istioIngressConfig,omitempty"`
EnvoyConfig *EnvoyConfig `json:"envoyConfig,omitempty"`
IstioIngressConfig *IstioIngressConfig `json:"istioIngressConfig,omitempty"`
EnvoyConfig *EnvoyConfig `json:"envoyConfig,omitempty"`
ContourIngressConfig *ContourIngressConfig `json:"contourIngressConfig,omitempty"`
}

type ContourIngressConfig struct {
// TLS secret used for Contour IngressRoute resource
TLSSecretName string `json:"tlsSecretName"`
// Broker hostname template for Contour IngressRoute resource to generate broker hostnames.
BrokerFQDNTemplate string `json:"brokerFQDNTemplate"`
}

// InternalListenerConfig defines the internal listener config for Kafka
Expand Down
21 changes: 21 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions charts/kafka-operator/crds/kafkaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12899,6 +12899,19 @@ spec:
type: string
clusterWideConfig:
type: string
contourIngressConfig:
properties:
brokerFQDNTemplate:
description: Broker hostname template for Contour IngressRoute
resource to generate broker hostnames.
type: string
tlsSecretName:
description: TLS secret used for Contour IngressRoute resource
type: string
required:
- brokerFQDNTemplate
- tlsSecretName
type: object
cruiseControlConfig:
description: CruiseControlConfig defines the config for Cruise Control
properties:
Expand Down Expand Up @@ -18817,6 +18830,7 @@ spec:
as well.
enum:
- envoy
- contour
- istioingress
type: string
istioControlPlane:
Expand Down Expand Up @@ -19171,6 +19185,7 @@ spec:
enum:
- LoadBalancer
- NodePort
- ClusterIP
type: string
anyCastPort:
description: configuring AnyCastPort allows kafka cluster
Expand All @@ -19190,6 +19205,21 @@ spec:
ingressConfig:
additionalProperties:
properties:
contourIngressConfig:
properties:
brokerFQDNTemplate:
description: Broker hostname template for
Contour IngressRoute resource to generate
broker hostnames.
type: string
tlsSecretName:
description: TLS secret used for Contour IngressRoute
resource
type: string
required:
- brokerFQDNTemplate
- tlsSecretName
type: object
envoyConfig:
description: EnvoyConfig defines the config for
Envoy
Expand Down
30 changes: 30 additions & 0 deletions config/base/crds/kafka.banzaicloud.io_kafkaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12899,6 +12899,19 @@ spec:
type: string
clusterWideConfig:
type: string
contourIngressConfig:
properties:
brokerFQDNTemplate:
description: Broker hostname template for Contour IngressRoute
resource to generate broker hostnames.
type: string
tlsSecretName:
description: TLS secret used for Contour IngressRoute resource
type: string
required:
- brokerFQDNTemplate
- tlsSecretName
type: object
cruiseControlConfig:
description: CruiseControlConfig defines the config for Cruise Control
properties:
Expand Down Expand Up @@ -18817,6 +18830,7 @@ spec:
as well.
enum:
- envoy
- contour
- istioingress
type: string
istioControlPlane:
Expand Down Expand Up @@ -19171,6 +19185,7 @@ spec:
enum:
- LoadBalancer
- NodePort
- ClusterIP
type: string
anyCastPort:
description: configuring AnyCastPort allows kafka cluster
Expand All @@ -19190,6 +19205,21 @@ spec:
ingressConfig:
additionalProperties:
properties:
contourIngressConfig:
properties:
brokerFQDNTemplate:
description: Broker hostname template for
Contour IngressRoute resource to generate
broker hostnames.
type: string
tlsSecretName:
description: TLS secret used for Contour IngressRoute
resource
type: string
required:
- brokerFQDNTemplate
- tlsSecretName
type: object
envoyConfig:
description: EnvoyConfig defines the config for
Envoy
Expand Down
Loading
Loading