0

I have created an Azure Service Fabric Cluster using "Windows 2016 DataCenter with Containers" OS and enabled Reverse Proxy listening on Port 80 on the cluster. We intend to deploy our legacy ASP.NET MVC & WCF applications on this cluster.

In our existing deployment model we have services co-located on same host communicating to each other because of chatty communication and low latency requirements. Is it possible for apps hosted in windows container to communicate with other windows container apps on the same Node? Basically I would like to have Node affinity between two windows container apps on the same Service Fabric Node.

I tried it with a sample application and it looks like the only option is to use Private IP of container which is getting dynamically assigned. Is it possible to pass --ip-address parameter while instantiating containers on Service Fabric cluster?

[Update: 04/05/2017]

Service Fabric Cluster Version: 5.5.219.0

Total NodeTypes: 1

Total Nodes: 3

Both containers are deployed on all three nodes. Azure internet load balancer is used to expose Service Fabric Reverse Proxy. All services are accessing internally as well as externally via reverse proxy.

Gaurav

Gaurav
  • 895
  • 3
  • 14
  • 31

2 Answers2

1

There is what you can do now in the v5.5 release and what is coming in the next release.

For v5.5 Release This GitHub repo https://github.com/Azure-Samples/service-fabric-dotnet-containers shows how to communicate between Windows Containers where you can map a host port to the private port on the container using PortBinding policy in the Application manifest.

You can then communicate either called the Naming Service over REST (this is what this sample does) or as you say and is easier, with the ReverseProxy which has a URL format. If both containers are deployed on the same machine then the communication is via the local ReverseProxy and you get local calls between the containers. See https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reverseproxy. As Mikkel points out, you have to tell Service Fabric that you want the containers on the same VM, through placement constraints.

Note: for the GitHub sample above to work on your local machine you need to update the local dev manifest ClusterManifestTemplate.xml in the C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\NonSecure\FiveNode folder and change the IPAddressOrFQDN attribute from "localhost" to the actual IP of the machine it is running on. This is due to a Windows Server Network bug, documentated in the git repo above. i.e

<Node NodeName="_Node_0" IPAddressOrFQDN="ComputerFullName" IsSeedNode="true"  NodeTypeRef="NodeType0" FaultDomain="fd:/0" UpgradeDomain="0" />

becomes

<Node NodeName="_Node_0" IPAddressOrFQDN="192.1.3.50" IsSeedNode="true"  NodeTypeRef="NodeType0" FaultDomain="fd:/0" UpgradeDomain="0" />

Coming for v5.6 Release In the next release we have added a DNS server layered on top of the Naming Service, so that you can use DNS names in place of fabric:/ names used by the reverse proxy. This means that within the Service Fabric cluster you can call between the containers with http://[domainname]/path calls instead. Same rules apply for the calls between local containers on the same machine as for the reverse proxy.

  • Thanks for detailed response. I have added few more environment details above...Related to your statement "If both containers are deployed on the same machine then the communication is via the local ReverseProxy and you get local calls between the containers"...How do you enforce usage of local reverse proxy? If Service A in Container A is calling Service B in Container B then it would use URL with format http://:/ContainerASFAppB/ServiceB. Load balancer would randomly pick the reverse proxy present on any of the three nodes – Gaurav Apr 05 '17 at 19:11
  • I read about Placement constraints but in this case since both containers are present on all three nodes, it may not be of help. What I am trying to achieve is that the containers on same nodes talk to each other either via their host-name, ip-address or through local reverse-proxy. I did not find a way to specify hostname or ipaddress in either Application or Service Manifest. These values are getting randomly assigned by Service Fabric. So the only way to for me to approach is either use Node IP address or local reverse proxy. Due to a Win 2016 WinNAT limitation, I cannot use Host IP either. – Gaurav Apr 05 '17 at 19:25
0

Using Service affinity would be an option: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-resource-manager-advanced-placement-rules-affinity

  • Thanks Mikkel for sharing the link. I went through the documentation but it looks like this feature is useful for Service Fabric Stateless and Stateful services. I could not find any information regarding how container based apps can be co-located on service fabric node. – Gaurav Apr 05 '17 at 03:51
  • If you deploy containers as guest containers, they are basically stateless services. – Mikkel Mørk Hegnhøj Apr 05 '17 at 05:52