6.3. 启用引导镜像管理
默认情况下,对于 Google Cloud 和 Amazon Web Services (AWS)集群,Machine Config Operator (MCO)会在更新集群时更新集群中的机器集中的引导镜像。
如果您禁用了引导镜像管理功能,导致引导镜像没有更新,您可以通过编辑 MachineConfiguration 对象来重新启用该功能。
对于 VMware vSphere,您可以启用引导镜像管理,它是一个技术预览功能。
vSphere 上的引导镜像管理只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅以下链接:
启用该功能将引导镜像更新至当前的 OpenShift Container Platform 版本。如果以后集群再次更新至新的 OpenShift Container Platform 版本,则会再次更新引导镜像。启用功能后创建的新节点使用更新的引导镜像。此功能对现有节点没有影响。
先决条件
对于 vSphere,在集群中启用
TechPreviewNoUpgrade功能集。如需更多信息,请参阅“使用功能门启用功能”。注意启用
TechPreviewNoUpgrade功能集将无法撤消,并防止次版本更新。不建议在生产环境集群中使用这些功能集。等待
managedBootImagesStatus小节显示在MachineConfiguration对象中。apiVersion: operator.openshift.io/v1 kind: MachineConfiguration metadata: name: cluster # ... status: # ... managedBootImagesStatus: machineManagers: - apiGroup: machine.openshift.io resource: machinesets selection: mode: None
流程
编辑名为
cluster的MachineConfiguration对象,为某些或所有机器集启用引导镜像管理功能:$ oc edit MachineConfiguration cluster可选:为所有机器集启用引导镜像管理功能:
apiVersion: operator.openshift.io/v1 kind: MachineConfiguration metadata: name: cluster namespace: openshift-machine-config-operator spec: # ... managedBootImages:1 machineManagers: - apiGroup: machine.openshift.io2 resource: machinesets3 selection: mode: All4 可选:为特定机器集启用引导镜像管理功能:
apiVersion: operator.openshift.io/v1 kind: MachineConfiguration metadata: name: cluster namespace: openshift-machine-config-operator spec: # ... managedBootImages:1 machineManagers: - apiGroup: machine.openshift.io2 resource: machinesets3 selection: mode: Partial4 partial: machineResourceSelector: matchLabels: region: "east"提示如果机器集中没有适当的标签,请运行以下命令来添加键值对:
$ oc label machineset.machine ci-ln-hmy310k-72292-5f87z-worker-a region="east" -n openshift-machine-api
验证
当受影响的节点返回
READY状态时,通过查看机器配置对象来查看引导镜像管理功能的当前状态:$ oc get machineconfiguration cluster -o yaml使用引导镜像引用的机器集示例
kind: MachineConfiguration metadata: name: cluster # ... status: conditions: - lastTransitionTime: "2025-05-01T20:11:49Z" message: Reconciled 2 of 4 MAPI MachineSets | Reconciled 0 of 0 CAPI MachineSets | Reconciled 0 of 0 CAPI MachineDeployments reason: BootImageUpdateConfigurationUpdated status: "True" type: BootImageUpdateProgressing - lastTransitionTime: "2025-05-01T19:30:13Z" message: 0 Degraded MAPI MachineSets | 0 Degraded CAPI MachineSets | 0 CAPI MachineDeployments reason: BootImageUpdateConfigurationUpdated status: "False" type: BootImageUpdateDegraded managedBootImagesStatus: machineManagers: - apiGroup: machine.openshift.io resource: machinesets selection: mode: All当受影响的节点返回到
READY状态时,使用以下方法之一检查当前的引导镜像:对于 Google Cloud 和 AWS,运行以下命令来获取引导镜像版本。根据具体的平台,机器集中的引导镜像的位置和格式可能会有所不同。但是,引导镜像总是列在
spec.template.spec.providerSpec.参数中。$ oc get machinesets <machineset_name> -n openshift-machine-api -o yaml使用引导镜像引用的机器集示例
apiVersion: machine.openshift.io/v1beta1 kind: MachineSet metadata: labels: machine.openshift.io/cluster-api-cluster: ci-ln-77hmkpt-72292-d4pxp update-boot-image: "true" name: ci-ln-77hmkpt-72292-d4pxp-worker-a namespace: openshift-machine-api spec: # ... template: # ... spec: # ... providerSpec: # ... value: disks: - autoDelete: true boot: true image: projects/rhcos-cloud/global/images/<boot_image>1 # ...- 1
- 此引导镜像与当前的 OpenShift Container Platform 版本相同。
对于 VMware vSphere,从受影响的节点获取引导镜像版本:
运行以下命令,打开到节点的
oc debug会话:$ oc debug node/<node_name>运行以下命令,将
/host设置为 debug shell 中的根目录:sh-5.1# chroot /host运行
rpm-ostree status命令,以查看自定义分层镜像正在使用:sh-5.1# rpm-ostree status输出示例
State: idle Deployments: * ostree-unverified-registry:quay.io/my-registry/... Digest: sha256:...