ingress-nginx-helm/examples/static-ip/index.html

58 lines
28 KiB
HTML
Raw Normal View History

2021-05-23 16:14:37 +00:00
<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href=https://kubernetes.github.io/ingress-nginx/examples/static-ip/ rel=canonical><link rel="shortcut icon" href=../../assets/images/favicon.png><meta name=generator content="mkdocs-1.1.2, mkdocs-material-6.2.4"><title>Static IPs - NGINX Ingress Controller</title><link rel=stylesheet href=../../assets/stylesheets/main.15aa0b43.min.css><link rel=stylesheet href=../../assets/stylesheets/palette.75751829.min.css><meta name=theme-color content=#009485><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback"><style>body,input{font-family:"Roboto",-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono",SFMono-Regular,Consolas,Menlo,monospace}</style><link rel=stylesheet href=../../extra.css><script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-118407822-1","kubernetes.github.io"),ga("set","anonymizeIp",!0),ga("send","pageview"),document.addEventListener("DOMContentLoaded",function(){document.forms.search&&document.forms.search.query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})}),document.addEventListener("DOMContentSwitch",function(){ga("send","pageview",document.location.pathname)})</script><script async src=https://www.google-analytics.com/analytics.js></script></head> <body dir=ltr data-md-color-scheme data-md-color-primary=teal data-md-color-accent=green> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#static-ips class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class=md-header data-md-component=header> <nav class="md-header-nav md-grid" aria-label=Header> <a href=https://kubernetes.github.io/ingress-nginx title="NGINX Ingress Controller" class="md-header-nav__button md-logo" aria-label="NGINX Ingress Controller"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 003-3 3 3 0 00-3-3 3 3 0 00-3 3 3 3 0 003 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z"/></svg> </a> <label class="md-header-nav__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg> </label> <div class=md-header-nav__title data-md-component=header-title> <div class=md-header-nav__ellipsis> <div class=md-header-nav__topic> <span class=md-ellipsis> NGINX Ingress Controller </span> </div> <div class=md-header-nav__topic> <span class=md-ellipsis> Static IPs </span> </div> </div> </div> <label class="md-header-nav__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg> </label> <div class=md-search data-md-component=search role=dialog> <label class=md-search__overlay for=__search></label> <div class=md-search__inner role=search> <form class=md-search__form name=search> <input type=text class=md-search__input name=query aria-label=Search placeholder=Search autocapitalize=off autocorrect=off autocomplete=off spellcheck=false data-md-component=search-query data-md-state=active required> <label class="md-search__icon md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 0
2021-01-11 15:59:14 +00:00
<span class=go>service &quot;nginx-ingress-lb&quot; created</span>
<span class=gp>$</span> kubectl get svc nginx-ingress-lb
<span class=go>NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE</span>
<span class=go>nginx-ingress-lb 10.0.138.113 104.154.109.191 80:31457/TCP,443:32240/TCP 15m</span>
</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> <div class=highlight><pre><span></span><code><span class=gp>$</span> kubectl create -f nginx-ingress-controller.yaml
<span class=go>deployment &quot;nginx-ingress-controller&quot; created</span>
</code></pre></div> <h2 id=assigning-the-ip-to-an-ingress>Assigning the IP to an Ingress<a class=headerlink href=#assigning-the-ip-to-an-ingress title="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> <div class=highlight><pre><span></span><code><span class=gp>$</span> kubectl create -f nginx-ingress.yaml
<span class=go>ingress &quot;nginx-ingress&quot; created</span>
<span class=gp>$</span> kubectl get ing ingress-nginx
<span class=go>NAME HOSTS ADDRESS PORTS AGE</span>
<span class=go>nginx-ingress * 104.154.109.191 80, 443 13m</span>
<span class=gp>$</span> curl <span class=m>104</span>.154.109.191 -kL
<span class=go>CLIENT VALUES:</span>
<span class=go>client_address=10.180.1.25</span>
<span class=go>command=GET</span>
<span class=go>real path=/</span>
<span class=go>query=nil</span>
<span class=go>request_version=1.1</span>
<span class=go>request_uri=http://104.154.109.191:8080/</span>
<span class=go>...</span>
</code></pre></div> <h2 id=retaining-the-ip>Retaining the IP<a class=headerlink href=#retaining-the-ip title="Permanent link"></a></h2> <p>You can test retention by deleting the Ingress</p> <div class=highlight><pre><span></span><code><span class=gp>$</span> kubectl delete ing nginx-ingress
<span class=go>ingress &quot;nginx-ingress&quot; deleted</span>
<span class=gp>$</span> kubectl create -f nginx-ingress.yaml
<span class=go>ingress &quot;nginx-ingress&quot; created</span>
<span class=gp>$</span> kubectl get ing nginx-ingress
<span class=go>NAME HOSTS ADDRESS PORTS AGE</span>
<span class=go>nginx-ingress * 104.154.109.191 80, 443 13m</span>
</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> <h2 id=promote-ephemeral-to-static-ip>Promote ephemeral to static IP<a class=headerlink href=#promote-ephemeral-to-static-ip title="Permanent link"></a></h2> <p>To promote the allocated IP to static, you can update the Service manifest</p> <div class=highlight><pre><span></span><code><span class=gp>$</span> kubectl patch svc nginx-ingress-lb -p <span class=s1>&#39;{&quot;spec&quot;: {&quot;loadBalancerIP&quot;: &quot;104.154.109.191&quot;}}&#39;</span>
<span class=go>&quot;nginx-ingress-lb&quot; patched</span>
</code></pre></div> <p>and promote the IP to static (promotion works differently for cloudproviders, provided example is for GKE/GCE) ` <div class=highlight><pre><span></span><code><span class=gp>$</span> gcloud compute addresses create nginx-ingress-lb --addresses <span class=m>104</span>.154.109.191 --region us-central1
<span class=go>Created [https://www.googleapis.com/compute/v1/projects/kubernetesdev/regions/us-central1/addresses/nginx-ingress-lb].</span>
<span class=go>---</span>
<span class=go>address: 104.154.109.191</span>
<span class=go>creationTimestamp: &#39;2017-01-31T16:34:50.089-08:00&#39;</span>
<span class=go>description: &#39;&#39;</span>
<span class=go>id: &#39;5208037144487826373&#39;</span>
<span class=go>kind: compute#address</span>
<span class=go>name: nginx-ingress-lb</span>
<span class=go>region: us-central1</span>
<span class=go>selfLink: https://www.googleapis.com/compute/v1/projects/kubernetesdev/regions/us-central1/addresses/nginx-ingress-lb</span>
<span class=go>status: IN_USE</span>
<span class=go>users:</span>
<span class=go>- us-central1/forwardingRules/a09f6913ae80e11e6a8c542010af0000</span>
</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> <footer class=md-footer> <div class=md-footer-nav> <nav class="md-footer-nav__inner md-grid" aria-label=Footer> <a href=../rewrite/ class="md-footer-nav__link md-footer-nav__link--prev" rel=prev> <div class="md-footer-nav__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg> </div> <div class=md-footer-nav__title> <div class=md-ellipsis> <span class=md-footer-nav__direction> Previous </span> Rewrite </div> </div> </a> <a href=../tls-termination/ class="md-footer-nav__link md-footer-nav__link--next" rel=next> <div class=md-footer-nav__title> <div class=md-ellipsis> <span class=md-footer-nav__direction> Next </span> TLS termination </div> </div> <div class="md-footer-nav__button md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="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> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-footer-copyright> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> </div> </div> </footer> </div> <script src=../../assets/javascripts/vendor.93c04032.min.js></script> <script src=../../assets/javascripts/bundle.83e5331e.min.js></script><script id=__lang type=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>
2020-04-15 17:09:38 +00:00
app = initialize({
base: "../..",
2021-01-11 15:59:14 +00:00
features: ['navigation.tabs', 'navigation.tabs.sticky', 'navigation.instant', 'navigation.sections'],
2020-04-15 17:09:38 +00:00
search: Object.assign({
2021-01-11 15:59:14 +00:00
worker: "../../assets/javascripts/worker/search.8c7e0a7e.min.js"
2020-04-15 17:09:38 +00:00
}, typeof search !== "undefined" && search)
})
2021-01-11 15:59:14 +00:00
</script> </body> </html>