From 018bdc0cc512b7a116169b5dc56be5a1a66db5ae Mon Sep 17 00:00:00 2001 From: andersonid Date: Sat, 4 Oct 2025 11:32:50 -0300 Subject: [PATCH] Fix route creation to work across different OpenShift clusters --- k8s/route.yaml | 3 ++- scripts/deploy-complete.sh | 9 +++++---- scripts/deploy-s2i.sh | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/k8s/route.yaml b/k8s/route.yaml index 21bbcb5..6638b2f 100644 --- a/k8s/route.yaml +++ b/k8s/route.yaml @@ -10,13 +10,14 @@ metadata: haproxy.router.openshift.io/timeout: "300s" haproxy.router.openshift.io/rate-limit: "100" spec: - host: oru.apps.shrocp4upi419ovn.lab.upshift.rdu2.redhat.com + # Let OpenShift generate the host automatically for different clusters to: kind: Service name: resource-governance-service weight: 100 port: targetPort: http + path: / tls: termination: edge insecureEdgeTerminationPolicy: Redirect diff --git a/scripts/deploy-complete.sh b/scripts/deploy-complete.sh index 591b7ce..2fe1f2e 100755 --- a/scripts/deploy-complete.sh +++ b/scripts/deploy-complete.sh @@ -66,9 +66,9 @@ oc apply -f k8s/deployment.yaml echo -e "${YELLOW}Applying Service...${NC}" oc apply -f k8s/service.yaml -# Apply Route -echo -e "${YELLOW}Applying Route...${NC}" -oc apply -f k8s/route.yaml +# Create Route (let OpenShift generate host automatically) +echo -e "${YELLOW}Creating Route...${NC}" +oc expose service resource-governance-service -n $NAMESPACE --name=resource-governance-route --path=/ # Wait for deployment to be ready echo -e "${YELLOW}Waiting for deployment to be ready...${NC}" @@ -92,9 +92,10 @@ echo -e "${YELLOW}Getting application URL...${NC}" # Wait a bit to ensure route is ready sleep 5 -# Check if route exists +# Check if route exists and get URL if oc get route resource-governance-route -n $NAMESPACE > /dev/null 2>&1; then ROUTE_URL=$(oc get route resource-governance-route -n $NAMESPACE -o jsonpath='{.spec.host}') + echo -e "${GREEN}SUCCESS: Route created with host: $ROUTE_URL${NC}" else echo -e "${YELLOW}WARNING: Route not found, checking available routes...${NC}" oc get routes -n $NAMESPACE diff --git a/scripts/deploy-s2i.sh b/scripts/deploy-s2i.sh index 2f8cdcd..6499c2c 100755 --- a/scripts/deploy-s2i.sh +++ b/scripts/deploy-s2i.sh @@ -208,10 +208,10 @@ print_status "Step 9: Applying Service..." oc apply -f "$K8S_DIR/service.yaml" print_success "Service applied successfully" -# Step 10: Apply Route (use the correct route from manifests) -print_status "Step 10: Applying Route..." -oc apply -f "$K8S_DIR/route.yaml" -print_success "Route applied successfully" +# Step 10: Create Route (let OpenShift generate host automatically) +print_status "Step 10: Creating Route..." +oc expose service resource-governance-service -n "$NAMESPACE" --name=resource-governance-route --path=/ +print_success "Route created successfully" # Step 11: Get application URL print_status "Step 11: Getting application URL..."