Create Discovery Service for Cache Clients in Amazon Elastic Kubernetes Service
In a standard environment, application connectivity is often managed via static IP addresses. However, within Amazon Elastic Kubernetes Service (EKS), pods are ephemeral and assigned dynamic IP addresses that change upon restart. To maintain stable communication, you must implement a Headless Discovery Service. This service acts as a communication bridge, allowing NCache client applications to discover the underlying pod IPs at runtime to initialize cache handles and perform distributed operations.
Create Discovery Amazon Elastic Kubernetes Service YAML File
The first step in creating a headless discovery service for your Amazon Elastic Kubernetes Service cluster is to create a YAML file. This file contains the required information a client application needs to connect to this service. Let's call this file cachediscovery.yaml and this is what it looks like:
Note
The parameters required to create this YAML file, ready to be deployed, are explained in the Properties table.
kind: Service
apiVersion: v1 # depends on underlying Kubernetes version
metadata:
name: cacheserver
labels:
app: cacheserver
spec:
clusterIP: None
selector:
app: ncache # same label as provided in the ncache deployment yaml
ports:
- name: management-tcp
port: 8250
targetPort: 8250
- name: management-http
port: 8251
targetPort: 8251
- name: client-port
port: 9800
targetPort: 9800
Tip
The clusterIP tag is set to none here which shows that this service will not have any public IP assigned to it. This factor is what makes this service a headless service.
Create Discovery Service inside Cluster
After creating the YAML file, you need to deploy this resource inside your EKS cluster. Follow the steps mentioned below to set up this discovery service.
To create a fully functional discovery service that the Amazon Elastic Kubernetes Service cluster uses to communicate with NCache clients outside of the cache cluster, execute the following command in the AWS command line interface.
kubectl create -f [dir]/cachediscovery.yamlTo get a list and status of all running services, execute the following command:
kubectl get service
After creating a headless discovery service for NCache clients, you need to create Access for NCache Management, explained in the next chapter.
See Also
Create NCache Resources in EKS
Create Access for NCache Management in EKS
Create NCache Client in EKS
Create NCache Client Deployment in EKS