简体   繁体   English

暴露Pod的tomcat端口

[英]Expose pod's tomcat port

I have the bare metall kubernetes pod running tomcat application on port 8085. If it would be common server, the app would be accessible via http://<server-ip>:8085/app . 我有在端口8085上运行tomcat应用程序的裸机kubernetes pod。如果它是通用服务器,则可以通过http://<server-ip>:8085/app访问该应用http://<server-ip>:8085/app My goal is to expose the tomcat on Kubernetes node's address and the same port as used in tomcat. 我的目标是在tomcat的Kubernetes节点地址和端口上公开tomcat。

I am able to expose and access app using Node Port service - but it is inconvenient that port is always different. 我可以使用节点端口服务公开和访问应用程序-但是端口总是不同的,这很不方便。 I tried to setup traefik ingress: 我试图设置traefik入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-tag2
spec:
  rules:
    - host: kubernetes.example.com #in my conf I use node's domain name
      http:
        paths:
        - path: /test
          backend:
            serviceName: test-tag2
            servicePort: 8085

And I can see result in Traefik's dashboard, but still if I navigate to http://kubernetes.example.com/test/app I get nothing. 而且我可以在Traefik的信息中心中看到结果,但是如果我浏览到http://kubernetes.example.com/test/app ,仍然看不到任何结果。

I've tried a bunch of ways to configure that and still no luck. 我尝试了很多方法来配置它,但还是没有运气。 Is it actually possible to expose my pod in this way? 实际上有可能以这种方式暴露我的豆荚吗?

Did you try specifying a nodePort value in the service yaml? 您是否尝试在服务Yaml中指定nodePort值? If specified, kubernetes will create service on the specified NodePort. 如果指定,kubernetes将在指定的NodePort上创建服务。 If the nodePort is not available , kubernetes doesn't create the service. 如果nodePort不可用,kubernetes不会创建服务。

Refer to this answer for more details: https://stackoverflow.com/a/43944385/1237402 请参阅此答案以获取更多详细信息: https : //stackoverflow.com/a/43944385/1237402

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM