Skip to content

Commit b3d45bc

Browse files
committed
added envoy gateway
1 parent bab7a1a commit b3d45bc

32 files changed

+13739
-63
lines changed

api/v1beta1/kafkacluster_types.go

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ type KafkaClusterSpec struct {
169169
RollingUpgradeConfig RollingUpgradeConfig `json:"rollingUpgradeConfig"`
170170
// Selector for broker pods that need to be recycled/reconciled
171171
TaintedBrokersSelector *metav1.LabelSelector `json:"taintedBrokersSelector,omitempty"`
172-
// +kubebuilder:validation:Enum=envoy;contour
172+
// +kubebuilder:validation:Enum=envoy;contour;envoygateway
173173
// IngressController specifies the type of the ingress controller to be used for external listeners.
174174
IngressController string `json:"ingressController,omitempty"`
175175
// If true OneBrokerPerNode ensures that each kafka broker will be placed on a different node unless a custom
@@ -179,13 +179,14 @@ type KafkaClusterSpec struct {
179179
// when false, they will be kept so the Kafka cluster remains available for those Kafka clients which are still using the previous ingress setting.
180180
// +kubebuilder:default=false
181181
// +optional
182-
RemoveUnusedIngressResources bool `json:"removeUnusedIngressResources,omitempty"`
183-
PropagateLabels bool `json:"propagateLabels,omitempty"`
184-
CruiseControlConfig CruiseControlConfig `json:"cruiseControlConfig"`
185-
EnvoyConfig EnvoyConfig `json:"envoyConfig,omitempty"`
186-
ContourIngressConfig ContourIngressConfig `json:"contourIngressConfig,omitempty"`
187-
MonitoringConfig MonitoringConfig `json:"monitoringConfig,omitempty"`
188-
AlertManagerConfig *AlertManagerConfig `json:"alertManagerConfig,omitempty"`
182+
RemoveUnusedIngressResources bool `json:"removeUnusedIngressResources,omitempty"`
183+
PropagateLabels bool `json:"propagateLabels,omitempty"`
184+
CruiseControlConfig CruiseControlConfig `json:"cruiseControlConfig"`
185+
EnvoyConfig EnvoyConfig `json:"envoyConfig,omitempty"`
186+
ContourIngressConfig ContourIngressConfig `json:"contourIngressConfig,omitempty"`
187+
EnvoyGatewayConfig EnvoyGatewayIngressConfig `json:"envoyGatewayConfig,omitempty"`
188+
MonitoringConfig MonitoringConfig `json:"monitoringConfig,omitempty"`
189+
AlertManagerConfig *AlertManagerConfig `json:"alertManagerConfig,omitempty"`
189190
// Envs defines environment variables for Kafka broker Pods.
190191
// Adding the "+" prefix to the name prepends the value to that environment variable instead of overwriting it.
191192
// Add the "+" suffix to append.
@@ -588,6 +589,24 @@ func (c EnvoyConfig) GetBrokerHostname(brokerId int32) string {
588589
return strings.Replace(c.BrokerHostnameTemplate, "%id", strconv.Itoa(int(brokerId)), 1)
589590
}
590591

592+
// GetBrokerHostname returns the broker hostname for the given broker ID
593+
func (c EnvoyGatewayIngressConfig) GetBrokerHostname(brokerId int32) string {
594+
return strings.Replace(c.BrokerHostnameTemplate, "%id", strconv.Itoa(int(brokerId)), 1)
595+
}
596+
597+
// GetGatewayClassName returns the GatewayClassName or default value
598+
func (c EnvoyGatewayIngressConfig) GetGatewayClassName() string {
599+
if c.GatewayClassName == "" {
600+
return "eg"
601+
}
602+
return c.GatewayClassName
603+
}
604+
605+
// GetAnnotations returns the annotations for the Gateway resource
606+
func (c EnvoyGatewayIngressConfig) GetAnnotations() map[string]string {
607+
return util.CloneMap(c.Annotations)
608+
}
609+
591610
// We use -1 for ExternalStartingPort value to enable TLS on envoy
592611
func (c ExternalListenerConfig) TLSEnabled() bool {
593612
return c.ExternalStartingPort == -1
@@ -686,8 +705,9 @@ type Config struct {
686705

687706
type IngressConfig struct {
688707
IngressServiceSettings `json:",inline"`
689-
EnvoyConfig *EnvoyConfig `json:"envoyConfig,omitempty"`
690-
ContourIngressConfig *ContourIngressConfig `json:"contourIngressConfig,omitempty"`
708+
EnvoyConfig *EnvoyConfig `json:"envoyConfig,omitempty"`
709+
ContourIngressConfig *ContourIngressConfig `json:"contourIngressConfig,omitempty"`
710+
EnvoyGatewayConfig *EnvoyGatewayIngressConfig `json:"envoyGatewayConfig,omitempty"`
691711
}
692712

693713
type ContourIngressConfig struct {
@@ -697,6 +717,25 @@ type ContourIngressConfig struct {
697717
BrokerFQDNTemplate string `json:"brokerFQDNTemplate"`
698718
}
699719

720+
type EnvoyGatewayIngressConfig struct {
721+
// GatewayClassName is the name of the GatewayClass resource to use
722+
// +optional
723+
GatewayClassName string `json:"gatewayClassName,omitempty"`
724+
// GatewayName is the name of the Gateway resource to create
725+
// +optional
726+
GatewayName string `json:"gatewayName,omitempty"`
727+
// TLSSecretName is the name of the secret containing TLS certificates for TLS termination
728+
// +optional
729+
TLSSecretName string `json:"tlsSecretName,omitempty"`
730+
// BrokerHostnameTemplate is the template for generating broker hostnames (e.g., "kafka-%id.example.com")
731+
// The %id placeholder will be replaced with the broker ID
732+
// +optional
733+
BrokerHostnameTemplate string `json:"brokerHostnameTemplate,omitempty"`
734+
// Annotations to add to the Gateway resource
735+
// +optional
736+
Annotations map[string]string `json:"annotations,omitempty"`
737+
}
738+
700739
// InternalListenerConfig defines the internal listener config for Kafka
701740
type InternalListenerConfig struct {
702741
CommonListenerSpec `json:",inline"`

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 28 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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20780,6 +20780,31 @@ spec:
2078020780
type: object
2078120781
type: array
2078220782
type: object
20783+
envoyGatewayConfig:
20784+
properties:
20785+
annotations:
20786+
additionalProperties:
20787+
type: string
20788+
description: Annotations to add to the Gateway resource
20789+
type: object
20790+
brokerHostnameTemplate:
20791+
description: |-
20792+
BrokerHostnameTemplate is the template for generating broker hostnames (e.g., "kafka-%id.example.com")
20793+
The %id placeholder will be replaced with the broker ID
20794+
type: string
20795+
gatewayClassName:
20796+
description: GatewayClassName is the name of the GatewayClass
20797+
resource to use
20798+
type: string
20799+
gatewayName:
20800+
description: GatewayName is the name of the Gateway resource to
20801+
create
20802+
type: string
20803+
tlsSecretName:
20804+
description: TLSSecretName is the name of the secret containing
20805+
TLS certificates for TLS termination
20806+
type: string
20807+
type: object
2078320808
envs:
2078420809
description: |-
2078520810
Envs defines environment variables for Kafka broker Pods.
@@ -20948,6 +20973,7 @@ spec:
2094820973
enum:
2094920974
- envoy
2095020975
- contour
20976+
- envoygateway
2095120977
type: string
2095220978
kRaft:
2095320979
default: false
@@ -22610,6 +22636,33 @@ spec:
2261022636
type: object
2261122637
type: array
2261222638
type: object
22639+
envoyGatewayConfig:
22640+
properties:
22641+
annotations:
22642+
additionalProperties:
22643+
type: string
22644+
description: Annotations to add to the Gateway
22645+
resource
22646+
type: object
22647+
brokerHostnameTemplate:
22648+
description: |-
22649+
BrokerHostnameTemplate is the template for generating broker hostnames (e.g., "kafka-%id.example.com")
22650+
The %id placeholder will be replaced with the broker ID
22651+
type: string
22652+
gatewayClassName:
22653+
description: GatewayClassName is the name
22654+
of the GatewayClass resource to use
22655+
type: string
22656+
gatewayName:
22657+
description: GatewayName is the name of the
22658+
Gateway resource to create
22659+
type: string
22660+
tlsSecretName:
22661+
description: TLSSecretName is the name of
22662+
the secret containing TLS certificates for
22663+
TLS termination
22664+
type: string
22665+
type: object
2261322666
externalTrafficPolicy:
2261422667
description: |-
2261522668
externalTrafficPolicy denotes if this Service desires to route external

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20780,6 +20780,31 @@ spec:
2078020780
type: object
2078120781
type: array
2078220782
type: object
20783+
envoyGatewayConfig:
20784+
properties:
20785+
annotations:
20786+
additionalProperties:
20787+
type: string
20788+
description: Annotations to add to the Gateway resource
20789+
type: object
20790+
brokerHostnameTemplate:
20791+
description: |-
20792+
BrokerHostnameTemplate is the template for generating broker hostnames (e.g., "kafka-%id.example.com")
20793+
The %id placeholder will be replaced with the broker ID
20794+
type: string
20795+
gatewayClassName:
20796+
description: GatewayClassName is the name of the GatewayClass
20797+
resource to use
20798+
type: string
20799+
gatewayName:
20800+
description: GatewayName is the name of the Gateway resource to
20801+
create
20802+
type: string
20803+
tlsSecretName:
20804+
description: TLSSecretName is the name of the secret containing
20805+
TLS certificates for TLS termination
20806+
type: string
20807+
type: object
2078320808
envs:
2078420809
description: |-
2078520810
Envs defines environment variables for Kafka broker Pods.
@@ -20948,6 +20973,7 @@ spec:
2094820973
enum:
2094920974
- envoy
2095020975
- contour
20976+
- envoygateway
2095120977
type: string
2095220978
kRaft:
2095320979
default: false
@@ -22610,6 +22636,33 @@ spec:
2261022636
type: object
2261122637
type: array
2261222638
type: object
22639+
envoyGatewayConfig:
22640+
properties:
22641+
annotations:
22642+
additionalProperties:
22643+
type: string
22644+
description: Annotations to add to the Gateway
22645+
resource
22646+
type: object
22647+
brokerHostnameTemplate:
22648+
description: |-
22649+
BrokerHostnameTemplate is the template for generating broker hostnames (e.g., "kafka-%id.example.com")
22650+
The %id placeholder will be replaced with the broker ID
22651+
type: string
22652+
gatewayClassName:
22653+
description: GatewayClassName is the name
22654+
of the GatewayClass resource to use
22655+
type: string
22656+
gatewayName:
22657+
description: GatewayName is the name of the
22658+
Gateway resource to create
22659+
type: string
22660+
tlsSecretName:
22661+
description: TLSSecretName is the name of
22662+
the secret containing TLS certificates for
22663+
TLS termination
22664+
type: string
22665+
type: object
2261322666
externalTrafficPolicy:
2261422667
description: |-
2261522668
externalTrafficPolicy denotes if this Service desires to route external

config/base/rbac/role.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ rules:
109109
- patch
110110
- update
111111
- watch
112+
- apiGroups:
113+
- gateway.networking.k8s.io
114+
resources:
115+
- gateways
116+
- tcproutes
117+
- tlsroutes
118+
verbs:
119+
- create
120+
- delete
121+
- get
122+
- list
123+
- patch
124+
- update
125+
- watch
112126
- apiGroups:
113127
- kafka.banzaicloud.io
114128
resources:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: kafka.banzaicloud.io/v1beta1
2+
kind: KafkaCluster
3+
metadata:
4+
labels:
5+
controller-tools.k8s.io: "1.0"
6+
name: kafka
7+
spec:
8+
monitoringConfig:
9+
jmxImage: "ghcr.io/adobe/koperator/jmx-javaagent:1.4.0"
10+
headlessServiceEnabled: true
11+
propagateLabels: false
12+
oneBrokerPerNode: false
13+
clusterImage: "ghcr.io/adobe/koperator/kafka:2.13-3.9.1"
14+
ingressController: "envoy"
15+
kRaftMode: true
16+
readOnlyConfig: |
17+
auto.create.topics.enable=false
18+
cruise.control.metrics.topic.auto.create=true
19+
cruise.control.metrics.topic.num.partitions=1
20+
cruise.control.metrics.topic.replication.factor=2
21+
brokerConfigGroups:
22+
default:
23+
storageConfigs:
24+
- mountPath: "/kafka-logs"
25+
pvcSpec:
26+
accessModes:
27+
- ReadWriteOnce
28+
resources:
29+
requests:
30+
storage: 10Gi
31+
brokerAnnotations:
32+
prometheus.io/scrape: "true"
33+
prometheus.io/port: "9020"
34+
brokers:
35+
- id: 0
36+
brokerConfigGroup: "default"
37+
brokerConfig:
38+
roles:
39+
- "broker"
40+
- "controller"
41+
- id: 2
42+
brokerConfigGroup: "default"
43+
brokerConfig:
44+
roles:
45+
- "broker"
46+
- "controller"
47+
rollingUpgradeConfig:
48+
failureThreshold: 1
49+
listenersConfig:
50+
internalListeners:
51+
- type: "plaintext"
52+
name: "internal"
53+
containerPort: 29092
54+
usedForInnerBrokerCommunication: true
55+
- type: "plaintext"
56+
name: "controller"
57+
containerPort: 29093
58+
usedForInnerBrokerCommunication: false
59+
usedForControllerCommunication: true
60+
externalListeners:
61+
- type: "plaintext"
62+
name: "external"
63+
externalStartingPort: 19090
64+
containerPort: 9094
65+

0 commit comments

Comments
 (0)