When I create a deployment in Kubernetes (specifically Amazon EKS), it spins up N pods:
worker-node-dddf68987-67fsq 192.168.149.142
worker-node-dddf68987-f77ks 192.168.155.15
worker-node-dddf68987-zndn4 192.168.232.226And those pods can be resolved in DNS as (e.g.) 192-168-232-226.my-namespace.pod.cluster.local.
But they're not resolvable as (e.g.) worker-node-dddf68987-zndn4.my-namespace.pod.cluster.local. Why not?
Every answer I've seen says something like "well actually, you really want to look up the service". I don't.
My motivation is this: when connecting Erlang nodes into a cluster, the node name must match exactly on both ends, and I'd prefer my node name to be worker-node@worker-node-dddf68987-zndn4, rather than worker-node@192.168.232.226.
I can set the "server" node name by using hostname -f, but if that name's not discoverable in DNS, the "client" node can't connect to it.
I'm aware that by using a StatefulSet, I can permanently associate a name with a pod. That's not what I want. My nodes don't have any state. I don't mind that the name changes -- I'm using libcluster, which will automatically deal with Erlang cluster membership. I just want the names to be readable.
Aside: the dashed IP lookup is basically a hack:
# ping 1-1-1-1.default.pod.cluster.local
PING 1-1-1-1.default.pod.cluster.local (1.1.1.1) 56(84) bytes of data.
64 bytes from one.one.one.one (1.1.1.1): icmp_seq=1 ttl=52 time=1.97 msBecause kubernetes service creates an abstraction layer in front of pods in deployments and works as a load balancer for them. Pod names are volatile and will change once you recreate the deployment or modify it.
What you're trying to achieve can be done by creating a headless service to disable load balancing:
If there exists a headless service in the same namespace as the pod and with the same name as the subdomain, the cluster’s DNS Server also returns an A or AAAA record for the Pod’s fully qualified hostname.
Or just use StatefulSet for which a headless service is required
Each Pod in a StatefulSet derives its hostname from the name of the StatefulSet and the ordinal of the Pod.