agones
agones copied to clipboard
Set the hostName of the Pod to the name of the GameServer
Is your feature request related to a problem? Please describe.
If you want to connect from within a Agones cluster to a Pod that is backing a GameServer, you have to lookup the internal IP of the Pod to be able to do so.
If you know the name of the GameServer, it would be useful to be able to utilise a DNS record to connect to it from within a cluster.
Describe the solution you'd like
Set the hostName
value on the Pod to the same name as the GamseServer
(which is the same name as the pod) on creation.
If the end user want to have a DNS record for the Pod inside the cluster, much like one already can with StatefulSets, they can create a headless service to do so:
- https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-hostname-and-subdomain-fields
- https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id
Describe alternatives you've considered
People can lookup the internal IP through the Kubernetes API, but it requires some more coding to do so.
Additional context
https://agones.slack.com/archives/C9DGM5DS8/p1658939259987459
Isn't the pod name (which is the GS name) already the pod hostName ? Wouldn't setting Pod.spec.hostName = gs.Name
be a noop in that case ?
EDIT: After a bit of backtracking in that slack thread if found the reference to that piece of doc https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ that Mark linked.
Note: Because A or AAAA records are not created for Pod names, hostname is required for the Pod's A or AAAA record to be
created. A Pod with no hostname but with subdomain will only create the A or AAAA record for the headless Service (default-> subdomain.my-namespace.svc.cluster-domain.example), pointing to the Pod's IP address. Also, Pod needs to become > ready in order to have a record unless publishNotReadyAddresses=True is set on the Service.
@valentintorikian - I see you have a commit that would fix this. Would you like to send a PR? Thanks!