<p>I have a set of pods running based on the following fleet:</p>
<pre><code>apiVersion: &quot;agones.dev/v1&quot;
kind: Fleet
metadata:
  name: bungee
spec:
  replicas: 2
  template:
    metadata:
      labels:
        run: bungee
    spec:
      ports:
        - name: default
          containerPort: 25565
          protocol: TCP
      template:
        spec:
          containers:
            - name: bungee
              image: a/b:test
</code></pre>
<p>I can access these pods outside the cluster with <code>&lt;node-IP&gt;:&lt;port&gt;</code> where the port is random per pod given by Agones.</p>
<p>My goal is to be able to connect to these pods through a single IP, meaning I have to add some sort of load balancer. I tried using this service of type LoadBalancer, but I can't connect to any of the pods with it.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bungee-svc
spec:
  type: LoadBalancer
  loadBalancerIP: XXX.XX.XX.XXX
  ports:
    - port: 25565
      protocol: TCP
  selector:
    run: bungee
  externalTrafficPolicy: Local
</code></pre>
<p>Is a service like this the wrong approach here, and if so what should I use instead? If it is correct, why is it not working?</p>
<p><strong>Edit:</strong> External IP field says pending while checking the service status. I am running Kubernetes on bare-metal.</p>
<p><strong>Edit 2:</strong> Attempting to use NodePort as suggested, I see the service has not been given an external IP address. Trying to connect to <code>&lt;node-IP&gt;:&lt;nodePort&gt;</code> does not work. Could it be a problem related to the selector?</p>

Ferskfisk
<p>LoadBalancer Services could have worked, in clusters that are integrating with the API of the cloud provider hosting your Kubernetes nodes (cloud-controller-manager component). Since this is not your case, you're looking for a NodePort Service.</p>
<p>Something like:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bungee-svc
spec:
  type: NodePort
  ports:
    - port: 25565
      protocol: TCP
  selector:
    run: bungee
</code></pre>
<p>Having created that service, you can check its description - or yaml/json representation:</p>
<pre><code># kubectl describe svc xxx
Type:                     NodePort
IP:                       10.233.24.89 &lt;- ip within SDN
Port:                     tcp-8080  8080/TCP &lt;- ports within SDN
TargetPort:               8080/TCP &lt;- port on your container
NodePort:                 tcp-8080  31655/TCP &lt;- port exposed on your nodes
Endpoints:                10.233.108.232:8080 &lt;- pod:port ...
Session Affinity:         None
</code></pre>
<p>Now, I know the port <code>31655</code> was allocated to my NodePort Service -- ports are unique on your cluster, they are picked within a range, depends on your cluster configuration.</p>
<p>I can connect to my service, accessing any Kubernetes node IP, on the port that was allocated to my NodePort service.</p>
<pre><code>curl http://k8s-worker1.example.com:31655/
</code></pre>
<p>As a sidenote: a LoadBalancer Service extends a NodePort Service. While the externalIP won't ever show up, note that your Service was already allocated with its own port, as any NodePort Service - which is meant to receive traffic from whichever LoadBalancer would have been configured on behalf of your cluster, onto the cloud infrastructure it is integrated with.</p>
<p>And ... I have to say I'm not familiar with Agones. When you say &quot;I can access these pods outside the cluster with <code>&lt;node-IP&gt;:&lt;port&gt;</code> where the port is random per pod given by Agones&quot;. Are you sure ports are allocated on a per-pod basis, and bound to a given node? Or could it be they're already using a NodePort Service. Give it another look: have you tried connecting that port on other nodes of your cluster?</p>
