Azure / service-fabric-mesh-preview

Service Fabric Mesh is the Service Fabric's serverless offering to enable developers to deploy containerized applications without managing infrastructure. Service Fabric Mesh , aka project “SeaBreeze” is currently available in private preview. This repository will be used for tracking bugs/feature requests as GitHub issues and for maintaining the latest documentation.
MIT License
82 stars 13 forks source link

Multiple exposed services - trying to deploy an SPA #77

Open benc-uk opened 6 years ago

benc-uk commented 6 years ago

How would I expose multiple services from the same app together? I have an SPA which consists of two components, one serving the SPA content, the other acting as a REST API. I've deployed these as a single sbz application which contains them both as services
As this is a SPA both services need to have publicly accessible endpoints (using bold here to denote sbz terminology)

In my network I've tried this

        "ingressConfig": {
          "layer4": [
            {
              "publicPort": "80",
              "applicationName": "spaApp",
              "serviceName": "spaFrontendService",
              "endpointName": "spaFrontendListener"
            },
            {
              "publicPort": "80",
              "applicationName": "spaApp",
              "serviceName": "spaApiService",
              "endpointName": "spaApiListener"
            }            
          ]
        }

But all I get is a single public IP address. How can I expose them both? Seems like they need to be on different networks, but that seems very wrong as they are all part of the same logical app The networking model here is unclear

benc-uk commented 6 years ago

I just tried creating two separate Microsoft.ServiceFabric/networks each pointing to the same applicationName but different serviceNames, and both networks got the same public IP address! Which was totally unexpected, and also still makes it impossible to connect to each service seperately

CESARDELATORRE commented 6 years ago

I think that for that case below, you'd need to use different ports, like:

spaFrontendService --> 80

spaApiService --> 88

I haven't seen a way in Seabreeze to use the same port with multiple URLs pointing to multiple endpoints, kind of like a reverse proxy with NGINX in Kubernetes. But I think that should be an important feature so you can publish a single HTTP port like 80.

Cesar.


