@@ -315,9 +315,11 @@ fn pod_template(config: &WasmCloudHostConfig, _ctx: Arc<Context>) -> PodTemplate
315
315
316
316
let mut nats_resources: Option < k8s_openapi:: api:: core:: v1:: ResourceRequirements > = None ;
317
317
let mut wasmcloud_resources: Option < k8s_openapi:: api:: core:: v1:: ResourceRequirements > = None ;
318
- if let Some ( resources) = & config. spec . resources {
319
- nats_resources = resources. nats . clone ( ) ;
320
- wasmcloud_resources = resources. wasmcloud . clone ( ) ;
318
+ if let Some ( scheduling_options) = & config. spec . scheduling_options {
319
+ if let Some ( resources) = & scheduling_options. resources {
320
+ nats_resources = resources. nats . clone ( ) ;
321
+ wasmcloud_resources = resources. wasmcloud . clone ( ) ;
322
+ }
321
323
}
322
324
323
325
let containers = vec ! [
@@ -371,14 +373,34 @@ fn pod_template(config: &WasmCloudHostConfig, _ctx: Arc<Context>) -> PodTemplate
371
373
..Default :: default ( )
372
374
} ,
373
375
] ;
374
- PodTemplateSpec {
376
+
377
+ let mut volumes = vec ! [
378
+ Volume {
379
+ name: "nats-config" . to_string( ) ,
380
+ config_map: Some ( ConfigMapVolumeSource {
381
+ name: Some ( config. name_any( ) ) ,
382
+ ..Default :: default ( )
383
+ } ) ,
384
+ ..Default :: default ( )
385
+ } ,
386
+ Volume {
387
+ name: "nats-creds" . to_string( ) ,
388
+ secret: Some ( SecretVolumeSource {
389
+ secret_name: Some ( config. spec. secret_name. clone( ) ) ,
390
+ ..Default :: default ( )
391
+ } ) ,
392
+ ..Default :: default ( )
393
+ } ,
394
+ ] ;
395
+ let service_account = config. name_any ( ) ;
396
+ let mut template = PodTemplateSpec {
375
397
metadata : Some ( ObjectMeta {
376
398
labels : Some ( labels) ,
377
399
..Default :: default ( )
378
400
} ) ,
379
401
spec : Some ( PodSpec {
380
402
service_account : Some ( config. name_any ( ) ) ,
381
- containers,
403
+ containers : containers . clone ( ) ,
382
404
volumes : Some ( vec ! [
383
405
Volume {
384
406
name: "nats-config" . to_string( ) ,
@@ -399,7 +421,21 @@ fn pod_template(config: &WasmCloudHostConfig, _ctx: Arc<Context>) -> PodTemplate
399
421
] ) ,
400
422
..Default :: default ( )
401
423
} ) ,
402
- }
424
+ } ;
425
+
426
+ if let Some ( scheduling_options) = & config. spec . scheduling_options {
427
+ if let Some ( pod_overrides) = & scheduling_options. pod_template_additions {
428
+ let mut overrides = pod_overrides. clone ( ) ;
429
+ overrides. service_account_name = Some ( service_account) ;
430
+ overrides. containers = containers. clone ( ) ;
431
+ if let Some ( vols) = overrides. volumes {
432
+ volumes. extend ( vols) ;
433
+ }
434
+ overrides. volumes = Some ( volumes) ;
435
+ template. spec = Some ( overrides) ;
436
+ }
437
+ } ;
438
+ template
403
439
}
404
440
405
441
fn deployment_spec ( config : & WasmCloudHostConfig , ctx : Arc < Context > ) -> DeploymentSpec {
@@ -504,31 +540,34 @@ async fn configure_hosts(config: &WasmCloudHostConfig, ctx: Arc<Context>) -> Res
504
540
] ;
505
541
}
506
542
507
- if config. spec . daemonset {
508
- let mut spec = daemonset_spec ( config, ctx. clone ( ) ) ;
509
- spec. template . spec . as_mut ( ) . unwrap ( ) . containers [ 1 ]
510
- . env
511
- . as_mut ( )
512
- . unwrap ( )
513
- . append ( & mut env_vars) ;
514
- let ds = DaemonSet {
515
- metadata : ObjectMeta {
516
- name : Some ( config. name_any ( ) ) ,
517
- namespace : Some ( config. namespace ( ) . unwrap ( ) ) ,
518
- owner_references : Some ( vec ! [ config. controller_owner_ref( & ( ) ) . unwrap( ) ] ) ,
543
+ if let Some ( scheduling_options) = & config. spec . scheduling_options {
544
+ if scheduling_options. daemonset {
545
+ let mut spec = daemonset_spec ( config, ctx. clone ( ) ) ;
546
+ spec. template . spec . as_mut ( ) . unwrap ( ) . containers [ 1 ]
547
+ . env
548
+ . as_mut ( )
549
+ . unwrap ( )
550
+ . append ( & mut env_vars) ;
551
+ let ds = DaemonSet {
552
+ metadata : ObjectMeta {
553
+ name : Some ( config. name_any ( ) ) ,
554
+ namespace : Some ( config. namespace ( ) . unwrap ( ) ) ,
555
+ owner_references : Some ( vec ! [ config. controller_owner_ref( & ( ) ) . unwrap( ) ] ) ,
556
+ ..Default :: default ( )
557
+ } ,
558
+ spec : Some ( spec) ,
519
559
..Default :: default ( )
520
- } ,
521
- spec : Some ( spec) ,
522
- ..Default :: default ( )
523
- } ;
524
-
525
- let api = Api :: < DaemonSet > :: namespaced ( ctx. client . clone ( ) , & config. namespace ( ) . unwrap ( ) ) ;
526
- api. patch (
527
- & config. name_any ( ) ,
528
- & PatchParams :: apply ( CLUSTER_CONFIG_FINALIZER ) ,
529
- & Patch :: Apply ( ds) ,
530
- )
531
- . await ?;
560
+ } ;
561
+
562
+ let api =
563
+ Api :: < DaemonSet > :: namespaced ( ctx. client . clone ( ) , & config. namespace ( ) . unwrap ( ) ) ;
564
+ api. patch (
565
+ & config. name_any ( ) ,
566
+ & PatchParams :: apply ( CLUSTER_CONFIG_FINALIZER ) ,
567
+ & Patch :: Apply ( ds) ,
568
+ )
569
+ . await ?;
570
+ }
532
571
} else {
533
572
let mut spec = deployment_spec ( config, ctx. clone ( ) ) ;
534
573
spec. template . spec . as_mut ( ) . unwrap ( ) . containers [ 1 ]
0 commit comments