简体   繁体   English

端口绑定 - 12因子应用程序

[英]Port Binding - 12 Factor App

Whenever I deploy a spring boot app , it had embedded tomcat container. 每当我部署一个spring boot应用程序时,它都嵌入了tomcat容器。 It relys on container being available. 它依赖于容器可用。 Does it mean that these are not 12 factor app compliant as depends on runtime injection of webserver? 这是否意味着这些因素不符合Web服务器的运行时注入?

What does TCP routing mean for non-http services? TCP路由对非http服务意味着什么?

Port Binding 端口绑定

Export services via port binding. 通过端口绑定导出服务。 The 12-factor app is completely self-contained and does not rely on runtime injection of a web server into the execution environment to create web-facing service. 12因素应用程序是完全独立的,不依赖于将Web服务器运行时注入执行环境来创建面向Web的服务。

For Pivotal Cloud Foundry, non-HTTP services require TCP routing in order to be replatformed. 对于Pivotal Cloud Foundry,非HTTP服务需要TCP路由才能重新格式化。

When you run locally, a spring boot app, it runs with a default profile. 当您在本地运行Spring Boot应用程序时,它将使用default配置文件运行。 So, Spring will leverage your port and other settings at runtime. 因此,Spring将在运行时利用您的端口和其他设置。

When you push to cloud, a spring boot app runs with a cloud profile. 当您推送到云时,Spring启动应用程序将运行cloud配置文件。 In a cloud profile, port settings are dictated by the cloud and settings you provide are ignored. cloud配置文件中,端口设置由云指定,您提供的设置将被忽略。

In PCF, a Diego cell hosts all app instances. 在PCF中,Diego单元托管所有应用程序实例。 A Diego cell has its own CIDR block for apps its hosting. 迭戈小区有自己的CIDR块用于托管的应用程序。 So your app instance will get an IP from that range. 因此,您的应用实例将获得该范围内的IP。 And you cannot access the app by its ip. 并且您无法通过其IP访问该应用程序。

The Diego cell vm though, has the IP from the CIDR range of the network its running. 例如,Diego cell vm具有来自其运行的网络的CIDR范围的IP。 Diego cell also uses NAT-ing to map you app ip to a port on the Diego cell vm. Diego cell还使用NAT-ing将app ip映射到Diego cell vm上的端口。 That is how the traffic is routed to your app. 这就是流量路由到您的应用的方式。

As you can see, the Diego cell, in PCF, cannot rely that the port you provided. 如您所见,PCF中的Diego单元不能依赖您提供的端口。 Instead it will run the app where it can, and NAT to an available port. 相反,它将在可能的地方运行应用程序,并将NAT运行到可用端口。

Take a look at Diego Reference Architecture . 看看Diego Reference Architecture

As to your second question, Go-Routers in Cloud Foundry route requests to app instances. 至于您的第二个问题,Cloud Foundry中的Go-Routers将请求路由到应用实例。 By default only http/https traffic is enabled on Go-Routers. 默认情况下,仅在Go-Routers上启用http / https流量。 You can enable TCP Routing on Go-Routers. 您可以在Go-Routers上启用TCP路由。 This was added, I believe, in PCF 1.9. 我相信,这是在PCF 1.9中增加的。 Here's the documentation . 这是文档

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

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