Fix route creation to work across different OpenShift clusters

This commit is contained in:
2025-10-04 11:32:50 -03:00
parent 14900fc27f
commit 018bdc0cc5
3 changed files with 11 additions and 9 deletions

View File

@@ -10,13 +10,14 @@ metadata:
haproxy.router.openshift.io/timeout: "300s" haproxy.router.openshift.io/timeout: "300s"
haproxy.router.openshift.io/rate-limit: "100" haproxy.router.openshift.io/rate-limit: "100"
spec: spec:
host: oru.apps.shrocp4upi419ovn.lab.upshift.rdu2.redhat.com # Let OpenShift generate the host automatically for different clusters
to: to:
kind: Service kind: Service
name: resource-governance-service name: resource-governance-service
weight: 100 weight: 100
port: port:
targetPort: http targetPort: http
path: /
tls: tls:
termination: edge termination: edge
insecureEdgeTerminationPolicy: Redirect insecureEdgeTerminationPolicy: Redirect

View File

@@ -66,9 +66,9 @@ oc apply -f k8s/deployment.yaml
echo -e "${YELLOW}Applying Service...${NC}" echo -e "${YELLOW}Applying Service...${NC}"
oc apply -f k8s/service.yaml oc apply -f k8s/service.yaml
# Apply Route # Create Route (let OpenShift generate host automatically)
echo -e "${YELLOW}Applying Route...${NC}" echo -e "${YELLOW}Creating Route...${NC}"
oc apply -f k8s/route.yaml oc expose service resource-governance-service -n $NAMESPACE --name=resource-governance-route --path=/
# Wait for deployment to be ready # Wait for deployment to be ready
echo -e "${YELLOW}Waiting for deployment to be ready...${NC}" 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 # Wait a bit to ensure route is ready
sleep 5 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 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}') 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 else
echo -e "${YELLOW}WARNING: Route not found, checking available routes...${NC}" echo -e "${YELLOW}WARNING: Route not found, checking available routes...${NC}"
oc get routes -n $NAMESPACE oc get routes -n $NAMESPACE

View File

@@ -208,10 +208,10 @@ print_status "Step 9: Applying Service..."
oc apply -f "$K8S_DIR/service.yaml" oc apply -f "$K8S_DIR/service.yaml"
print_success "Service applied successfully" print_success "Service applied successfully"
# Step 10: Apply Route (use the correct route from manifests) # Step 10: Create Route (let OpenShift generate host automatically)
print_status "Step 10: Applying Route..." print_status "Step 10: Creating Route..."
oc apply -f "$K8S_DIR/route.yaml" oc expose service resource-governance-service -n "$NAMESPACE" --name=resource-governance-route --path=/
print_success "Route applied successfully" print_success "Route created successfully"
# Step 11: Get application URL # Step 11: Get application URL
print_status "Step 11: Getting application URL..." print_status "Step 11: Getting application URL..."