Create NCache Cluster in AKS
After deploying all necessary services, now you need to create a cache cluster inside your AKS cluster. There are two ways to do this, one is through NCache Web Manager and the other is through NCache PowerShell tool (ncacheps).
Note
You can use NCache PowerShell tool only if your client application is deployed using .NET SDK. Refer to Create NCache Client Deployment in AKS to deploy client with .NET SDK.
Using NCache Web Manager
Follow the steps mentioned below to create a cache cluster through NCache Web Manager.
Execute the following command to access gateway IP address.
kubectl get service
Copy the Public IP from the result of the previously executed command.
Paste that IP in a web browser of your choice followed by NCache web management port number such as xx.xx.xx.xx:8251. This will lead you to NCache Web Manager at one of the cache nodes. From there you need to create a cache cluster.
Follow the steps provided in Create New Clustered Cache to create a new cache cluster using NCache web manager.
Important
Make sure the server IP addresses are the same as the ones shown in the result of the following command
kubectl get pods -o wide
Using PowerShell
You can create a cluster and add nodes to it through NCache PowerShell tool. Follow the steps provided below:
- Run NCache PowerShell tool.
- Follow the steps mentioned in Create Cache Cluster to create a cache cluster and add nodes to it through NCache PowerShell.
Important
The server IP here should be the Public IP address available when the following command is executed:
kubectl get service
The node IPs when adding server nodes to the cluster should be the same as the IPs mentioned when the following command is executed:
kubectl get pods -o wide
Note
Start cache on all server nodes.
Connect Clients to Cache
After the cache cluster is created and the cache is started on all nodes, you need to connect clients to the cache. Follow either of the provided methods to do this.
Using GetCache() API
Connect to the cache using the GetCache() method of NCache.
Follow the steps mentioned in Connect to Cache to connect clients to your cache.
The following code snippet shows how the cache discovery service can be introduced when initializing the cache handle:
ICache cache = CacheManager.GetCache("democlusteredcache", new CacheConnectionOptions
{
ServerList = new List<ServerInfo> { new ServerInfo("cacheserver")}, // other parameters
});
Using the Client Config File
- Access client.ncconf file placed at
%NCHOME%/config
in Windows and atopt\ncache\config
in Linux machines. - Add the name of the cache discovery service created earlier in Create Discovery Service in AKS in the
<server name>
tag under the name of your cache cluster as shown below:
<cache id="democlusteredcache" ...">
<server name="cacheserver"/>
</cache>
Run NCache Client
Run your client application after setting up the cache cluster in AKS by executing the following command in Azure Cloud Shell:
kubectl exec --namespace=ncache client-podname -- /app/clientapplication/run.sh democlusteredcache cacheserver
Once the cache cluster is formed and clients are connected to it, you can monitor your cache cluster and clients, explained in the next chapter.
See Also
Create NCache Client Deployment in AKS
Monitor NCache Cluster and Clients in AKS
Adding Cache Servers in AKS at Runtime
Removing Cache Servers in AKS at Runtime