125. 如何用 Elemental 缩小节点池中的特定节点
Situation 地理位置When scaling down aRancher-provisioned Elemental RKE2 cluster node poolafter modifying theMachineInventorySelectorTemplate, theoldest nodein the pool is removed — rather than the node that no longer matches the updated selector.在修改MachineInventorySelectorTemplate后缩小Rancher 配置的 Elemental RKE2 集群节点池时会移除池中最早的节点——而不是不再匹配更新选择器的节点。This behavior isexpected.这种行为是可以预料的。TheMachineInventorySelectorTemplateis evaluatedonly once, during initial creation, to generate selectors.MachineInventorySelectorTemplate仅在初始创建时被评估一次以生成选择器。Subsequent edits to the templatedo not propagateto existing selectors or machines that were previously created.模板后续的编辑不会传递到已有的选择器或之前创建的机器。For instructions on how to remove a specific machine or node from a node pool, refer to theResolutionsection below.关于如何从节点池中移除特定机器或节点的说明请参阅下方的解析部分。Resolution 结局To delete a specific node or machine from a pool, you can perform the operation via theRancher UIorkubectl.要从池中删除特定节点或机器可以通过Rancher UI或kubectl执行操作。Option 1: Using Rancher UI选项一使用 Rancher UINavigate to the cluster and locate the node you want to remove.导航到集群找到你想移除的节点。Select the node andscale downthe node pool.选择节点并缩小节点池。Rancher automatically applies the following annotation to the targeted machine:Rancher 会自动对目标机器应用以下注释span stylecolor:#000000span stylebackground-color:#ffffffspan stylebackground-color:#efefefcodea>span stylecolor:#000000span stylebackground-color:#ffffffcode classlanguage-yaml /code/span/spanOption 2: Using kubectl 选项二使用 KubectlIdentify the target machine object.识别目标机器对象。Manually apply the deletion annotation:手动应用删除注释span stylecolor:#000000span stylebackground-color:#ffffffspan stylebackground-color:#efefefcodeapiVersion: a>span stylecolor:#000000span stylebackground-color:#ffffffcode classlanguage-yaml /code/span/spanScale down the node pool to complete the deletion process.缩小节点池以完成删除过程。Cause 病因During node pool scaling operations, theMachineInventorySelectorTemplateisnot referenced.在节点池缩放操作中MachineInventorySelectorTemplate不会被引用。Instead, theoldest nodeis selected for removal to maintain the desired node count and to prevent unintended deletions that could occur due to mismatches between:相反会选择最早的节点进行移除以保持所需的节点数量并防止因以下节点不匹配而导致的意外删除Labels defined in the MachineInventorySelectorTemplate, andMachineInventorySelectorTemplate 定义的标签Labels present on existing MachineInventory objects.标签存在于现有的 MachineInventory 对象上。This safeguard ensures consistent and predictable scaling behavior, even when template labels are later modified.这种保护措施确保了即使模板标签后来被修改也能保持一致且可预测的扩展行为。Additional Information 附加信息https://github.com/rancher/elemental-operator/issues/353Environment 环境Rancher 牧场主Elemental 元素RKE2访问Rancher-K8S解决方案博主企业合作伙伴 https://blog.csdn.net/lidw2009