forked from docs/doc-exports
Reviewed-by: Kovács, Zoltán <zkovacs@t-systems.com> Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com> Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
48 lines
8.2 KiB
HTML
48 lines
8.2 KiB
HTML
<a name="asm_bestpractice_0003"></a><a name="asm_bestpractice_0003"></a>
|
|
|
|
<h1 class="topictitle1">Upgrading Data Plane Sidecars Without Service Interruption</h1>
|
|
<div id="body1562746525802"><p id="asm_bestpractice_0003__p1193563316504">ASM enables you to manage the traffic of services added into a service mesh. Sidecars are important components in ASM data plane. The upgrade of sidecars involves the re-injection of sidecars into data plane service pods, which requires the pods to be updated.</p>
|
|
<p id="asm_bestpractice_0003__p39171649142012">This section describes how to avoid service interruption during sidecar upgrade.</p>
|
|
<div class="section" id="asm_bestpractice_0003__section1344318497218"><h4 class="sectiontitle">Configuring the Number of Service Pods</h4><p id="asm_bestpractice_0003__p1471954115015">Ensure that the number of service pods is greater than or equal to <strong id="asm_bestpractice_0003__b9511243172615">2</strong> and the upgrade policy is set to <strong id="asm_bestpractice_0003__b10550113219263">RollingUpdate</strong>.</p>
|
|
<p id="asm_bestpractice_0003__p8060118">Sample configurations:</p>
|
|
<p id="asm_bestpractice_0003__p993316556199"><strong id="asm_bestpractice_0003__b72781017171611">kubectl get deploy nginx -n</strong> <em id="asm_bestpractice_0003__i9669173571517">namespace_name</em> <strong id="asm_bestpractice_0003__b2966120131611">-oyaml | grep strategy -a10</strong></p>
|
|
<p id="asm_bestpractice_0003__p51225179207"><span><img id="asm_bestpractice_0003__image461012317217" src="en-us_image_0000001145684268.png"></span></p>
|
|
<p id="asm_bestpractice_0003__p175833321213"><strong id="asm_bestpractice_0003__b107921117519">Configuration description:</strong></p>
|
|
<ul id="asm_bestpractice_0003__ul11496821185111"><li id="asm_bestpractice_0003__li13497172185110">Number of service pods: deployment.spec.replicas >= 2</li><li id="asm_bestpractice_0003__li154971221105114">Upgrade policy: deployment.spec.strategy.type == RollingUpdate</li><li id="asm_bestpractice_0003__li5497122105114">Minimum number of alive pods in rolling upgrade: deployment.spec.replicas - deployment.spec.strategy.maxUnavailable > 0</li></ul>
|
|
</div>
|
|
<div class="section" id="asm_bestpractice_0003__section1324111014226"><h4 class="sectiontitle">Adding a Readiness Probe</h4><p id="asm_bestpractice_0003__p7511210115213">Readiness probes help you ensure that new service pods take over traffic only when they are ready. This prevents access failures caused by unready new pods.</p>
|
|
<p id="asm_bestpractice_0003__p5978143116227">The configurations are as follows:</p>
|
|
<p id="asm_bestpractice_0003__p13225135817272"><strong id="asm_bestpractice_0003__b27051933193020">kubectl get deploy nginx -n</strong> <em id="asm_bestpractice_0003__i151411047131511">namespace_name</em> <strong id="asm_bestpractice_0003__b1070664193012">-oyaml | grep readinessProbe -a10</strong></p>
|
|
<p id="asm_bestpractice_0003__p428018952818"><span><img id="asm_bestpractice_0003__image12545114142815" src="en-us_image_0000001191764069.png"></span></p>
|
|
<p id="asm_bestpractice_0003__p17161182032815"><strong id="asm_bestpractice_0003__b9834171873811">Configuration description:</strong></p>
|
|
<p id="asm_bestpractice_0003__p191011716304">Configuring a readiness probe: deployment.spec.template.spec.containers[i].readinessProbe</p>
|
|
<p id="asm_bestpractice_0003__p19391851123011">The configuration includes the initial check time, check interval, and timeout duration.</p>
|
|
</div>
|
|
<div class="section" id="asm_bestpractice_0003__section845914363222"><h4 class="sectiontitle">Setting the Service Ready Time</h4><p id="asm_bestpractice_0003__p124715578547"><strong id="asm_bestpractice_0003__b1817317159446">minReadySeconds</strong> is used to specify the minimum number of seconds for which a newly created pod should be ready without any of its containers crashing, for it to be considered available.</p>
|
|
<p id="asm_bestpractice_0003__p2500195314226">The configurations are as follows:</p>
|
|
<p id="asm_bestpractice_0003__p15675111817390"><strong id="asm_bestpractice_0003__b1498004616307">kubectl get deploy nginx -n</strong> <em id="asm_bestpractice_0003__i0324165281515">namespace_name</em> <strong id="asm_bestpractice_0003__b29388504300">-oyaml | grep minReadySeconds -a1</strong></p>
|
|
<p id="asm_bestpractice_0003__p139821937143914"><span><img id="asm_bestpractice_0003__image1582244116396" src="en-us_image_0000001191923931.png"></span></p>
|
|
<p id="asm_bestpractice_0003__p379010446396"><strong id="asm_bestpractice_0003__b165117911468">Configuration description:</strong></p>
|
|
<p id="asm_bestpractice_0003__p096416511397">The service ready time: deployment.spec.minReadySeconds. Configure this parameter based on the live environment.</p>
|
|
</div>
|
|
<div class="section" id="asm_bestpractice_0003__section9379325152319"><h4 class="sectiontitle">Configuring a Graceful Shutdown Time</h4><p id="asm_bestpractice_0003__p1634864915408"><strong id="asm_bestpractice_0003__b0528153385017">terminationGracePeriodSeconds</strong> is used to configure a graceful shutdown time. During a rolling upgrade, the endpoint of an old service pod is removed and the pod status is set to <strong id="asm_bestpractice_0003__b5859338227">Terminating</strong>. A SIGTERM signal is then sent to the pod. After the graceful shutdown time you configured, the pod will be forcibly terminated. The graceful deletion time allows the pod to keep processing unfinished requests, if any, to avoid hard termination.</p>
|
|
<p id="asm_bestpractice_0003__p479731716535"><strong id="asm_bestpractice_0003__b1083125643017">kubectl get deploy nginx -n</strong> <em id="asm_bestpractice_0003__i6364257111517">namespace_name</em> <strong id="asm_bestpractice_0003__b19750141173115">-oyaml | grep terminationGracePeriodSeconds -a1</strong></p>
|
|
<p id="asm_bestpractice_0003__p151911538112316"><span><img id="asm_bestpractice_0003__image59021924105312" src="en-us_image_0000001191923929.png"></span></p>
|
|
<p id="asm_bestpractice_0003__p84581127195319"><strong id="asm_bestpractice_0003__b14451381903">Configuration description:</strong></p>
|
|
<p id="asm_bestpractice_0003__p1841333615313">The graceful shutdown time: deployment.spec.template.spec.terminationGracePeriodSeconds. The default value is 30s. Configure this parameter based on the live environment.</p>
|
|
</div>
|
|
<div class="section" id="asm_bestpractice_0003__section1453854922316"><h4 class="sectiontitle">Configuring the preStop</h4><p id="asm_bestpractice_0003__p8167564553"><strong id="asm_bestpractice_0003__b16927121901914">preStop</strong> enabled you to perform certain execution before a service pod is stopped. In this way, it helps you gracefully shut down a service pod. Configure this parameter based on service requirements. Nginx is used as an example here.</p>
|
|
<p id="asm_bestpractice_0003__p333918155913"><strong id="asm_bestpractice_0003__b184851999316">kubectl get deploy nginx -n</strong> <em id="asm_bestpractice_0003__i1042284111610">namespace_name</em> <strong id="asm_bestpractice_0003__b106117123319">-oyaml | grep lifec -a10</strong></p>
|
|
<p id="asm_bestpractice_0003__p113056112410"><span><img id="asm_bestpractice_0003__image6101162115345" src="en-us_image_0000001493677652.png"></span></p>
|
|
<p id="asm_bestpractice_0003__p19235130586">In the <strong id="asm_bestpractice_0003__b7658163861717">lifecycle.preStop</strong> field, the <strong id="asm_bestpractice_0003__b1097518924710">nginx -s quit; sleep 10</strong> command is defined. This command first sends a graceful shutdown signal to the Nginx process and then the pod termination pauses for 10 seconds. In this way, Nginx has enough time to complete the ongoing requests and gracefully close the pod before it terminates.</p>
|
|
<p id="asm_bestpractice_0003__p84779414389"><strong id="asm_bestpractice_0003__b154143812267">10</strong> in <strong id="asm_bestpractice_0003__b12467011102620">sleep 10</strong> is an example value. You can change it based on the actual requirements and application performance. The key should be a proper value so that Nginx has enough time to gracefully shut down the process.</p>
|
|
<p id="asm_bestpractice_0003__p55331016155918">Alternatively, you can run custom commands or scripts to gracefully shut down your service process.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="asm_bp_0001.html">Best Practices</a></div>
|
|
</div>
|
|
</div>
|
|
|