Create NCache Cluster Service
The next step after successful cluster creation is to create NCache cluster service. This is the main service that represents the NCache servers running within the containers on the Service Fabric machines. This service uses Open configuration mode. Let us take a look at Open configuration mode and its usage:
Why to use Open Configuration mode
In Service Fabric, the networking mode can either be nat or Open. It uses nat networking mode by default. The open networking mode allows multiple containers to share the same port by allocating them individual IP addresses from the secondary IP address pool of the virtual machines they are running on. There is an added benefit in case of NCache service of allowing NCache containers to communicate across host boundaries when part of a clustered cache. For this specific reason the mode needs to be changed from the default nat mode. You can learn here more about the Open configuration mode and how to set it up.
Open Ports for Communication
For creating the service manifest file after setting up the Open configuration mode, open the following ports for communication:
The Management Port: The port on which the cache server listen for performing the management operations such as cache creation. The port number is 8250.
Client Port: The port for performing all the CRUD operations. The port number is 9800.
Create Service Manifest file
The service manifest file contains the path to the NCache server container images which are placed at DockerHub. It also contains the ports as endpoints as shown below:
<?xml version="1.0" encoding="utf-8"?> <ServiceManifest Name="NCacheServicePkg" Version="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ServiceTypes> <StatelessServiceType ServiceTypeName="NCacheServiceType" UseImplicitHost="true" /> </ServiceTypes> <CodePackage Name="Code" Version="1.0.0"> <EntryPoint> <!-- Follow this link for more information about deploying Windows containers to Service Fabric: https://aka.ms/sfguestcontainers --> <ContainerHost> <ImageName>alachisoft/ncache</ImageName> </ContainerHost> </EntryPoint> </CodePackage> <ConfigPackage Name="Config" Version="1.0.0" /> <Resources> <Endpoints> <Endpoint Name="cache-management" Protocol="tcp" UriScheme="tcp" Port="8250" CodePackageRef="Code" /> <Endpoint Name="cache-client" Protocol="tcp" UriScheme="tcp" Port="9800" CodePackageRef="Code" /> <Endpoint Name="bridge-management" Protocol="tcp" UriScheme="tcp" Port="8260" CodePackageRef="Code" /> <Endpoint Name="bridge-client" Protocol="tcp" UriScheme="tcp" Port="9900" CodePackageRef="Code" /> </Endpoints> </Resources> </ServiceManifest>