Files
doc-exports/docs/asm/umn/asm_01_0062.html
qiujiandong1 719033eb05 ASM UMN update 20250506 version
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: qiujiandong1 <qiujiandong1@huawei.com>
Co-committed-by: qiujiandong1 <qiujiandong1@huawei.com>
2025-07-14 13:38:34 +00:00

32 lines
4.9 KiB
HTML

<a name="asm_01_0062"></a><a name="asm_01_0062"></a>
<h1 class="topictitle1">All Pods Share the Same app and version Labels</h1>
<div id="body0000001175892783"><div class="section" id="asm_01_0062__section871654644012"><h4 class="sectiontitle">Description</h4><p id="asm_01_0062__p31319487407">All pods of a Service must share the same <strong id="asm_01_0062__b1541538899102422">app</strong> and <strong id="asm_01_0062__b84944479102422">version</strong> labels. <strong id="asm_01_0062__b468418259102422">app</strong> traces traffic in traffic monitoring, and <strong id="asm_01_0062__b829078207102422">version</strong> distinguishes different versions in grayscale release. If pods with different <strong id="asm_01_0062__b545469730102422">app</strong> or <strong id="asm_01_0062__b796028921102422">version</strong> labels exist, this item is abnormal.</p>
</div>
<div class="section" id="asm_01_0062__section761818153105"><h4 class="sectiontitle">Rectification Guide</h4><p id="asm_01_0062__p14746526119">The labels of pods are configured in <strong id="asm_01_0062__b1766435924102422">spec.template.metadata.labels</strong> of the Deployment. The recommended configuration is as follows:</p>
<pre class="screen" id="asm_01_0062__screen20963144716353">labels:
app: {serviceName}
version: v1</pre>
<p id="asm_01_0062__p116146511072">To modify the labels of multiple pods to the same value, perform the following steps:</p>
<ol id="asm_01_0062__ol13194528396"><li id="asm_01_0062__li1819413273917"><span>View the labels configured for <strong id="asm_01_0062__b806212425102422">spec.selector</strong>.</span><p><p id="asm_01_0062__p8128617823"><strong id="asm_01_0062__b122056400559">kubectl get svc</strong> {serviceName} <strong id="asm_01_0062__b1846914210558">-o yaml</strong></p>
<p id="asm_01_0062__p196151151574">For example, the labels are <strong id="asm_01_0062__b381443968102422">app: ratings</strong> and <strong id="asm_01_0062__b833110333102422">release: istio-bookinfo</strong>.</p>
</p></li><li id="asm_01_0062__li1519462133916"><span>Search for the pods of a Service by label.</span><p><p id="asm_01_0062__p1454130727"><strong id="asm_01_0062__b3392174525511">kubectl get pod -n</strong> {namespace} <strong id="asm_01_0062__b897184719559">-l app=ratings,release=istio-bookinfo</strong></p>
<div class="note" id="asm_01_0062__note1861515512712"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="asm_01_0062__p3960162145315"><strong id="asm_01_0062__b721707003102422">{namespace}</strong> is the same as the namespace of the Service.</p>
</div></div>
</p></li><li id="asm_01_0062__li1910515123393"><span>Find the workload of a pod by the pod name.</span><p><p id="asm_01_0062__p88271853920"><strong id="asm_01_0062__b19735451105514">kubectl get deployment</strong> {deploymentName} <strong id="asm_01_0062__b15625795519">-n</strong> {namespace}</p>
<div class="note" id="asm_01_0062__note156161513718"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="asm_01_0062__ul1861611516718"><li id="asm_01_0062__li661516519719">Generally, the pod name is in the format of <strong id="asm_01_0062__b1626122629102422">{deploymentName}-{random character string}-{random character string}</strong>.</li><li id="asm_01_0062__li146161451174">If no workload of a pod is found by the pod name, you need to delete residual ReplicaSets.<p id="asm_01_0062__p461613511972"><a name="asm_01_0062__li146161451174"></a><a name="li146161451174"></a>To check whether there are residual ReplicaSets, perform the following steps:</p>
<ol type="a" id="asm_01_0062__ol1984332252"><li id="asm_01_0062__li1498733132513">Query the ReplicaSets of the Deployment.<p id="asm_01_0062__p994094416111"><a name="asm_01_0062__li1498733132513"></a><a name="li1498733132513"></a><strong id="asm_01_0062__b417016010566">kubectl get replicaset | grep</strong> {deploymentName}</p>
</li><li id="asm_01_0062__li192982046142615">Find the ReplicaSets containing more than one pod. These ReplicaSets may be residual after label modification. You need to delete the old ReplicaSets.<p id="asm_01_0062__p753518581914"><a name="asm_01_0062__li192982046142615"></a><a name="li192982046142615"></a><strong id="asm_01_0062__b3665625567">kubectl delete replicaset</strong> {replicaSetName} <strong id="asm_01_0062__b1950920635612">-n</strong> {namespace}</p>
</li></ol>
</li></ul>
</div></div>
</p></li><li id="asm_01_0062__li610515124396"><span>For details about how to modify the <strong id="asm_01_0062__b912998563102422">app</strong> and <strong id="asm_01_0062__b590109138102422">version</strong> labels of a pod, see <a href="asm_01_0061.html#asm_01_0061__section551915418912">Rectification Guide</a>.</span></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="asm_01_0060.html">Fixing Items Manually</a></div>
</div>
</div>