NodeJS app with Cloud Map

In order to leverage the integration between the NodeJS app running in the EKS cluster and the AWS Cloud Map service, we will be using the ExternalDNS Kubernetes connector.

Since we are using the AWS App Mesh Controller For K8s and it is already integrated with Cloud Map, let’s change the Virtual Node configuration, so it can register the Pods IP addresses to the Cloud Map:

# Update the Virtual Node yaml file
cat <<EOF > ~/environment/eks-scripts/virtual-node.yml
kind: VirtualNode
  name: nodejs-app
  namespace: appmesh-workshop-ns
  meshName: appmesh-workshop
    - portMapping:
        port: 3000
        protocol: http
      namespaceName: appmeshworkshop.pvt.local
      serviceName: nodejs

# Apply the configuration
kubectl apply -f  ~/environment/eks-scripts/virtual-node.yml

After applying these changes, your pods IP Addresses will be added to the appmeshworkshop.pvt.local domain name, previously created in the Cloud Map. You can check that everything is working properly by using the AWS cli command bellow:

aws servicediscovery discover-instances \
--namespace appmeshworkshop.pvt.local \
--service-name nodejs

You can compare the IP addresses presented in the Instance ID fields with your Pods IP Addresses presented in the IP field of the following command:

kubectl get pods -n appmesh-workshop-ns -o wide

Or you can access the Cloud Map console, click in the appmeshworkshop.pvt.local domain name and then in the nodejs service name to see that your pods are registered under Service instances:

cloud map