Skip to content

Commit a709748

Browse files
committed
namespace must be provided so request knows where to go
Signed-off-by: Ryan Cook <[email protected]>
1 parent b1f2cca commit a709748

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

components/manifests/operator-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ spec:
2424
valueFrom:
2525
fieldRef:
2626
fieldPath: metadata.namespace
27+
- name: BACKEND_NAMESPACE
28+
valueFrom:
29+
fieldRef:
30+
fieldPath: metadata.namespace
2731
- name: BACKEND_API_URL
2832
value: "http://backend-service:8080/api"
2933
- name: AMBIENT_CODE_RUNNER_IMAGE

components/operator/main.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var (
3333
ambientCodeRunnerImage string
3434
imagePullPolicy corev1.PullPolicy
3535
contentServiceImage string
36+
backendNamespace string
3637
)
3738

3839
func 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+
10061027
var (
10071028
boolPtr = func(b bool) *bool { return &b }
10081029
int32Ptr = func(i int32) *int32 { return &i }

0 commit comments

Comments
 (0)