Create Discovery Service for NCache Clients in AKS
Inside an AKS cluster, every pod is assigned with a dynamic IP address that is unknown to every other pod. To make sure that your client application creates a connection with NCache servers successfully, you need a service that exposes the NCache deployment pod's IP address for your application. So you need to create a headless discovery service that gives client application access to the pods running the cache service inside the Azure Kubernetes cluster.
Create Discovery Service YAML File
Create a YAML file for headless discovery service. Let's call this file discoveryservice.yaml and this is what it should look like:
Note
The parameters required to create this YAML file ready to be deployed are mentioned in the Properties table.
kind: Service
apiVersion: v1 # it depends on the underlying Kubernetes version
metadata:
name: cacheserver
labels:
app: cacheserver
spec:
clusterIP: None
selector:
app: ncache # same label as provided in the ncache YAML file
ports:
- name: management-tcp
port: 8250
targetPort: 8250
- name: client-port
port: 9800
targetPort: 9800
Tip
Here, the clusterIP
tag equals none, meaning that this service will not have any public IP assigned to it. This is what makes this service a headless service.
Create Discovery Service
- Run the following command to create a discovery service that the AKS cluster uses to provide a communication channel between NCache servers and client applications.
kubectl create -f [dir]/discoveryservice.yaml
- After all required services have been deployed, you can check whether the created pods are live or not by running the following command in Azure Cloud Shell:
kubectl get pods -o wide
- To get a list of all deployed services, run the following command:
kubectl get service
After the successful creation of the cache discovery service, the next step is to create a Gateway Service in AKS, as explained in the next chapter.
See Also
Create NCache Deployment in AKS
Create Gateway Service in AKS
Create NCache Client Deployment in AKS
Create Cache Cluster in AKS