@@ -243,8 +243,9 @@ func getSplunkService(ctx context.Context, cr splcommon.MetaObject, spec *enterp
243243 // append labels and annotations from parent
244244 splcommon .AppendParentMeta (service .ObjectMeta .GetObjectMeta (), cr .GetObjectMeta ())
245245
246- if instanceType == SplunkDeployer || (instanceType == SplunkSearchHead && isHeadless ) {
247- // required for SHC bootstrap process; use services with heads when readiness is desired
246+ if instanceType == SplunkDeployer || isHeadless {
247+ // required for SHC bootstrap process and for App Runtime Syncthing sync
248+ // (app pods need to reach the syncthing-server sidecar before splunkd is fully ready)
248249 service .Spec .PublishNotReadyAddresses = true
249250 }
250251
@@ -767,7 +768,7 @@ func getSplunkStatefulSet(ctx context.Context, client splcommon.ControllerClient
767768 TopologySpreadConstraints : spec .TopologySpreadConstraints ,
768769 SchedulerName : spec .SchedulerName ,
769770 ImagePullSecrets : spec .ImagePullSecrets ,
770- InitContainers : getAppRuntimeSidecar (instanceType , cr .GetName (), spec .Image ),
771+ InitContainers : getAppRuntimeSidecar (instanceType , cr .GetName (), spec .Image , cr . GetNamespace () ),
771772 Containers : []corev1.Container {
772773 {
773774 Image : spec .Image ,
@@ -824,13 +825,18 @@ func getSplunkStatefulSet(ctx context.Context, client splcommon.ControllerClient
824825// getAppRuntimeSidecar returns the AppRuntime sidecar init container for Standalone, Indexer, and SearchHead.
825826// Returns nil for other instance types.
826827// In pod-per-app mode the sidecar runs the supervisor (no containerd), and creates app pods via the K8s API.
827- func getAppRuntimeSidecar (instanceType InstanceType , instanceName string , splunkImage string ) []corev1.Container {
828+ func getAppRuntimeSidecar (instanceType InstanceType , instanceName string , splunkImage string , namespace string ) []corev1.Container {
828829 if instanceType != SplunkStandalone && instanceType != SplunkIndexer && instanceType != SplunkSearchHead {
829830 return nil
830831 }
831832 restartAlways := corev1 .ContainerRestartPolicyAlways
832833 runAsUser := int64 (0 )
833834 runAsNonRoot := false
835+
836+ stsName := GetSplunkStatefulsetName (instanceType , instanceName )
837+ headlessSvc := GetSplunkServiceName (instanceType , instanceName , true )
838+ syncthingServerAddr := fmt .Sprintf ("%s-0.%s.%s.svc.cluster.local" , stsName , headlessSvc , namespace )
839+
834840 return []corev1.Container {
835841 {
836842 Image : getAppRuntimeImage (),
@@ -850,6 +856,8 @@ func getAppRuntimeSidecar(instanceType InstanceType, instanceName string, splunk
850856 {Name : "APPRUNTIME_K8S_INSTANCE_TYPE" , Value : instanceType .ToKind ()},
851857 {Name : "APPRUNTIME_K8S_SPLUNK_IMAGE" , Value : splunkImage },
852858 {Name : "APPRUNTIME_K8S_WORKER_IMAGE" , Value : getAppRuntimeImage ()},
859+ {Name : "APPRUNTIME_K8S_SYNCTHING_ENABLED" , Value : "true" },
860+ {Name : "APPRUNTIME_K8S_SYNCTHING_SERVER_ADDR" , Value : syncthingServerAddr },
853861 },
854862 SecurityContext : & corev1.SecurityContext {
855863 RunAsUser : & runAsUser ,
@@ -873,7 +881,7 @@ func getAppRuntimeImage() string {
873881 if image , ok := os .LookupEnv ("RELATED_IMAGE_APP_RUNTIME" ); ok {
874882 return image
875883 }
876- return "493245399694.dkr.ecr.us-west-2.amazonaws.com/appruntime/ecr-repo/supervisor:v3.1.0-sidecar "
884+ return "493245399694.dkr.ecr.us-west-2.amazonaws.com/appruntime/ecr-repo/supervisor:v3.1.0-pod-per-app-syncthing "
877885}
878886
879887// getSmartstoreConfigMap returns the smartstore configMap, if it exists and applicable for that instanceType
@@ -1228,6 +1236,43 @@ func updateSplunkPodTemplateWithConfig(ctx context.Context, client splcommon.Con
12281236 },
12291237 }
12301238 }
1239+
1240+ // Add Syncthing server sidecar for pod-per-app cross-node filesystem sharing
1241+ if instanceType == SplunkStandalone || instanceType == SplunkIndexer || instanceType == SplunkSearchHead {
1242+ syncthingServerImage := os .Getenv ("RELATED_IMAGE_SYNCTHING_SERVER" )
1243+ if syncthingServerImage == "" {
1244+ syncthingServerImage = "493245399694.dkr.ecr.us-west-2.amazonaws.com/appruntime/ecr-repo/syncthing-server:latest"
1245+ }
1246+ podTemplateSpec .Spec .Containers = append (podTemplateSpec .Spec .Containers , corev1.Container {
1247+ Name : "syncthing-server" ,
1248+ Image : syncthingServerImage ,
1249+ ImagePullPolicy : corev1 .PullAlways ,
1250+ Ports : []corev1.ContainerPort {
1251+ {Name : "st-sync" , ContainerPort : 22000 , Protocol : corev1 .ProtocolTCP },
1252+ {Name : "st-api" , ContainerPort : 8384 , Protocol : corev1 .ProtocolTCP },
1253+ },
1254+ VolumeMounts : []corev1.VolumeMount {
1255+ {
1256+ Name : fmt .Sprintf (splcommon .PvcNamePrefix , splcommon .EtcVolumeStorage ),
1257+ MountPath : fmt .Sprintf (splcommon .SplunkMountDirecPrefix , splcommon .EtcVolumeStorage ),
1258+ },
1259+ {
1260+ Name : fmt .Sprintf (splcommon .PvcNamePrefix , splcommon .VarVolumeStorage ),
1261+ MountPath : fmt .Sprintf (splcommon .SplunkMountDirecPrefix , splcommon .VarVolumeStorage ),
1262+ },
1263+ },
1264+ Resources : corev1.ResourceRequirements {
1265+ Requests : corev1.ResourceList {
1266+ corev1 .ResourceCPU : resource .MustParse ("100m" ),
1267+ corev1 .ResourceMemory : resource .MustParse ("256Mi" ),
1268+ },
1269+ Limits : corev1.ResourceList {
1270+ corev1 .ResourceCPU : resource .MustParse ("500m" ),
1271+ corev1 .ResourceMemory : resource .MustParse ("512Mi" ),
1272+ },
1273+ },
1274+ })
1275+ }
12311276}
12321277
12331278func removeDuplicateEnvVars (sliceList []corev1.EnvVar ) []corev1.EnvVar {
0 commit comments