请我在 docker 容器中的 apache tomcat 8.5.56 上运行 .war 应用程序,一切正常,但是当我在 Kubernetes 上创建部署容器时,我可以访问我的应用程序欢迎页面:我收到错误消息
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/SmartClass] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.56
请问有人知道怎么解决吗?对于部署,我刚刚将 .war 文件复制到
/opt/apache-tomcat/webapps/
我已将 server.xml 文件复制到 /opt/apache-tomcat/conf/
最佳答案
看起来问题与与应用程序的连接有关。
kubectl expose deployment tomcat-example --type=NodePort --name=example-service
kubectl describe services example-service
输出类似于:Name: example-service
Namespace: default
Labels: run=lexample
Annotations: <none>
Selector: run=example
Type: NodePort
IP: 10.32.0.16
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
NodePort: <unset> 30000/TCP
Endpoints: 10.200.1.4:8080,10.200.2.5:8080
Session Affinity: None
Events: <none>
记下服务的 NodePort 值。例如,在上述输出中,NodePort 值为 30000。kubectl get pods --selector="run=example" --output=wide
输出类似于:NAME READY STATUS ... IP NODE
tomcat-2895499144-bsbk5 1/1 Running ... 10.200.1.4 worker1
tomcat-2895499144-m1pwt 1/1 Running ... 10.200.2.5 worker2
kubectl cluster-info
查看节点地址.如果您使用的是 Google Compute Engine 实例,则可以使用 gcloud compute instances list
命令以查看节点的公共(public)地址。curl http://<public-node-ip>:<node-port>
在哪里 <public-node-ip>
是您节点的公共(public) IP 地址,<node-port>
是您的服务的 NodePort 值。请根据您使用的正确名称和值调整上述命令。
关于docker - 容器 docker & Kubernetes apache tomcat 8.5.56 http status 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63591728/