@@ -472,7 +472,81 @@ func (clusterWatcher *ClusterWatcher) UpdateKubearmorRelayEnv(cfg *opv1.KubeArmo
472
472
Name : "ENABLE_STDOUT_MSGS" ,
473
473
Value : common .KubearmorRelayEnvMap [common .EnableStdOutMsgs ],
474
474
},
475
+ {
476
+ Name : "ENABLE_DASHBOARDS" ,
477
+ Value : strconv .FormatBool (common .Adapter .ElasticSearch .Enabled ),
478
+ },
479
+ {
480
+ Name : "ES_URL" ,
481
+ Value : common .Adapter .ElasticSearch .Url ,
482
+ },
483
+ {
484
+ Name : "ES_ALERTS_INDEX" ,
485
+ Value : common .Adapter .ElasticSearch .AlertsIndexName ,
486
+ },
487
+ {
488
+ Name : "ES_USERNAME" ,
489
+ ValueFrom : & corev1.EnvVarSource {
490
+ SecretKeyRef : & corev1.SecretKeySelector {
491
+ LocalObjectReference : corev1.LocalObjectReference {
492
+ Name : common .Adapter .ElasticSearch .Auth .SecretName ,
493
+ },
494
+ Key : common .Adapter .ElasticSearch .Auth .UserNameKey ,
495
+ Optional : & common .Pointer2True ,
496
+ },
497
+ },
498
+ },
499
+ {
500
+ Name : "ES_PASSWORD" ,
501
+ ValueFrom : & corev1.EnvVarSource {
502
+ SecretKeyRef : & corev1.SecretKeySelector {
503
+ LocalObjectReference : corev1.LocalObjectReference {
504
+ Name : common .Adapter .ElasticSearch .Auth .SecretName ,
505
+ },
506
+ Key : common .Adapter .ElasticSearch .Auth .PasswordKey ,
507
+ Optional : & common .Pointer2True ,
508
+ },
509
+ },
510
+ },
511
+ }
512
+
513
+ ElasticSearchAdapterCaVolume := []corev1.Volume {
514
+ {
515
+ Name : "elastic-ca" ,
516
+ VolumeSource : corev1.VolumeSource {
517
+ Secret : & corev1.SecretVolumeSource {
518
+ SecretName : common .Adapter .ElasticSearch .Auth .CAcertSecretName ,
519
+ },
520
+ },
521
+ },
522
+ }
523
+
524
+ ElasticSearchAdapterCaVolumeMount := []corev1.VolumeMount {
525
+ {
526
+ Name : "elastic-ca" ,
527
+ MountPath : common .ElasticSearchAdapterCaCertPath ,
528
+ },
529
+ }
530
+ if common .Adapter .ElasticSearch .Auth .CAcertSecretName != "" {
531
+ relay .Spec .Template .Spec .Containers [0 ].Env = append (relay .Spec .Template .Spec .Containers [0 ].Env , corev1.EnvVar {
532
+ Name : "ES_CA_CERT_PATH" ,
533
+ Value : common .ElasticSearchAdapterCaCertPath + "/" + common .Adapter .ElasticSearch .Auth .CaCertKey ,
534
+ })
535
+
536
+ common .AddOrRemoveVolume (& ElasticSearchAdapterCaVolume , & relay .Spec .Template .Spec .Volumes , common .AddAction )
537
+ common .AddOrRemoveVolumeMount (& ElasticSearchAdapterCaVolumeMount , & relay .Spec .Template .Spec .Containers [0 ].VolumeMounts , common .AddAction )
538
+ } else {
539
+ common .AddOrRemoveVolume (& ElasticSearchAdapterCaVolume , & relay .Spec .Template .Spec .Volumes , common .DeleteAction )
540
+ common .AddOrRemoveVolumeMount (& ElasticSearchAdapterCaVolumeMount , & relay .Spec .Template .Spec .Containers [0 ].VolumeMounts , common .DeleteAction )
475
541
}
542
+
543
+ if common .Adapter .ElasticSearch .Auth .AllowTlsInsecure {
544
+ relay .Spec .Template .Spec .Containers [0 ].Env = append (relay .Spec .Template .Spec .Containers [0 ].Env , corev1.EnvVar {
545
+ Name : "ES_ALLOW_INSECURE_TLS" ,
546
+ Value : "true" ,
547
+ })
548
+ }
549
+
476
550
_ , err = clusterWatcher .Client .AppsV1 ().Deployments (common .Namespace ).Update (context .Background (), relay , v1.UpdateOptions {})
477
551
if err != nil {
478
552
clusterWatcher .Log .Warnf ("Cannot update deployment=%s error=%s" , deployments .RelayDeploymentName , err .Error ())
@@ -955,6 +1029,42 @@ func UpdatedKubearmorRelayEnv(config *opv1.KubeArmorConfigSpec) bool {
955
1029
updated = true
956
1030
}
957
1031
}
1032
+
1033
+ stringEnableElasticAdapter := strconv .FormatBool (config .Adapters .ElasticSearch .Enabled )
1034
+ if stringEnableElasticAdapter != "" {
1035
+ if common .Adapter .ElasticSearch .Enabled != config .Adapters .ElasticSearch .Enabled {
1036
+ updated = true
1037
+ common .Adapter .ElasticSearch .Enabled = config .Adapters .ElasticSearch .Enabled
1038
+ }
1039
+ if common .Adapter .ElasticSearch .Auth .AllowTlsInsecure != config .Adapters .ElasticSearch .Auth .AllowTlsInsecure {
1040
+ updated = true
1041
+ common .Adapter .ElasticSearch .Auth .AllowTlsInsecure = config .Adapters .ElasticSearch .Auth .AllowTlsInsecure
1042
+ }
1043
+ if common .Adapter .ElasticSearch .AlertsIndexName != config .Adapters .ElasticSearch .AlertsIndexName {
1044
+ updated = true
1045
+ common .Adapter .ElasticSearch .AlertsIndexName = config .Adapters .ElasticSearch .AlertsIndexName
1046
+ }
1047
+ if common .Adapter .ElasticSearch .Url != config .Adapters .ElasticSearch .Url {
1048
+ updated = true
1049
+ common .Adapter .ElasticSearch .Url = config .Adapters .ElasticSearch .Url
1050
+ }
1051
+ if config .Adapters .ElasticSearch .Auth .SecretName != "" && common .Adapter .ElasticSearch .Auth .SecretName != config .Adapters .ElasticSearch .Auth .SecretName {
1052
+ updated = true
1053
+ common .Adapter .ElasticSearch .Auth .SecretName = config .Adapters .ElasticSearch .Auth .SecretName
1054
+ }
1055
+ if config .Adapters .ElasticSearch .Auth .UserNameKey != "" && common .Adapter .ElasticSearch .Auth .UserNameKey != config .Adapters .ElasticSearch .Auth .UserNameKey {
1056
+ updated = true
1057
+ common .Adapter .ElasticSearch .Auth .UserNameKey = config .Adapters .ElasticSearch .Auth .UserNameKey
1058
+ }
1059
+ if config .Adapters .ElasticSearch .Auth .PasswordKey != "" && common .Adapter .ElasticSearch .Auth .PasswordKey != config .Adapters .ElasticSearch .Auth .PasswordKey {
1060
+ updated = true
1061
+ common .Adapter .ElasticSearch .Auth .PasswordKey = config .Adapters .ElasticSearch .Auth .PasswordKey
1062
+ }
1063
+ if config .Adapters .ElasticSearch .Auth .CAcertSecretName != "" && common .Adapter .ElasticSearch .Auth .CAcertSecretName != config .Adapters .ElasticSearch .Auth .CAcertSecretName {
1064
+ updated = true
1065
+ common .Adapter .ElasticSearch .Auth .CAcertSecretName = config .Adapters .ElasticSearch .Auth .CAcertSecretName
1066
+ }
1067
+ }
958
1068
return updated
959
1069
}
960
1070
0 commit comments