</code></pre></div><p>then, update the ingress controller so it adopts the static IP of the Service by passing the <code>--publish-service</code> flag (the example yaml used in the next step already has it set to "nginx-ingress-lb").</p><divclass=highlight><pre><span></span><code><spanclass=gp>$</span> kubectl create -f nginx-ingress-controller.yaml
</code></pre></div><h2id=assigning-the-ip-to-an-ingress>Assigning the IP to an Ingress<aclass=headerlinkhref=#assigning-the-ip-to-an-ingresstitle="Permanent link"> ¶</a></h2><p>From here on every Ingress created with the <code>ingress.class</code> annotation set to <code>nginx</code> will get the IP allocated in the previous step</p><divclass=highlight><pre><span></span><code><spanclass=gp>$</span> kubectl create -f nginx-ingress.yaml
</code></pre></div><h2id=retaining-the-ip>Retaining the IP<aclass=headerlinkhref=#retaining-the-iptitle="Permanent link"> ¶</a></h2><p>You can test retention by deleting the Ingress</p><divclass=highlight><pre><span></span><code><spanclass=gp>$</span> kubectl delete ing nginx-ingress
</code></pre></div><blockquote><p>Note that unlike the GCE Ingress, the same loadbalancer IP is shared amongst all Ingresses, because all requests are proxied through the same set of nginx controllers.</p></blockquote><h2id=promote-ephemeral-to-static-ip>Promote ephemeral to static IP<aclass=headerlinkhref=#promote-ephemeral-to-static-iptitle="Permanent link"> ¶</a></h2><p>To promote the allocated IP to static, you can update the Service manifest</p><divclass=highlight><pre><span></span><code><spanclass=gp>$</span> kubectl patch svc nginx-ingress-lb -p <spanclass=s1>'{"spec": {"loadBalancerIP": "104.154.109.191"}}'</span>
</code></pre></div><p>and promote the IP to static (promotion works differently for cloudproviders, provided example is for GKE/GCE) ` <divclass=highlight><pre><span></span><code><spanclass=gp>$</span> gcloud compute addresses create nginx-ingress-lb --addresses <spanclass=m>104</span>.154.109.191 --region us-central1
</code></pre></div></p><p>Now even if the Service is deleted, the IP will persist, so you can recreate the Service with <code>spec.loadBalancerIP</code> set to <code>104.154.109.191</code>.</p></article></div></div></main><footerclass=md-footer><divclass=md-footer-nav><navclass="md-footer-nav__inner md-grid"aria-label=Footer><ahref=../rewrite/class="md-footer-nav__link md-footer-nav__link--prev"rel=prev><divclass="md-footer-nav__button md-icon"><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg></div><divclass=md-footer-nav__title><divclass=md-ellipsis><spanclass=md-footer-nav__direction> Previous </span> Rewrite </div></div></a><ahref=../tls-termination/class="md-footer-nav__link md-footer-nav__link--next"rel=next><divclass=md-footer-nav__title><divclass=md-ellipsis><spanclass=md-footer-nav__direction> Next </span> TLS termination </div></div><divclass="md-footer-nav__button md-icon"><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"/></svg></div></a></nav></div><divclass="md-footer-meta md-typeset"><divclass="md-footer-meta__inner md-grid"><divclass=md-footer-copyright> Made with <ahref=https://squidfunk.github.io/mkdocs-material/target=_blankrel=noopener> Material for MkDocs </a></div></div></div></footer></div><scriptsrc=../../assets/javascripts/vendor.93c04032.min.js></script><scriptsrc=../../assets/javascripts/bundle.83e5331e.min.js></script><scriptid=__langtype=application/json>{"clipboard.copy":"Copy to clipboard","clipboard.copied":"Copied to clipboard","search.config.lang":"en","search.config.pipeline":"trimmer, stopWordFilter","search.config.separator":"[\\s\\-]+","search.placeholder":"Search","search.result.placeholder":"Type to start searching","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.term.missing":"Missing"}</script><script>