You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot部署至Azure出现Internal Server Error求助

Let's break down this issue step by step—there are a few common culprits that cause an Internal Server Error when deploying a Spring Boot app to Kubernetes on Azure. Here's how to diagnose and fix them:

Step 1: Verify the Docker image works locally first

First, rule out issues with your Docker image itself. Run it locally to see if the app responds correctly:

docker run -p 8090:8090 <your-image-name>

Then hit http://localhost:8090 in your browser or use curl. If this fails, the problem is with your Docker setup, not Kubernetes/Azure.

Check your Dockerfile for red flags

Looking at your Dockerfile, a couple of things stand out:

  • Hardcoded absolute paths: You're copying the JAR to /Users/a/Documents/dev/intellij/dockerImages/—this path won't exist in a clean Java 8 container! Use a generic path like /app instead:
    FROM java:8
    COPY ./springsimple-1.0-SNAPSHOT.jar /app/
    WORKDIR /app
    EXPOSE 8090
    CMD ["java", "-jar", "springsimple-1.0-SNAPSHOT.jar"]
    
  • Confirm the JAR is in the build context: When you run docker build, make sure you're in the directory where springsimple-1.0-SNAPSHOT.jar lives, otherwise the COPY command will fail silently (check docker build logs for errors).
  • Check your Spring Boot app's port: Does your app actually listen on 8090? By default Spring Boot uses 8080. If you haven't set server.port=8090 in application.properties or application.yml, your EXPOSE directive is pointing to the wrong port.
Step 2: Inspect the Kubernetes Pod in Azure

If the local Docker run works, the issue is in your Kubernetes deployment. Let's check the Pod status and logs:

  1. Get the list of Pods:
kubectl get pods

Look for the testproject Pod—its status should be Running. If it's CrashLoopBackOff or Error, that means the container is failing to start.

  1. View the Pod logs to see what's going wrong:
kubectl logs testproject

This will show you the Spring Boot startup logs, which will tell you if there's an error loading the app, missing dependencies, or port conflicts.

  1. Check the Pod's details for any runtime issues:
kubectl describe pod testproject

Look at the Events section at the bottom—this will show if there were issues pulling the image from your registry, or if the container failed to start.

Step 3: Verify Kubernetes Service configuration (if you created one)

If your Pod is running but you get an Internal Server Error when accessing it, make sure your Kubernetes Service is pointing to the correct port. For example, if you created a Service with:

kubectl expose deployment testproject --type=LoadBalancer --port=80 --target-port=8090

Double-check that target-port matches the port your Spring Boot app is listening on. If you used the default 8080, change target-port to 8080.

Step 4: Check Azure-specific networking
  • Network Security Group (NSG) rules: Make sure the NSG associated with your Kubernetes cluster allows inbound traffic on the port you're using (8090 or 8080, plus the Service port if using LoadBalancer).
  • Ingress configuration (if used): If you're using an Ingress controller, ensure the routing rules are pointing to the correct Service and port.
Quick recap of fixes to try first
  • Fix your Dockerfile to use a non-hardcoded path and confirm the JAR is in the build context.
  • Verify your Spring Boot app's port matches what's in EXPOSE and your Kubernetes Service.
  • Check Pod logs for startup errors—this is almost always the quickest way to find the root cause.

内容的提问来源于stack exchange,提问作者marhg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:00:15