How to get Ingress to work with game servers with required ports with nodeports on azure

5/4/2020

My question is specific on the configuration of how to have an ingress controller, in my case the Nginx Ingress controller, work to have users be able to access game servers depending on the port they enter. I assume that they would plug in the ingress server External-IP and then the port that I have on the nodeport correct?

Service 1

apiVersion: v1
kind: Service
metadata:
  name: game-svc-0
spec:
  type: NodePort
  selector:
    instance: game-0
  ports:    
    - port: 25565
      targetPort: 25565
      nodePort: 30000 # (default: 30000-32767)

Service 2

apiVersion: v1
kind: Service
metadata:
  name: game-svc-1
spec:
  type: NodePort
  selector:
    instance: game-1
  ports:    
    - port: 25565
      targetPort: 25565
      nodePort: 30001 # (default: 30000-32767)

Ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: game-server-ingress
  namespace: ingress-basic
  annotations:
    kubernetes.io/ingress.class: nginx
    # nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: game-svc-0
          servicePort: 30000
      - backend:
          serviceName: game-svc-1
          servicePort: 30001

Where the stateful set's container port is 25565 as required by the game's docker container.

However when I create the server and run the command

kubectl describe ing game-server-ingress -n ingress-basic

My output says it cannot find certain endpoints. Is this because the ingress is in another namespace? I wouldn't assume this is the issue since this is almost verbatim of the example from microsoft's docs.

Name:             game-server-ingress
Namespace:        ingress-basic
Address:          {address1},{address2}
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *
                 game-svc-0:30000 (<error: endpoints "game-svc-0" not found>)
                 game-svc-1:30001 (<error: endpoints "game-svc-1" not found>)
Annotations:  kubernetes.io/ingress.class: nginx
              nginx.ingress.kubernetes.io/rewrite-target: /

Have I configured a part of the node ports incorrectly? The problem is the server input doesn't take in '/words' just an IP address and port as IPADDRESS:PORT. Is this something ingress can even do?

-- mjwrazor
kubernetes
kubernetes-ingress
nginx-ingress

0 Answers