You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OKD 4.8部署bootstrap失败:无DHCP主机名时DNS反向查询未生效

问题根因

你遇到的是OKD底层操作系统RHCOS在无DHCP主机名分配场景下的主机名解析优先级问题:RHCOS默认优先读取DHCP返回的主机名,其次读取/etc/hosts中127.0.0.1对应的主机名(默认是localhost),最后才会尝试物理网卡IP的DNS反向解析,所以才会出现你遇到的反向解析配置正确但主机名不生效的问题。

临时验证方法

登录任意运行中的节点执行以下操作,确认根因:

  • 查看物理网卡的DNS配置是否正确:nmcli dev show enp8s0 | grep IP4.DNS,确认返回的DNS服务器是213.133.98.98等你配置的公共DNS
  • 执行命令强制刷新主机名:hostnamectl set-hostname --transient '' && nmcli general hostname,如果返回结果是你配置的对应节点域名,说明根因判断正确

永久修复方案

你当前的install-config.yaml配置没有错误,缺的是裸机UPI安装模式下针对无DHCP主机名控制场景的额外配置,两种可选方案如下:

方案1:注入静态主机名(最稳妥,推荐)

在生成ignition部署配置前,为每个节点添加静态主机名配置:

  1. 生成install-config.yaml后,先执行命令生成资源清单:
openshift-install create manifests --dir=<你的部署目录>
  1. 为每个节点创建对应的主机名配置MachineConfig,示例master0的配置如下:
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: master
  name: 99-master0-hostname
spec:
  config:
    ignition:
      version: 3.2.0
    storage:
      files:
      - contents:
          source: data:text/plain;charset=utf-8,master0.loki.kaiserpfalz-edv.de
        mode: 0644
        path: /etc/hostname

按同样逻辑生成master1、master2、bootstrap节点对应的配置文件即可,worker节点后续扩容时同理配置。
3. 继续执行后续安装流程生成ignition配置:

openshift-install create ignition-configs --dir=<你的部署目录>

节点启动后会自动读取/etc/hostname的静态配置,不会再出现localhost的问题。

方案2:调整NetworkManager解析优先级

如果不想配置静态主机名,强制系统优先使用物理网卡IP的反向解析结果作为主机名,通过MachineConfig注入NetworkManager配置:

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: master
  name: 99-adjust-hostname-priority
spec:
  config:
    ignition:
      version: 3.2.0
    storage:
      files:
      - contents:
          source: data:text/plain;charset=utf-8,[main]%0Ahostname-mode=dns
        mode: 0644
        path: /etc/NetworkManager/conf.d/99-hostname.conf

该配置会强制NetworkManager跳过/etc/hosts的localhost解析,直接用物理网卡IP的反向解析结果作为主机名。

内容的提问来源于stack exchange,提问作者klenkes74

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 22:24:03