</code></pre></div><h2id=create-the-canary-deployment-and-service>Create the canary deployment and service<aclass=headerlinkhref=#create-the-canary-deployment-and-servicetitle="Permanent link"> ¶</a></h2><p>This is the canary deployment that will take a weighted amount of requests instead of the main deployment</p><divclass=highlight><pre><span></span><code><spanclass=nb>echo</span><spanclass=w></span><spanclass=s2>"</span>
</code></pre></div><h2id=create-ingress-pointing-to-your-main-deployment>Create Ingress Pointing To Your Main Deployment<aclass=headerlinkhref=#create-ingress-pointing-to-your-main-deploymenttitle="Permanent link"> ¶</a></h2><p>Next you will need to expose your main deployment with an ingress resource, note there are no canary specific annotations on this ingress</p><divclass=highlight><pre><span></span><code><spanclass=nb>echo</span><spanclass=w></span><spanclass=s2>"</span>
</code></pre></div><h2id=create-ingress-pointing-to-your-canary-deployment>Create Ingress Pointing To Your Canary Deployment<aclass=headerlinkhref=#create-ingress-pointing-to-your-canary-deploymenttitle="Permanent link"> ¶</a></h2><p>You will then create an Ingress that has the canary specific configuration, please pay special notice of the following:</p><ul><li>The host name is identical to the main ingress host name</li><li>The <code>nginx.ingress.kubernetes.io/canary: "true"</code> annotation is required and defines this as a canary annotation (if you do not have this the Ingresses will clash)</li><li>The <code>nginx.ingress.kubernetes.io/canary-weight: "50"</code> annotation dictates the weight of the routing, in this case there is a "50%" chance a request will hit the canary deployment over the main deployment <divclass=highlight><pre><span></span><code><spanclass=nb>echo</span><spanclass=w></span><spanclass=s2>"</span>
</code></pre></div></li></ul><h2id=testing-your-setup>Testing your setup<aclass=headerlinkhref=#testing-your-setuptitle="Permanent link"> ¶</a></h2><p>You can use the following command to test your setup (replacing INGRESS_CONTROLLER_IP with your ingresse controllers IP Address)</p><divclass=highlight><pre><span></span><code><spanclass=k>for</span><spanclass=w></span>i<spanclass=w></span><spanclass=k>in</span><spanclass=w></span><spanclass=k>$(</span>seq<spanclass=w></span><spanclass=m>1</span><spanclass=w></span><spanclass=m>10</span><spanclass=k>)</span><spanclass=p>;</span><spanclass=w></span><spanclass=k>do</span><spanclass=w></span>curl<spanclass=w></span>-s<spanclass=w></span>--resolve<spanclass=w></span>echo.prod.mydomain.com:80:<spanclass=nv>$INGRESS_CONTROLLER_IP</span><spanclass=w></span>echo.prod.mydomain.com<spanclass=w></span><spanclass=p>|</span><spanclass=w></span>grep<spanclass=w></span><spanclass=s2>"Hostname"</span><spanclass=p>;</span><spanclass=w></span><spanclass=k>done</span>
</code></pre></div><p>You will get the following output showing that your canary setup is working as expected:</p><divclass=highlight><pre><span></span><code>Hostname:<spanclass=w></span>production-5c5f65d859-phqzc
</code></pre></div></article></div></div></main><footerclass=md-footer><divclass="md-footer-meta md-typeset"><divclass="md-footer-meta__inner md-grid"><divclass=md-copyright> Made with <ahref=https://squidfunk.github.io/mkdocs-material/target=_blankrel=noopener> Material for MkDocs </a></div></div></div></footer></div><divclass=md-dialogdata-md-component=dialog><divclass="md-dialog__inner md-typeset"></div></div><scriptid=__configtype=application/json>{"base":"../..","features":["navigation.tabs","navigation.tabs.sticky","navigation.instant","navigation.sections"],"search":"../../assets/javascripts/workers/search.f886a092.min.js","translations":{"clipboard.copied":"Copied to clipboard","clipboard.copy":"Copy to clipboard","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.placeholder":"Type to start searching","search.result.term.missing":"Missing","select.version":"Select version"}}</script><scriptsrc=../../assets/javascripts/bundle.aecac24b.min.js></script></body></html>