@@ -872,6 +872,10 @@ func (f *RisingWaveObjectFactory) envsForTLS() []corev1.EnvVar {
872872 return nil
873873}
874874
875+ func (f * RisingWaveObjectFactory ) isWebhookListenerEnabled () bool {
876+ return ptr .Deref (f .risingwave .Spec .EnableWebhookListener , false )
877+ }
878+
875879func (f * RisingWaveObjectFactory ) envsForFrontendArgs () []corev1.EnvVar {
876880 envVars := []corev1.EnvVar {
877881 {
@@ -900,6 +904,13 @@ func (f *RisingWaveObjectFactory) envsForFrontendArgs() []corev1.EnvVar {
900904 },
901905 }
902906
907+ if f .isWebhookListenerEnabled () {
908+ envVars = append (envVars , corev1.EnvVar {
909+ Name : envs .RWWebhookListenAddr ,
910+ Value : fmt .Sprintf ("0.0.0.0:%d" , consts .FrontendWebhookPort ),
911+ })
912+ }
913+
903914 return append (envVars , f .envsForTLS ()... )
904915}
905916
@@ -1912,7 +1923,7 @@ func newWorkloadObjectForComponentNodeGroup[T client.Object](f *RisingWaveObject
19121923}
19131924
19141925func (f * RisingWaveObjectFactory ) portsForFrontendContainer () []corev1.ContainerPort {
1915- return []corev1.ContainerPort {
1926+ ports := []corev1.ContainerPort {
19161927 {
19171928 Name : consts .PortService ,
19181929 Protocol : corev1 .ProtocolTCP ,
@@ -1924,6 +1935,16 @@ func (f *RisingWaveObjectFactory) portsForFrontendContainer() []corev1.Container
19241935 ContainerPort : consts .FrontendMetricsPort ,
19251936 },
19261937 }
1938+
1939+ if f .isWebhookListenerEnabled () {
1940+ ports = append (ports , corev1.ContainerPort {
1941+ Name : consts .PortHTTP ,
1942+ Protocol : corev1 .ProtocolTCP ,
1943+ ContainerPort : consts .FrontendWebhookPort ,
1944+ })
1945+ }
1946+
1947+ return ports
19271948}
19281949
19291950func (f * RisingWaveObjectFactory ) isEmbeddedServingModeEnabled () bool {
@@ -2142,8 +2163,7 @@ func (f *RisingWaveObjectFactory) argsForStandaloneV2() []string {
21422163}
21432164
21442165func (f * RisingWaveObjectFactory ) portsForStandaloneContainer () []corev1.ContainerPort {
2145- // TODO: either expose each metrics port, or combine them into one.
2146- return []corev1.ContainerPort {
2166+ ports := []corev1.ContainerPort {
21472167 {
21482168 Name : consts .PortMetrics ,
21492169 Protocol : corev1 .ProtocolTCP ,
@@ -2160,6 +2180,16 @@ func (f *RisingWaveObjectFactory) portsForStandaloneContainer() []corev1.Contain
21602180 ContainerPort : consts .MetaDashboardPort ,
21612181 },
21622182 }
2183+
2184+ if f .isWebhookListenerEnabled () {
2185+ ports = append (ports , corev1.ContainerPort {
2186+ Name : consts .PortHTTP ,
2187+ Protocol : corev1 .ProtocolTCP ,
2188+ ContainerPort : consts .FrontendWebhookPort ,
2189+ })
2190+ }
2191+
2192+ return ports
21632193}
21642194
21652195func (f * RisingWaveObjectFactory ) setupStandaloneContainer (podSpec * corev1.PodSpec , container * corev1.Container ) {
@@ -2223,6 +2253,13 @@ func (f *RisingWaveObjectFactory) setupStandaloneContainer(podSpec *corev1.PodSp
22232253 func (a , b * corev1.EnvVar ) bool { return a .Name == b .Name })
22242254 }
22252255
2256+ if f .isWebhookListenerEnabled () {
2257+ container .Env = append (container .Env , corev1.EnvVar {
2258+ Name : envs .RWWebhookListenAddr ,
2259+ Value : fmt .Sprintf ("0.0.0.0:%d" , consts .FrontendWebhookPort ),
2260+ })
2261+ }
2262+
22262263 if vol , volMount := f .volumeAndVolumeMountForTLS (); vol != nil && volMount != nil {
22272264 // Add or override the volume and volume mount for TLS.
22282265 podSpec .Volumes = mergeListWhenKeyEquals (podSpec .Volumes , * vol , func (a , b * corev1.Volume ) bool {
@@ -2280,7 +2317,7 @@ func (f *RisingWaveObjectFactory) NewStandaloneAdvancedStatefulSet() *kruiseapps
22802317
22812318// NewStandaloneService creates a Service for standalone component.
22822319func (f * RisingWaveObjectFactory ) NewStandaloneService () * corev1.Service {
2283- standaloneSvc := f . newService ( consts . ComponentStandalone , corev1 . ServiceTypeClusterIP , []corev1.ServicePort {
2320+ svcPorts := []corev1.ServicePort {
22842321 {
22852322 Name : consts .PortService ,
22862323 Protocol : corev1 .ProtocolTCP ,
@@ -2299,7 +2336,18 @@ func (f *RisingWaveObjectFactory) NewStandaloneService() *corev1.Service {
22992336 Port : consts .MetaDashboardPort ,
23002337 TargetPort : intstr .FromString (consts .PortDashboard ),
23012338 },
2302- })
2339+ }
2340+
2341+ if f .isWebhookListenerEnabled () {
2342+ svcPorts = append (svcPorts , corev1.ServicePort {
2343+ Name : consts .PortHTTP ,
2344+ Protocol : corev1 .ProtocolTCP ,
2345+ Port : consts .FrontendWebhookPort ,
2346+ TargetPort : intstr .FromString (consts .PortHTTP ),
2347+ })
2348+ }
2349+
2350+ standaloneSvc := f .newService (consts .ComponentStandalone , corev1 .ServiceTypeClusterIP , svcPorts )
23032351
23042352 return mustSetControllerReference (f .risingwave , standaloneSvc , f .scheme )
23052353}
@@ -2355,6 +2403,15 @@ func (f *RisingWaveObjectFactory) NewFrontendService() *corev1.Service {
23552403 })
23562404 }
23572405
2406+ if f .isWebhookListenerEnabled () {
2407+ svcPorts = append (svcPorts , corev1.ServicePort {
2408+ Name : consts .PortHTTP ,
2409+ Protocol : corev1 .ProtocolTCP ,
2410+ Port : consts .FrontendWebhookPort ,
2411+ TargetPort : intstr .FromString (consts .PortHTTP ),
2412+ })
2413+ }
2414+
23582415 frontendSvc := f .newService (consts .ComponentFrontend , f .risingwave .Spec .FrontendServiceType , svcPorts )
23592416
23602417 // Hijack selector if it's standalone mode.
0 commit comments