title: Kubernetes - route static IP to multiple services (Google Cloud Platform)
body: <p>I have a small application comprising three services: </p>
  
  <ol>
  <li>A single page application (SPA) served from nginx</li>
  <li>A simple nodejs HTTP API used by the SPA</li>
  <li>An MQtt broker exposing ports 1883 and 9001</li>
  </ol>
  
  <p>Ideally I'd like the all to be served from the same subdomain and static IP address and have been trying to configure this in Kubernetes on the Google Cloud Platform.</p>
  
  <p>I've created deployments for each of the services, with the SPA exposing port 80, the API 3000 and the MQTT broker 1883/9001. I've then followed the instructions <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip" rel="nofollow noreferrer">here</a> to set up a static IP and a Service to route to the SPA, then created similar services for the API and the MQTT app. (I've initally adapted these from deployments and services generated from a docker-compose file and Kompose).</p>
  
  <p>The SPA and API seem to work fine but the MQTT service does not. When I run <code>kubetl get events</code> I see:</p>
  
  <p><code>Error creating load balancer (will retry): failed to ensure load balancer for service default/mqtt-broker: failed to create forwarding rule for load balancer (a5529f2a9bdaf11e8b35d42010a84005(default/mqtt-broker)): googleapi: Error 400: Invalid value for field 'resource.IPAddress': '35.190.221.113'. Specified IP address is in-use and would result in a conflict., invalid
  </code></p>
  
  <p>So I'm wondering if I should be creating a single service to route to the three deployments but can't find any documentation or examples that explain how to do this for a non http service.</p>
  
  <p>I guess I could put the mqtt service on a separate IP address but this seems to be hacking around the problem rather than solving it.</p>
  
  <p>Thanks in advance for any advice.</p>