Create NCache Resource in EKS
To perform all managerial operations on your cache cluster, NCache can be deployed as a deployment pod inside your Amazon Elastic Kubernetes Cluster. You can create an NCache deployment pod inside your EKS cluster through the following steps.
Create Deployment YAML Files
After you have created your EKS cluster (explained in the previous chapter Create Elastic Kubernetes Cluster), you need to deploy NCache resources inside your cluster. For this purpose, you need to create the following YAML files:
- NCache Deployment
- NCache Service
- NCache Ingress
These files hold all the necessary information required to successfully run and manage NCache servers in EKS. Provided below is the description of these deployment files.
Note
The parameters required to create these YAML files ready to be deployed are explained in the Properties table.
Create NCache Deployment
This YAML file, ncachedeployment.yaml, contains all the necessary information including replica count, node selector, image repository and ports details required by your EKS cluster to create and run any number of NCache server pods that use the alachisoft/ncache:enterprise-server-linux-5.0.2 docker image. This image can be pulled from the NCache DockerHub repository.
The ncachedeployment.yaml contents are shown below:
kind: Deployment
apiVersion: apps/v1beta1 # it depends on the underlying Kubernetes version
metadata:
name: ncache-deployment
labels:
app: ncache
spec:
replicas: 2
template:
metadata:
labels:
app: ncache
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
containers:
- name: ncache
image: docker.io/alachisoft/ncache:enterprise-server-linux-5.0.2
ports:
- name: management-tcp
containerPort: 8250
- name: management-http
containerPort: 8251
- name: client-port
containerPort: 9800
Execute the following command in AWS command-line tool to run the NCache pods inside your EKS cluster:
kubectl create -f [dir]/ncachedeployment.yaml
Create NCache Service
NCache Service file builds a service on top of the NCache deployment inside your AWS Kubernetes cluster. The main purpose of this file is to expose the deployment from the server. Create this NCache service YAML file, ncacheservice.yaml as shown below to expose the NCache Web Manager that is running on port 8251.
apiVersion: v1
kind: Service
metadata:
name: "ncache-service"
spec:
ports:
- port: 180
targetPort: 8251
protocol: TCP
name: management-http
selector:
app: "ncache"
From AWS command line tool, run the following command to deploy this NCache service inside your cluster:
kubectl create -f [dir]/ncacheservice.yaml
Create NCache Ingress
The last YAML that you need to deploy in your EKS cluster is the ncacheingress.yaml file. This file contains the information needed to create a sticky session between a client application and NCache Web Manager running inside the Kubernetes cluster. The contents of this file are provided below:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ncache-ingress-nginx
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/affinity-mode: "persistent"
nginx.ingress.kubernetes.io/session-cookine-name: "route"
nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: ncache-service
servicePort: 180
As can be seen from the contents provided above, the ingress resource is implemented by the Nginx ingress controller and the annotations signify that we are using sticky sessions when accessing the Web Manager GUI.
Run the following command to deploy the ingress inside your cluster:
kubectl create -f [dir]/ncacheingress.yaml
After deploying the above provided YAML files, all the resources to run NCache servers and perform management operations on them through the NCache Web Manager will be in place.
Properties
Following are the properties of the parameters specific to Kubernetes that are required to create the YAML file.
Parameters | Description |
---|---|
kind |
This can be many different types like a Deployment, a Service, DaemonSet or StatefulSet. |
apiVersion |
Specifies the version of the kind and it depends on the underlying version of Kubernetes. |
metadata |
Specifies details of the deployment. |
name |
Specifies the name of your deployment. |
labels |
Specifies key-value pair of resources that are used for identification purpose inside the Kubernetes cluster. |
annotations |
Specifies arbitrary non-identifying metadata to objects inside the Kubernetes cluster. |
spec |
Specifies logical details of the deployment. |
imagePullSecrets |
Specifies the private registry from where the image needs to be pulled. |
replicas |
Specifies the number of replica pods to be created at the time of deployment. |
template |
Specifies the information required for pulling image and creating port connection. |
nodeSelector |
Specifies the node on which the underlying container needs to be hosted. |
clusterIP |
Specifies the cluster IP required for external communication. Setting its value as None means that the service will not be accessible outside the cluster. |
selector |
Specifies the parameters that define selection criteria of the services. |
type |
Specifies the type of the service to be created. |
sessionAffinity |
Specifies the parameter that decides the persistency of a session. |
containers |
Specifies parameters required for initializing image and ports. |
image |
Specifies the path of the image that needs to be pulled. |
resources |
Specifies CPU or memory allocation for a container. |
limits |
Specifies CPU or memory limit. |
requests |
Specifies CPU or memory request for a container. |
ports |
Specifies name and port number of the port required for communication. There can be one or multiple ports depending on your deployment. |
containerPort |
Specifies port number of the deployment ports. |
port |
Specifies a port number. |
targetPort |
Specifies the port that needs to be targeted against the provided port number. |
After creating NCache deployment, the next step is to create discovery service for NCache clients, explained in the next chapter.
See Also
Create Elastic Kubernetes Cluster
Create Discovery Service in EKS
Create Access for NCache Management in EKS
Create NCache Client in EKS