@@ -19,7 +19,7 @@ use stackable_operator::{
1919 fragment:: { self , Fragment , ValidationError } ,
2020 merge:: Merge ,
2121 } ,
22- k8s_openapi:: apimachinery:: pkg:: api:: resource:: Quantity ,
22+ k8s_openapi:: { api :: core :: v1 :: ServicePort , apimachinery:: pkg:: api:: resource:: Quantity } ,
2323 kube:: { CustomResource , ResourceExt , runtime:: reflector:: ObjectRef } ,
2424 memory:: { BinaryMultiple , MemoryQuantity } ,
2525 product_config_utils:: { self , Configuration } ,
@@ -32,7 +32,10 @@ use stackable_operator::{
3232} ;
3333use strum:: { Display , EnumIter , EnumString , IntoEnumIterator } ;
3434
35- use crate :: crd:: v1alpha1:: { SupersetConfigFragment , SupersetRoleConfig } ;
35+ use crate :: {
36+ crd:: v1alpha1:: { SupersetConfigFragment , SupersetRoleConfig } ,
37+ listener:: default_listener_class,
38+ } ;
3639
3740pub mod affinity;
3841pub mod authentication;
@@ -49,9 +52,6 @@ pub const MAX_LOG_FILES_SIZE: MemoryQuantity = MemoryQuantity {
4952 unit : BinaryMultiple :: Mebi ,
5053} ;
5154
52- pub const LISTENER_VOLUME_NAME : & str = "listener" ;
53- pub const LISTENER_VOLUME_DIR : & str = "/stackable/listener" ;
54-
5555pub const APP_PORT_NAME : & str = "http" ;
5656pub const APP_PORT : u16 = 8088 ;
5757pub const METRICS_PORT_NAME : & str = "metrics" ;
@@ -311,10 +311,6 @@ impl Default for v1alpha1::SupersetRoleConfig {
311311 }
312312}
313313
314- fn default_listener_class ( ) -> String {
315- "cluster-internal" . to_string ( )
316- }
317-
318314#[ derive( Clone , Debug , Deserialize , Eq , PartialEq , Serialize ) ]
319315#[ serde( rename_all = "camelCase" ) ]
320316pub struct SupersetCredentials {
@@ -528,6 +524,43 @@ impl v1alpha1::SupersetCluster {
528524 }
529525 }
530526
527+ /// Set of functions to define service names on rolegroup level.
528+ /// Headless service for cluster internal purposes only.
529+ // TODO: Move to operator-rs
530+ pub fn rolegroup_headless_service_name (
531+ & self ,
532+ rolegroup : & RoleGroupRef < v1alpha1:: SupersetCluster > ,
533+ ) -> String {
534+ format ! ( "{name}-headless" , name = rolegroup. object_name( ) )
535+ }
536+
537+ /// Headless metrics service exposes Prometheus endpoint only
538+ // TODO: Move to operator-rs
539+ pub fn rolegroup_headless_metrics_service_name (
540+ & self ,
541+ rolegroup : & RoleGroupRef < v1alpha1:: SupersetCluster > ,
542+ ) -> String {
543+ format ! ( "{name}-metrics" , name = rolegroup. object_name( ) )
544+ }
545+
546+ pub fn metrics_ports ( & self ) -> Vec < ServicePort > {
547+ vec ! [ ServicePort {
548+ name: Some ( METRICS_PORT_NAME . to_string( ) ) ,
549+ port: METRICS_PORT . into( ) ,
550+ protocol: Some ( "TCP" . to_string( ) ) ,
551+ ..ServicePort :: default ( )
552+ } ]
553+ }
554+
555+ pub fn service_ports ( & self ) -> Vec < ServicePort > {
556+ vec ! [ ServicePort {
557+ name: Some ( APP_PORT_NAME . to_string( ) ) ,
558+ port: APP_PORT . into( ) ,
559+ protocol: Some ( "TCP" . to_string( ) ) ,
560+ ..ServicePort :: default ( )
561+ } ]
562+ }
563+
531564 pub fn generic_role_config ( & self , role : & SupersetRole ) -> Option < GenericRoleConfig > {
532565 self . get_role_config ( role) . map ( |r| r. common . to_owned ( ) )
533566 }
0 commit comments