kubernetes how to call full service name instead of AWS node ip

9/24/2021

I'm running my application EKS cluster, few days back we encounter the issues, let say we have application pod is running with one replicas count in different AWS node lets call vm name as like below.

ams-99547bd55-9fp6r               1/1     Running   0          7m31s   10.255.114.81    ip-10-255-12-11.eu-central-1.compute.internal   
mongodb-58746b7584-z82nd          1/1     Running   0          21h   10.255.113.10   ip-10-255-12-11.eu-central-1.compute.internal

Here the my running serivces

NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
ams-service         NodePort    172.20.81.165    <none>        3030:30010/TCP               18m
mongodb-service     NodePort    172.20.158.81    <none>        27017:30003/TCP              15d

I have setting.conf.yaml file running as config map where i have application related configuration

apiVersion: v1
kind: ConfigMap
metadata:
  name: ama-settings
  labels:
    conf: ams-settings
data:
  config : |
 "git": {
      "prefixUrl": "ssh://git@10.255.12.11:30001/app-server/repos/ams/",
      "author": {
      "name": "app poc",
      "mail": "app@domain.com"
    },

      "mongodb": {
      "host": "10.255.12.11",
      "port": "30003",
      "database": "ams",
      "ssl": false,
     }

This is working as we expected, but in case if existing node ip where my pod is running, some of the reason when i'm deleting my running pod and trying to re-deploy that time my pod is placed in some other AWS node basically EC2 vm.

During this time my application is not working then I need edit my setting.conf.yaml file to update with new AWS node IP where my pod is running.

Here the question how to use the service name instead of AWS node IP, because we don't want change the ip address frequently in case if any existing VM is goes down.

-- Gowmi
kubernetes

1 Answer

9/24/2021

ideally, instead of using the AWS IP you should be using the 0.0.0.0/0 Refrence doc

example in Node

const cors = require("cors");
app.use(cors());

const port = process.env.PORT || 8000;
app.listen(port,"0.0.0.0" ,() => {
  console.log(`Server is running on port ${port}`);
});

however, if you want to add the service name :

you can use the full certified name, but I am not sure it will work on as host 0.0.0.0 would be better option

<service.name>.<namespace name>.svc.cluster.local

example

ams-service.default.svc.cluster.local
-- Harsh Manvar
Source: StackOverflow