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>
32 lines
4.9 KiB
HTML
32 lines
4.9 KiB
HTML
<a name="asm_01_0061"></a><a name="asm_01_0061"></a>
|
|
|
|
<h1 class="topictitle1">All Pods Have the app and version Labels</h1>
|
|
<div id="body0000001129853084"><div class="section" id="asm_01_0061__section10293311125813"><h4 class="sectiontitle">Description</h4><p id="asm_01_0061__p1975831285817">All pods of a Service must be labeled with <strong id="asm_01_0061__b667471182102516">app</strong> and <strong id="asm_01_0061__b113851416102516">version</strong>. <strong id="asm_01_0061__b194376912102516">app</strong> traces traffic in traffic monitoring, and <strong id="asm_01_0061__b1168435401102516">version</strong> distinguishes different versions in grayscale release. If a pod is not labeled with <strong id="asm_01_0061__b1974294860102516">app</strong> or <strong id="asm_01_0061__b1181422169102516">version</strong>, this item is abnormal.</p>
|
|
</div>
|
|
<div class="section" id="asm_01_0061__section551915418912"><a name="asm_01_0061__section551915418912"></a><a name="section551915418912"></a><h4 class="sectiontitle">Rectification Guide</h4><p id="asm_01_0061__p14746526119">The labels of pods are configured in <strong id="asm_01_0061__b1192211683102516">spec.template.metadata.labels</strong> of the Deployment. The recommended configuration is as follows:</p>
|
|
<pre class="screen" id="asm_01_0061__screen20963144716353">labels:
|
|
app: {serviceName}
|
|
version: v1</pre>
|
|
<div class="caution" id="asm_01_0061__note74631640151718"><span class="cautiontitle"><img src="public_sys-resources/caution_3.0-en-us.png"> </span><div class="cautionbody"><p id="asm_01_0061__p74631408175">Modifying or deleting the Deployment will trigger pod rolling upgrade, which may cause temporary service interruption. Therefore, perform the operation at a proper time.</p>
|
|
</div></div>
|
|
<ol id="asm_01_0061__ol157611128133516"><li id="asm_01_0061__li67618288356"><span>Copy the original workload configuration and save it as a YAML file.</span><p><p id="asm_01_0061__p19914220007"><strong id="asm_01_0061__b0328115519544">kubectl get deployment</strong> {deploymentName} <strong id="asm_01_0061__b164251210553">-n</strong> {namespace} <strong id="asm_01_0061__b2022109135517">-o yaml ></strong> {deploymentName}<strong id="asm_01_0061__b1065041207">-deployment.yaml</strong></p>
|
|
<p id="asm_01_0061__p361217511877">For example:</p>
|
|
<p id="asm_01_0061__p134614717016"><strong id="asm_01_0061__b46113501209">kubectl get deployment productpage -n default -o yaml > productpage-deployment.yaml</strong></p>
|
|
</p></li><li id="asm_01_0061__li127611428193520"><span>Modify the <strong id="asm_01_0061__b1916981420102516">productpage-deployment.yaml</strong> file. If the file does not contain <strong id="asm_01_0061__b1491123397102516">app</strong> and <strong id="asm_01_0061__b394260619102516">version</strong>, add them. You are advised to set <strong id="asm_01_0061__b62813455102516">app</strong> to the Service name and the <strong id="asm_01_0061__b1226345703102516">version</strong> to <strong id="asm_01_0061__b2029800709102516">v1</strong>.</span></li><li id="asm_01_0061__li107611528143516"><span>Delete the original workload.</span><p><p id="asm_01_0061__p132247102254"><strong id="asm_01_0061__b8613181519558">kubectl delete deployment</strong> {oldDeploymentName} <strong id="asm_01_0061__b53831120115516">-n</strong> {namespace}</p>
|
|
</p></li><li id="asm_01_0061__li11761928193516"><span>Apply the new workload configuration.</span><p><p id="asm_01_0061__p679115231014"><strong id="asm_01_0061__b627632619113">kubectl apply -f productpage-deployment.yaml</strong></p>
|
|
</p></li></ol>
|
|
<div class="note" id="asm_01_0061__note5614125110710"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="asm_01_0061__p325044816182">For clusters of v1.15 or earlier, you can modify pod labels on the CCE console, but residual ReplicaSets may exist.</p>
|
|
<p id="asm_01_0061__p884115412411">To check whether there are residual ReplicaSets, perform the following steps:</p>
|
|
<ol id="asm_01_0061__ol1984332252"><li id="asm_01_0061__li1498733132513">Query the ReplicaSets of the Deployment.<p id="asm_01_0061__p994094416111"><a name="asm_01_0061__li1498733132513"></a><a name="li1498733132513"></a><strong id="asm_01_0061__b77562026195513">kubectl get replicaset | grep</strong> {deploymentName}</p>
|
|
</li><li id="asm_01_0061__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_0061__p753518581914"><a name="asm_01_0061__li192982046142615"></a><a name="li192982046142615"></a><strong id="asm_01_0061__b10918182955519">kubectl delete replicaset</strong> {replicaSetName} <strong id="asm_01_0061__b181557349551">-n</strong> {namespace}</p>
|
|
</li></ol>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="asm_01_0060.html">Manual Fixing Items</a></div>
|
|
</div>
|
|
</div>
|
|
|