From: Ben Coleman notifications@github.com Sent: Tuesday, April 17, 2018 11:53:13 AM To: Azure/seabreeze-preview-pr Cc: Subscribed Subject: [Azure/seabreeze-preview-pr] Multiple exposed services - trying to deploy an SPA (#77)

How would I expose multiple services from the same app together? I have an SPA which consists of two components, one serving the SPA content, the other acting as a REST API. I've deployed these as a single sbz application which contains them both as services As this is a SPA both services need to have publicly accessible endpoints (using bold here to denote sbz terminology)

In my network I've tried this

    "ingressConfig": {
      "layer4": [
        {
          "publicPort": "80",
          "applicationName": "spaApp",
          "serviceName": "spaFrontendService",
          "endpointName": "spaFrontendListener"
        },
        {
          "publicPort": "80",
          "applicationName": "spaApp",
          "serviceName": "spaApiService",
          "endpointName": "spaApiListener"
        }
      ]
    }

But all I get is a single public IP address. How can I expose them both? Seems like the need to be on different network but that seems very wrong as they are all part of the same logical app The networking model here is unclear

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Azure/seabreeze-preview-pr/issues/77, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABoh--njdf6-TaWbcRIzMA9TP9L2i2GKks5tpjoZgaJpZM4TY3Ch.

CESARDELATORRE commented 6 years ago

Basically, the following works ok:

Cesar.


From: Cesar De la Torre Llorente Sent: Tuesday, April 17, 2018 2:02:55 PM To: Azure/seabreeze-preview-pr; Azure/seabreeze-preview-pr Cc: Subscribed Subject: Re: [Azure/seabreeze-preview-pr] Multiple exposed services - trying to deploy an SPA (#77)

I think that for that case below, you'd need to use different ports, like:

spaFrontendService --> 80

spaApiService --> 88

I haven't seen a way in Seabreeze to use the same port with multiple URLs pointing to multiple endpoints, kind of like a reverse proxy with NGINX in Kubernetes. But I think that should be an important feature so you can publish a single HTTP port like 80.

Cesar.


From: Ben Coleman notifications@github.com Sent: Tuesday, April 17, 2018 11:53:13 AM To: Azure/seabreeze-preview-pr Cc: Subscribed Subject: [Azure/seabreeze-preview-pr] Multiple exposed services - trying to deploy an SPA (#77)

How would I expose multiple services from the same app together? I have an SPA which consists of two components, one serving the SPA content, the other acting as a REST API. I've deployed these as a single sbz application which contains them both as services As this is a SPA both services need to have publicly accessible endpoints (using bold here to denote sbz terminology)

In my network I've tried this

    "ingressConfig": {
      "layer4": [
        {
          "publicPort": "80",
          "applicationName": "spaApp",
          "serviceName": "spaFrontendService",
          "endpointName": "spaFrontendListener"
        },
        {
          "publicPort": "80",
          "applicationName": "spaApp",
          "serviceName": "spaApiService",
          "endpointName": "spaApiListener"
        }
      ]
    }

But all I get is a single public IP address. How can I expose them both? Seems like the need to be on different network but that seems very wrong as they are all part of the same logical app The networking model here is unclear

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Azure/seabreeze-preview-pr/issues/77, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABoh--njdf6-TaWbcRIzMA9TP9L2i2GKks5tpjoZgaJpZM4TY3Ch.

benc-uk commented 6 years ago

Thanks!

I've just tried that, but two things arise:

I definitely think this needs clarifying and documenting

CESARDELATORRE commented 6 years ago

Each service can run on port 80, but the internal port (all container's port could be 80 if you'd like).

But for the external ports published outside of the cluster/mesh, you'd need a different port or a different URL based on a reverse proxy. But I haven't seen how to do the second option in Seabreeze.

Cesar.


From: Ben Coleman notifications@github.com Sent: Tuesday, April 17, 2018 2:29:03 PM To: Azure/seabreeze-preview-pr Cc: Cesar De la Torre Llorente; Comment Subject: Re: [Azure/seabreeze-preview-pr] Multiple exposed services - trying to deploy an SPA (#77)

Thanks!

I've just tried that, but two things arise:

I definitely think this needs clarifying and documenting

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/Azure/seabreeze-preview-pr/issues/77#issuecomment-382153499, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABoh--Mq9dHFE6XRlfuDTYEgif-ejOhmks5tpl6fgaJpZM4TY3Ch.

CESARDELATORRE commented 6 years ago

Here you can see an example of two endpoints published outside SeaBreeze with different ports. https://github.com/Azure/seabreeze-preview-pr/blob/64a9856e3d3bbd3d20eb1a4b09bc21e6ca0ccc1e/samples/src/quickstart/Sbz/SbzVotingARM.json

The internal container's ports could be 80 for both, though. It depends on how the dockerfile of each container is configured.

benc-uk commented 6 years ago

Thanks. Using port 8080 for my second service finally worked. Seems like only ports 80 and 8080 can be used in this preview

CESARDELATORRE commented 6 years ago

Well, I just published the following app in port 88, so it must be a different reason?

http://52.170.253.101:88/

image

CESARDELATORRE commented 6 years ago

And other ports, as well, such as 5100:

http://40.121.204.36:5100/

image

benc-uk commented 6 years ago

Hi Cesar, Can you share your template for the 5100 example? The link you provided works here (so we can rule out local and ISP network issues) I'd like to try it out in my subscription. Thanks!

mattrowmsft commented 6 years ago

@benc-uk sorry before you spend too much time hunting this. I'm currently rooting out some bugs with port programming that were introduced recently. I think this is causing most of the port headaches.

sridmad commented 6 years ago

@benc-uk , With layer 4 ingress, each endpoint you want to expose externally has to be on an unique public port. We are looking at layer 7 ingress and when it is enabled, traffic sent to one public port can be routed to different backend services based on the URL path of the request.

Config will look something the following. We have not yet designed the Layer 7 ingress, so following is subject to change.

    "ingressConfig": {
      "layer7": [
        {
          "publicPort": "80",
          "applicationName": "spaApp",
          "serviceName": "spaFrontendService",
          "endpointName": "spaFrontendListener",
           **"path": "/web/"**
        },
        {
          "publicPort": "80",
          "applicationName": "spaApp",
          "serviceName": "spaApiService",
          "endpointName": "spaApiListener",
           **"path": "/api/"**
        }            
      ]
    }
benc-uk commented 6 years ago

Thanks for the feedback, good to see this layer 7 ingress capability as a core part of the platform. My SPA is currently designed with each micro-service having its own HTTP endpoint, so under the seabreeze model I think they will need separate networks, or run on different ports.

However this approach has many advantages in simplifying configuration while maintaining the separation internally. It has given me food for thought

benc-uk commented 6 years ago

Any update on Layer7 ingress support? Or some form of path based routing? The announcements at Ignite mention "Network and Gateway resources enable multiple-ingress and routing"

However I can't find any examples or docs to support this

robinmanuelthiel commented 5 years ago

I am also facing an issue exposing multiple applications (could be my stupidity as well): What I want to achieve is deploying two services (Web API and Chat Bot) and both expose them on different ports.

When doing that with the following script, only one of the two manages to start. Is that, because they are both exposing the same ports internally? Shouldn't that work?

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "apiVersion": "2018-07-01-preview",
      "name": "contosomaintenance",
      "type": "Microsoft.ServiceFabricMesh/applications",
      "location": "westeurope",
      "dependsOn": [
        "Microsoft.ServiceFabricMesh/networks/contosomaintenance-network"
      ],
      "properties": {
        "services": [
          {
            "name": "contosomaintenance-api",
            "properties": {
              "description": "Contoso Maintenance REST API",
              "osType": "Linux",
              "codePackages": [
                {
                  "name": "contosomaintenance-api",
                  "image": "robinmanuelthiel/contosomaintenance-api:latest",
                  "endpoints": [
                    {
                      "name": "http",
                      "port": 80
                    },
                    {
                      "name": "https",
                      "port": 443
                    }
                  ],
                  "resources": {
                    "requests": {
                      "cpu": "0.5",
                      "memoryInGB": "1"
                    }
                  }
                }
              ],
              "replicaCount": "1",
              "networkRefs": [
                {
                  "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'contosomaintenance-network')]"
                }
              ]
            }
          },
          {
            "name": "contosomaintenance-bot",
            "properties": {
              "description": "Contoso Maintenance Chat Bot",
              "osType": "Linux",
              "codePackages": [
                {
                  "name": "contosomaintenance-bot",
                  "image": "robinmanuelthiel/contosomaintenance-bot:latest",
                  "endpoints": [
                    {
                      "name": "http",
                      "port": 80
                    },
                    {
                      "name": "https",
                      "port": 443
                    }
                  ],
                  "resources": {
                    "requests": {
                      "cpu": "0.5",
                      "memoryInGB": "1"
                    }
                  }
                }
              ],
              "replicaCount": "1",
              "networkRefs": [
                {
                  "name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'contosomaintenance-network')]"
                }
              ]
            }
          }
        ]
      }
    },
    {
      "apiVersion": "2018-07-01-preview",
      "name": "contosomaintenance-network",
      "type": "Microsoft.ServiceFabricMesh/networks",
      "location": "westeurope",
      "dependsOn": [],
      "properties": {
        "description": "Contoso Maintenance Network",
        "addressPrefix": "10.0.0.0/22",
        "ingressConfig": {
          "layer4": [
            {
              "name": "contosomaintenance-api-ingress-http",
              "publicPort": "20001",
              "applicationName": "contosomaintenance",
              "serviceName": "contosomaintenance-api",
              "endpointName": "http"
            },
            {
              "name": "contosomaintenance-api-ingress-bot",
              "publicPort": "20002",
              "applicationName": "contosomaintenance",
              "serviceName": "contosomaintenance-bot",
              "endpointName": "http"
            }
          ]
        }
      }
    }
  ]
}

Just asked the same question on Stack Overflow: https://stackoverflow.com/questions/53619479/exposing-multiple-services-in-service-fabric-mesh