Create Cache Cluster in Amazon Elastic Kubernetes Service
After deploying all necessary services, now you need to create a cache cluster inside your Amazon Elastic Kubernetes Service cluster. You can create a cache cluster either through NCache Management Center or through NCache PowerShell module (ncacheps).
Note
You can only use NCache PowerShell module if your NCache client image is deployed using .NET SDK instead of runtime.
Amazon Elastic Kubernetes Service: Using NCache Management Center
Follow the steps mentioned below to create a cache cluster through NCache Management Center.
- To access the NCache Management Center within the Amazon Elastic Kubernetes Service cluster, you need the URL of the NCache ingress. Execute the following command to get this URL:
kubectl get ingresses
Assuming you’ve named your NCache ingress resource as ncache, you will get something like the following output if successful:
Name HOSTS ADDRESS PORTS AGE
ncache * xxx.<eks-region>.elb.amazonaws.com 80 32s
- Copy the value under the ADDRESS into your browser address bar and you will be directed the NCache Management Center service on one of the cache nodes running inside the Amazon Elastic Kubernetes Service cluster.
From here you need to create a cache cluster. Follow the steps provided in Create New Clustered Cache to create a new cache cluster using NCache Management Center.
Important
Make sure the server IP addresses are the same as the ones shown in the result of the following command
kubectl get pods -l app=nccache -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 by executing the following command in AWS command line interface:
kubectl exec <client_pod_name> -- pwsh -NoExit
Follow the steps mentioned in Create Cache Cluster to create a cache cluster and add nodes to it through NCache PowerShell.
Important
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 -l app=ncache -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, connect clients to the cache. You can do this by following any of the given methods:
Using GetCache() API
Connect to the cache using the GetCache() method of NCache.
To connect clients to your cache, follow the steps provided in Connect to 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
- Go to your client.ncconf file placed at
%NCHOME%/config
in Windows and atopt\ncache\config
in Linux machines. - Add the name of the cache headless discovery service created earlier in Create Discovery Service in Amazon Elastic Kubernetes Service 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
Now that you have your cluster set up, you need to run your client application by executing the following command in the AWS command line interface.
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 in EKS
Create NCache Client Deployment in EKS
Monitor NCache Cluster and Clients in EKS
Adding Cache Servers in EKS at Runtime
Removing Cache Servers in EKS at Runtime