<p>I'm looking to expose individual pods HTTP.  The trick here is that the pod in question needs to know its externally valid IP address, and so in order to configure that ahead of time, I have to have certainty on the external IP address that I'm exposing it by.</p>

<p>Currently I'm trying to expose in this way:</p>

<pre><code>kubectl expose pod my-pod --type=LoadBalancer --name=lb-http --external-ip=$IP --port=80 --target-port=30000
</code></pre>

<p>But I'm thinking that the <code>--external-ip</code> flag isn't operating as I intend, as my GKE cluster ends up with a different endpoint IP address.</p>

<p>Is there a way to expose an individual pod to a <em>particular pre-determined IP address</em>?</p>

FrobberOfBits
<p>Not possible via LoadBalancer type service. However you can use nginx ingress controller to expose all of your pods on same static IP and apply <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource" rel="nofollow noreferrer">ingress rules</a> for path and host based routing.This <a href="https://github.com/kubernetes/ingress-nginx/tree/master/docs/examples/static-ip" rel="nofollow noreferrer">doc</a> demonstrates how to assign a static-ip to an Ingress on through the Nginx controller.</p>

<p>You can achieve the same with GKE ingress as well. Here is the <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer#step_5_optional_configure_a_static_ip_address" rel="nofollow noreferrer">doc</a> on how to do that.</p>
