OpenShift部署OptaPlanner排班应用后访问提示Not Found求助
Let’s walk through the most likely issues and fixes since your pods and services are reporting healthy status but the route isn’t serving the expected content:
Verify your route configuration details
First, check how your route maps to the application service. Runoc get routesto view the route's host, path, and target service. Ensure:- The
PATHcolumn is either empty (mapping to the service root) or set to/rosterif the app expects that context path. If the route uses/as the path but you’re accessing/roster, double-check if the app’s actual context path differs. - The target service and port match what your application uses. Run
oc get service <your-service-name>to confirm the service exposes the correct port (usually 8080 for Spring Boot apps like this one).
- The
Check the application’s context path directly in the pod
Sometimes the app simply isn’t listening on/roster. Jump into a running pod and test locally:oc rsh <your-pod-name> curl localhost:8080Or if you suspect the context path is
/roster:oc rsh <your-pod-name> curl localhost:8080/rosterIf you get a 404 here too, the app itself isn’t configured to serve content at that path. Check the app’s startup logs (via
oc logs <your-pod-name>) for lines mentioning "context path" or "servlet mapping" to confirm where content is served.Validate service-to-pod connectivity
Even if the service shows as active, ensure it routes traffic to your pods. Runoc describe service <your-service-name>and look at theEndpointssection—you should see your pod’s IP paired with the app’s port (e.g.,10.128.0.45:8080). If this section is empty, the service isn’t linked to your pod (check that pod labels match the service’s selector labels).Test routing from within the cluster
To rule out route-specific issues, test accessing the service directly from another cluster pod:oc run temp-test --image=busybox --rm -it -- curl <your-service-name>:8080/rosterIf this works, the problem is isolated to the OpenShift route configuration. If it fails, the issue lies between the service and application pod.
Check for unintended redirects or TLS settings
If your route has TLS enabled, check if it redirects HTTP traffic to HTTPS. Runoc describe route <your-route-name>and look forInsecureEdgeTerminationPolicy: Redirect. If set, try accessinghttps://localhost/rosterinstead—browsers sometimes hide redirects that lead to unexpected 404s.
By working through these steps, you’ll be able to pinpoint whether the issue stems from route mapping, application context path, or service-to-pod connectivity.
内容的提问来源于stack exchange,提问作者ajd

