I’m writing a Kubernetes operator to deploy individual, dedicated game servers, inside the same cluster. What would be the best method for exposing these servers outside of the cluster?
Requirements
- Servers must be individually addressable outside of the cluster. Dedicated game servers are isolated from each other and cannot be load balanced.
- Support TCP and UDP protocols. These are the primary protocols that the games will be communicating with.
- Manageable programatically. My custom resource is an individual server. Assocciating a server to something like an ingress is dangerous, as a single ingress resource contains the rules of other servers too.
- Scale to the upper limits of Kubernetes.
- Native to Kubernetes. This could be hosted anywhere, with no reliance on custom resources or tooling outside of my own project.
Ideas
I initially thought of an ingress
. However, ingress listeners and rules are not separate resources from the ingress itself. Modifying these rules programatically per individual server, could be very dangerous. This is the same with the listeners on the new Gateway API too.
I looked at nodeports
, but since the scope of nodeports are cluster wide, the theoretical limit per cluster is a single range of ports - far below 65535
.
The closest I’ve gotten so far is clusterIps
with externalIps
. From what I’m reading, this seems to work in a similar way to a nodePort, but the scope is placed on the externalIps. This means I could distribute the servers across a number of externalIps, scaling much more than nodeports.
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app.kubernetes.io/name: MyApp
ports:
- name: http
protocol: TCP
port: 80
targetPort: 49152
externalIPs:
- 198.51.100.32
I’m not sure if I’m misinterpreting the way that clusterIps
and externalIps
work.