• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Show / Hide Table of Contents

Create NCache Client Deployment in AKS

To run NCache client in your Azure Kubernetes cluster, you need to deploy your client application in the cluster. There are multiple ways of creating NCache client deployment and these vary depending upon your requirements.

Use NCache Client Dockerfile

You can create your NCache client dockerfile that contains the commands to create a container image using either runtime .NET or .NET SDK. This allows you to use both InProc and OutProc caches.

Follow the steps mentioned below to start creating your client dockerfile.

  • Access the dockerfile provided by Alachisoft from:
    https://github.com/Alachisoft/NCache-Docker/tree/master/enterprise/client/

    • Place NCache installation setup in the Resources folder.
Note

In case of .NET SDK, you need to change the base image tag as shown below and this will allow access to runtime and other packages like PowerShell tool.

FROM mcr.microsoft.com/dotnet/core/sdk

Method 1

  • Add your client application in the Resources folder.
  • Go to startup.sh in the Resources folder.
  • Add the name of your client application in place of sleep infinity.
  • Save the startup.sh file.

Method 2

  • In the dockerfile, add the path to your client application under the COPY command and save the file.
COPY [application path]
  • Go to the startup.sh file and replace the sleep infinity tag with the path of your application and save the file.
Tip

You can simply add your client application path in the ENTRYPOINT section of the dockerfile and spare the need of using startup.sh altogether.

After you have finished editing the client dockerfile, go to your build environment and execute the following commands. These commands convert your client application's dockerfile into a container image and upload it on the container registry.

docker build . -t [image tag]
docker push [repository]:[image tag]
Note

You need to have docker installed on your machine to create your client docker image and you need to run this command from inside the directory containing your dockerfile.

.NET SDK to Access PowerShell

The plus point about using .NET SDK is that it comes packed with not only runtime but also PowerShell tool. Hence, in order to automate scripting, it is recommended to use .NET SDK environment.

Execute the following command on a shell platform to get access to PowerShell tool inside your Kubernetes cluster:

kubectl exec pod-name -- pwsh -NoExit

You can verify that you have entered PowerShell by the tag PS:>.

Now, you need to import NCache PowerShell module to start using NCache specific PowerShell tools.

Note

To use NCache PowerShell module, NCache must be installed on your machine.

Import-Module /opt/ncache/bin/tools/ncacheps

This will allow you to execute PowerShell commands on any of the pods present inside the Kubernetes cluster. From here on, you can start, stop, add, remove nodes all while staying inside the AKS cluster.

Embed NCache Client Libraries in Application

In case you do not have NCache installed on the machine that is running your client application, then you can use NuGet packages to deploy NCache client in your Kubernetes cluster. This only allows access to InProc caches.

Install NuGet packages provided by Alachisoft in your client application to use NCache without running NCache as client.

  • You will find the required NuGet packages at NCache NuGet Packages

  • To install these packages in your client application, follow the steps mentioned in Install NuGet in Microsoft Visual Studio

Once the packages have been successfully installed, create a docker image of your client application.

Create Client Deployment YAML file

Here, you need to create another YAML file for deploying client in your Kubernetes cluster. Let's call this file client.yaml.

Note

The parameters required to create this YAML file ready to be deployed are mentioned in the Properties table.

kind: Deployment
apiVersion: apps/v1beta1    # it depends on the underlying Kubernetes version 
metadata:
  name: client
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: client
    spec:
      imagePullSecrets:
      - name: client-private 
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
      - name: client
        image: # Your docker client image here 
        ports:
        - name: port1
          containerPort: 8250
        - name: port2
          containerPort: 8251
        - name: port3
          containerPort: 9800

To deploy this file as a pod in the Kubernetes cluster, execute the following command in the Azure Cloud Shell:

kubectl create -f [dir]/client.yaml 

The next step is to create NCache cache cluster, explained in the next chapter.

See Also

Create Discovery Service in AKS
Create Cache Cluster in AKS
Monitor NCache Cluster and Clients in AKS
Adding Cache Servers in AKS at Runtime

Back to top Copyright © 2017 Alachisoft