3333 ambientCodeRunnerImage string
3434 imagePullPolicy corev1.PullPolicy
3535 contentServiceImage string
36+ backendNamespace string
3637)
3738
3839func main () {
@@ -47,6 +48,12 @@ func main() {
4748 namespace = "default"
4849 }
4950
51+ // Get backend namespace from environment or use operator namespace
52+ backendNamespace = os .Getenv ("BACKEND_NAMESPACE" )
53+ if backendNamespace == "" {
54+ backendNamespace = namespace // Default to same namespace as operator
55+ }
56+
5057 // Get ambient-code runner image from environment or use default
5158 ambientCodeRunnerImage = os .Getenv ("AMBIENT_CODE_RUNNER_IMAGE" )
5259 if ambientCodeRunnerImage == "" {
@@ -391,7 +398,7 @@ func handleAgenticSessionEvent(obj *unstructured.Unstructured) error {
391398 {Name : "LLM_TEMPERATURE" , Value : fmt .Sprintf ("%.2f" , temperature )},
392399 {Name : "LLM_MAX_TOKENS" , Value : fmt .Sprintf ("%d" , maxTokens )},
393400 {Name : "TIMEOUT" , Value : fmt .Sprintf ("%d" , timeout )},
394- {Name : "BACKEND_API_URL" , Value : os . Getenv ( "BACKEND_API_URL" )},
401+ {Name : "BACKEND_API_URL" , Value : getBackendAPIURL ( )},
395402
396403 // 🔑 Git configuration environment variables
397404 {Name : "GIT_USER_NAME" , Value : gitUserName },
@@ -1003,6 +1010,20 @@ func updateProjectSettingsStatus(namespace, name string, statusUpdate map[string
10031010 return nil
10041011}
10051012
1013+ // getBackendAPIURL returns the fully qualified backend API URL for cross-namespace communication
1014+ func getBackendAPIURL () string {
1015+ // Check if a custom backend API URL is provided
1016+ if customURL := os .Getenv ("BACKEND_API_URL" ); customURL != "" {
1017+ // If it already contains a fully qualified domain, use it as-is
1018+ if strings .Contains (customURL , ".svc.cluster.local" ) || strings .Contains (customURL , "://" ) {
1019+ return customURL
1020+ }
1021+ }
1022+
1023+ // Construct fully qualified service name for cross-namespace communication
1024+ return fmt .Sprintf ("http://backend-service.%s.svc.cluster.local:8080/api" , backendNamespace )
1025+ }
1026+
10061027var (
10071028 boolPtr = func (b bool ) * bool { return & b }
10081029 int32Ptr = func (i int32 ) * int32 { return & i }
0 commit comments