</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=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=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=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> i in <spanclass=k>$(</span>seq <spanclass=m>1</span><spanclass=m>10</span><spanclass=k>)</span><spanclass=p>;</span><spanclass=k>do</span> curl -s --resolve echo.prod.mydomain.com:80:<spanclass=nv>$INGRESS_CONTROLLER_IP</span> echo.prod.mydomain.com <spanclass=p>|</span> grep <spanclass=s2>"Hostname"</span><spanclass=p>;</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: production-5c5f65d859-phqzc
</code></pre></div></article></div></div></main><footerclass=md-footer><divclass=md-footer-nav><navclass="md-footer-nav__inner md-grid"aria-label=Footer><ahref=../openpolicyagent/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> Open Policy Agent rules </div></div></a><ahref=../../developer-guide/getting-started/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> Getting Started </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>