azure内部服务器错误上的春季启动错误 [英] spring boot on azure Internal Server Error

查看:76
本文介绍了azure内部服务器错误上的春季启动错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的"Hello"弹簧启动应用程序

I have a very simple "Hello" spring-boot application

@RestController
public class HelloWorld {
    @RequestMapping("/")
    public String sayHello() {
        return "Hello Spring Boot!!";
    }
}

我打包了Dockerfile

I packaged Dockerfile

FROM java:8
COPY ./springsimple-1.0-SNAPSHOT.jar /Users/a/Documents/dev/intellij/dockerImages/
WORKDIR /Users/a/Documents/dev/intellij/dockerImages/  
EXPOSE 8090
CMD ["java", "-jar", "springsimple-1.0-SNAPSHOT.jar"]

并进入我的容器注册表并进行部署

and pulled into my container registry and deployed it

amhg$ kubectl run testproject --image acontainerregistry.azurecr.io/hellospring:v1 
    deployment.apps "testproject" created
amhg$ kubectl expose deployments testproject --port=5000 --type=LoadBalancer
    service "testproject" exposed

命令kubectl取得豆荚

command kubectl get pods

NAME                               READY     STATUS             RESTARTS   AGE
    testproject-bdf5b54d-gkk92         1/1       Running            0          41s

但是,当我尝试执行命令(从127.0.0.1:8001开始使用)时,出现了错误消息:

However when I try the command (Starting to serve on 127.0.0.1:8001) I got the error:

 amhg$ curl http://127.0.0.1:8001/api/v1/proxy/namespaces/default/pods/testproject-bdf5b54d-gkk92/
    Internal Server Error

缺少什么?

吊舱的描述是

amhg$ kubectl describe pod testproject-bdf5b54d-gkk92
Name:           testproject-bdf5b54d-gkk92
Namespace:      default
Node:           aks-nodepool1-39744669-0/10.240.0.4
Start Time:     Thu, 19 Apr 2018 13:13:20 +0200
Labels:         pod-template-hash=68916108
                run=testproject
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"testproject-bdf5b54d","uid":"aa99808e-43c2-11e8-9537-0a58ac1f0f4...
Status:         Running
IP:             10.244.0.40
Controlled By:  ReplicaSet/testproject-bdf5b54d
Containers:
  testproject:
    Container ID:   docker://6ed3878fa4476a5d2e56f0ba70908742702709c7505c7b19989efc6ff658ea55
    Image:          acontainerregistry.azurecr.io/hellospring:v1
    Image ID:       docker-pullable://acontainerregistry.azurecr.io/azure-vote-front@sha256:e2af252d275c99b802e21b3b469c75b256d7812ee71d7582cd759bd4faf5a6ec
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Thu, 19 Apr 2018 13:13:21 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-vkpjm (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          True 
  PodScheduled   True 
Volumes:
  default-token-vkpjm:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-vkpjm
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.alpha.kubernetes.io/notReady:NoExecute for 300s
                 node.alpha.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason                 Age   From                               Message
  ----    ------                 ----  ----                               -------
  Normal  Scheduled              57m   default-scheduler                  Successfully assigned testproject-bdf5b54d-gkk92 to aks-nodepool1-39744669-0
  Normal  SuccessfulMountVolume  57m   kubelet, aks-nodepool1-39744669-0  MountVolume.SetUp succeeded for volume "default-token-vkpjm"
  Normal  Pulled                 57m   kubelet, aks-nodepool1-39744669-0  Container image "acontainerregistry.azurecr.io/hellospring:v1" already present on machine
  Normal  Created                57m   kubelet, aks-nodepool1-39744669-0  Created container
  Normal  Started                57m   kubelet, aks-nodepool1-39744669-0  Started container

推荐答案

让我们从头开始:最好使用YAML配置文件对Kubernetes进行任何操作.如果出现问题,它将帮助您进行调试,并在以后重复您的操作.

Let's start from the beginning: it is always better to use YAML config files to do anything with Kubernetes. It will help you with debugging if something goes wrong and repeat your action in future.

首先,您使用以下命令创建广告连播:

First, you use the command to create the pod:

kubectl运行testproject --image acontainerregistry.azurecr.io/hellospring:v1

kubectl run testproject --image acontainerregistry.azurecr.io/hellospring:v1

YAML如下所示:

apiVersion: v1
kind: Pod
metadata:
  name: test-app
spec:
  containers:
  - name: java-app
    image: acontainerregistry.azurecr.io/hellospring:v1
    ports:
    - containerPort: 8090

,您可以将其作为命令应用

and you can apply it as a command:

kubectl apply -f ./pod.yaml

得到的结果与运行命令时得到的结果相同,但是除此之外,您还有将来可以使用的配置文件.

You get the same result as while running your command, but additionally you have the config file which can be used in future.

您正尝试使用以下命令公开您的广告连播:

You`re trying to expose your pod using command:

kubectl公开部署testproject --port = 5000 --type = LoadBalancer

kubectl expose deployments testproject --port=5000 --type=LoadBalancer

您的服务的YAML如下:

YAML for your service looks like:

apiVersion: v1
kind: Service
metadata:
  name: java-service
  labels:
    name: test-app
spec:
  type: LoadBalancer
  ports:
  - port: 5000
    targetPort: 8090
    name: http
  selector:
    name: test-app

做同样的事情但使用YAML可以描述更多内容,并确保您不会错过任何内容.

Doing the same but with using YAML allows to describe more and be sure you don't miss anything.

您试图卷曲localhost,但是我不确定您从该命令中期望得到什么:

You tried to curl the localhost but I`m not sure what did you expect from this command:

amhg $ curl > http:///127.0.0.1:8001/api/v1/proxy/namespaces/default/pods/testproject-bdf5b54d-gkk92/ 服务器内部错误

amhg$ curl http://127.0.0.1:8001/api/v1/proxy/namespaces/default/pods/testproject-bdf5b54d-gkk92/ Internal Server Error

创建服务后,请致电kubectl describe service $service_name,您可以在此处找到它:

After you create the service, you call kubectl describe service $service_name, which you can find here:

LoadBalancer Ingress:     XX.XX.XX.XX
Port:                     http  5000/TCP

您可以卷曲该地址并从应用程序中收到答案.

You can curl this address and receive the answer from your application.

curl -v XX.XX.XX.XX:5000

不要忘记打开Azure防火墙上的端口.

Don't forget to open the port on Azure firewall.

这篇关于azure内部服务器错误上的春季启动错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