@@ -19,16 +19,20 @@ use stackable_operator::{
19
19
api:: {
20
20
apps:: v1:: { StatefulSet , StatefulSetSpec } ,
21
21
core:: v1:: {
22
- ConfigMap , ConfigMapKeySelector , ConfigMapVolumeSource , EmptyDirVolumeSource ,
23
- EnvVar , EnvVarSource , ExecAction , ObjectFieldSelector , PodSpec , Probe ,
22
+ ConfigMap , ConfigMapKeySelector , ConfigMapVolumeSource , EnvVar , EnvVarSource ,
23
+ EphemeralVolumeSource , ExecAction , PersistentVolumeClaimSpec ,
24
+ PersistentVolumeClaimTemplate , PodSpec , Probe , ResourceRequirements ,
24
25
SecurityContext , Service , ServiceAccount , ServicePort , ServiceSpec , Volume ,
25
26
} ,
26
27
rbac:: v1:: { ClusterRole , RoleBinding , RoleRef , Subject } ,
27
28
} ,
28
- apimachinery:: pkg:: apis:: meta:: v1:: LabelSelector ,
29
+ apimachinery:: pkg:: { api :: resource :: Quantity , apis:: meta:: v1:: LabelSelector } ,
29
30
Resource ,
30
31
} ,
31
- kube:: runtime:: { controller:: Action , reflector:: ObjectRef } ,
32
+ kube:: {
33
+ core:: ObjectMeta ,
34
+ runtime:: { controller:: Action , reflector:: ObjectRef } ,
35
+ } ,
32
36
labels:: { role_group_selector_labels, role_selector_labels} ,
33
37
logging:: controller:: ReconcilerError ,
34
38
product_config:: {
@@ -41,7 +45,6 @@ use strum::{EnumDiscriminants, IntoStaticStr};
41
45
42
46
use crate :: {
43
47
discovery:: { self , build_discovery_configmaps} ,
44
- pod_svc_controller,
45
48
utils:: { self , ObjectRefExt } ,
46
49
ControllerConfig ,
47
50
} ;
@@ -492,33 +495,6 @@ fn build_broker_rolegroup_statefulset(
492
495
. context ( KafkaVersionParseFailureSnafu ) ?;
493
496
let image = format ! ( "docker.stackable.tech/stackable/kafka:{}" , image_version) ;
494
497
495
- let container_get_svc = ContainerBuilder :: new ( "get-svc" )
496
- . image ( "docker.stackable.tech/stackable/tools:0.2.0-stackable0.3.0" )
497
- . command ( vec ! [ "bash" . to_string( ) ] )
498
- . args ( vec ! [
499
- "-euo" . to_string( ) ,
500
- "pipefail" . to_string( ) ,
501
- "-c" . to_string( ) ,
502
- [
503
- "kubectl get service \" $POD_NAME\" -o jsonpath='{.spec.ports[0].nodePort}'" ,
504
- "tee /stackable/tmp/nodeport" ,
505
- ]
506
- . join( " | " ) ,
507
- ] )
508
- . add_env_vars ( vec ! [ EnvVar {
509
- name: "POD_NAME" . to_string( ) ,
510
- value_from: Some ( EnvVarSource {
511
- field_ref: Some ( ObjectFieldSelector {
512
- api_version: Some ( "v1" . to_string( ) ) ,
513
- field_path: "metadata.name" . to_string( ) ,
514
- } ) ,
515
- ..EnvVarSource :: default ( )
516
- } ) ,
517
- ..EnvVar :: default ( )
518
- } ] )
519
- . add_volume_mount ( "tmp" , "/stackable/tmp" )
520
- . build ( ) ;
521
-
522
498
// For most storage classes the mounts will belong to the root user and not be writeable to
523
499
// other users.
524
500
// Since kafka runs as the user stackable inside of the container the data directory needs to be
@@ -583,18 +559,6 @@ fn build_broker_rolegroup_statefulset(
583
559
..EnvVar :: default ( )
584
560
} ) ;
585
561
586
- env. push ( EnvVar {
587
- name : "NODE" . to_string ( ) ,
588
- value_from : Some ( EnvVarSource {
589
- field_ref : Some ( ObjectFieldSelector {
590
- api_version : Some ( "v1" . to_string ( ) ) ,
591
- field_path : "status.hostIP" . to_string ( ) ,
592
- } ) ,
593
- ..EnvVarSource :: default ( )
594
- } ) ,
595
- ..EnvVar :: default ( )
596
- } ) ;
597
-
598
562
// add env var for log4j if set
599
563
if kafka. spec . log4j . is_some ( ) {
600
564
env. push ( EnvVar {
@@ -609,7 +573,7 @@ fn build_broker_rolegroup_statefulset(
609
573
let jvm_args = format ! ( "-javaagent:/stackable/jmx/jmx_prometheus_javaagent-0.16.1.jar={}:/stackable/jmx/broker.yaml" , METRICS_PORT ) ;
610
574
let zookeeper_override = "--override \" zookeeper.connect=$ZOOKEEPER\" " ;
611
575
let advertised_listeners_override =
612
- "--override \" advertised.listeners=PLAINTEXT://$NODE :$(cat /stackable/tmp/nodeport )\" " ;
576
+ "--override \" advertised.listeners=PLAINTEXT://$(cat /stackable/lb/default-address/address) :$(cat /stackable/lb/default-address/ports/kafka )\" " ;
613
577
let opa_url_override = opa_connect_string. map_or ( "" . to_string ( ) , |opa| {
614
578
format ! ( "--override \" opa.authorizer.url={}\" " , opa)
615
579
} ) ;
@@ -634,7 +598,7 @@ fn build_broker_rolegroup_statefulset(
634
598
. add_container_port ( "metrics" , METRICS_PORT . into ( ) )
635
599
. add_volume_mount ( LOG_DIRS_VOLUME_NAME , "/stackable/data" )
636
600
. add_volume_mount ( "config" , "/stackable/config" )
637
- . add_volume_mount ( "tmp " , "/stackable/tmp " )
601
+ . add_volume_mount ( "lb " , "/stackable/lb " )
638
602
. resources ( resources)
639
603
. build ( ) ;
640
604
@@ -670,10 +634,9 @@ fn build_broker_rolegroup_statefulset(
670
634
& rolegroup_ref. role ,
671
635
& rolegroup_ref. role_group ,
672
636
)
673
- . with_label ( pod_svc_controller:: LABEL_ENABLE , "true" )
674
637
} )
675
638
. add_init_container ( container_chown)
676
- . add_init_container ( container_get_svc)
639
+ // .add_init_container(container_get_svc)
677
640
. add_container ( container_kafka)
678
641
. add_container ( container_kcat_prober)
679
642
. add_volume ( Volume {
@@ -685,8 +648,32 @@ fn build_broker_rolegroup_statefulset(
685
648
..Volume :: default ( )
686
649
} )
687
650
. add_volume ( Volume {
688
- name : "tmp" . to_string ( ) ,
689
- empty_dir : Some ( EmptyDirVolumeSource :: default ( ) ) ,
651
+ name : "lb" . to_string ( ) ,
652
+ ephemeral : Some ( EphemeralVolumeSource {
653
+ volume_claim_template : Some ( PersistentVolumeClaimTemplate {
654
+ metadata : Some ( ObjectMeta {
655
+ annotations : Some (
656
+ [ (
657
+ "lb.stackable.tech/lb-class" . to_string ( ) ,
658
+ "nodeport" . to_string ( ) ,
659
+ ) ]
660
+ . into ( ) ,
661
+ ) ,
662
+ ..Default :: default ( )
663
+ } ) ,
664
+ spec : PersistentVolumeClaimSpec {
665
+ access_modes : Some ( vec ! [ "ReadWriteMany" . to_string( ) ] ) ,
666
+ resources : Some ( ResourceRequirements {
667
+ requests : Some (
668
+ [ ( "storage" . to_string ( ) , Quantity ( "1" . to_string ( ) ) ) ] . into ( ) ,
669
+ ) ,
670
+ ..Default :: default ( )
671
+ } ) ,
672
+ storage_class_name : Some ( "lb.stackable.tech" . to_string ( ) ) ,
673
+ ..Default :: default ( )
674
+ } ,
675
+ } ) ,
676
+ } ) ,
690
677
..Volume :: default ( )
691
678
} )
692
679
. build_template ( ) ;
0 commit comments