Kubernetes 节点设置#

本节介绍在 BCM 头节点上执行的配置步骤。

  1. 在启动 cmsh 之前,将以下 XML 代码保存到活动头节点上的以下目录 /cm/local/apps/cmd/etc/htdocs/disk-setup/k8s-disksetup.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <diskSetup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <device>
    
            <blockdev>/dev/nvme0n1</blockdev>
    
            <partition id="a0" partitiontype="esp">
            <size>100M</size>
            <type>linux</type>
            <filesystem>fat</filesystem>
            <mountPoint>/boot/efi</mountPoint>
            <mountOptions>defaults,noatime,nodiratime</mountOptions>
            </partition>
            <partition id="a1">
            <size>max</size>
            <type>linux</type>
            <filesystem>xfs</filesystem>
            <mountPoint>/</mountPoint>
            <mountOptions>defaults,noatime,nodiratime</mountOptions>
            </partition>
        </device>
    </diskSetup>
    
  2. 现在我们可以创建软件镜像并定义 kubernetes 节点(或简称 knode)的类别。

    cmsh
    
    [bcm10-headnode]% softwareimage
    [bcm10-headnode->softwareimage]% clone default-image k8s-control-plane-image
    [bcm10-headnode->softwareimage*[k8s-control-plane-image*]]% commit
    [bcm10-headnode->softwareimage[k8s-control-plane-image]]% kernelmodules
    [bcm10-headnode->softwareimage[k8s-control-plane-image]->kernelmodules]% add mlx5_core
    [bcm10-headnode->softwareimage*[k8s-control-plane-image*]->kernelmodules*[mlx5_core*]]% commit
    [bcm10-headnode->softwareimage[k8s-control-plane-image]]% category
    [bcm10-headnode->category]% clone default k8s-control-plane
    [bcm10-headnode->category*[k8s-control-plane*]]% set softwareimage k8s-control-plane-image
    [bcm10-headnode->category*[k8s-control-plane*]]% set disksetup /cm/local/apps/cmd/etc/htdocs/disk-setup/k8s-disksetup.xml
    [bcm10-headnode->category*[k8s-control-plane*]]% commit
    
  3. 接下来创建第一个 knode。

    cmsh
    
    [bcm10-headnode]% device
    [bcm10-headnode->device]% clone node001 knode-01
    [bcm10-headnode->device*[knode-01*]]% set category k8s-control-plane
    [bcm10-headnode->device*[knode-01*]]% commit
    
  4. 添加并配置接口。

    注意

    接口的名称将根据节点的硬件供应商而变化。

    cmsh
    
    [bcm10-headnode]% device
    [bcm10-headnode->device]% use knode-01
    [bcm10-headnode->device[knode-01]]% interfaces
    [bcm10-headnode->device[knode-01]->interfaces]% add bmc ipmi0 10.133.3.25 ipminet
    [bcm10-headnode->device*[knode-01*]->interfaces*[ipmi0*]]% commit
    [bcm10-headnode->device[knode-01]->interfaces]% add physical ens2f1np1; add physical ens1f1np1
    [bcm10-headnode->device*[knode-01*]->interfaces*[ens1f1np1*]]% commit
    [bcm10-headnode->device[knode-01]->interfaces]% add bond bond0 10.133.4.25 internalnet
    [bcm10-headnode->device*[knode-01*]->interfaces*[bond0*]]% append interfaces ens2f1np1 ens1f1np1
    [bcm10-headnode->device*[knode-01*]->interfaces*[bond0*]]% remove bootif
    [bcm10-headnode->device*[knode-01*]->interfaces*[bond0*]]% ..
    [bcm10-headnode->device*[knode-01*]->interfaces*]% ..
    [bcm10-headnode->device*[knode-01*]]% set provisioninginterface bond0
    [bcm10-headnode->device*[knode-01*]]% commit
    
  5. 这里我们将第一个 knode 克隆成总共 3 个节点。

    cmsh
    
    [bcm10-headnode]% device
    [bcm10-headnode->device]% foreach --clone knode-01 -n knode-02..knode-03 --next-ip ()
    [bcm10-headnode->device*]% commit
    Successfully committed 2 Devices
    
  6. 为每个节点设置 MAC 地址,以便它们可以 PXE 启动。

    对所有 3 个 knode 重复此操作。

    cmsh
    
    [bcm10-headnode]% device
    [bcm10-headnode->device]% use knode-01
    [bcm10-headnode->device[knode-01]]% interfaces
    [bcm10-headnode->device[knode-01]->interfaces]% set ens2f1np1 mac 00:CC:EE:FF:77:88
    [bcm10-headnode->device*[knode-01*]->interfaces*]% set ens1f1np1 mac 00:CC:EE:FF:77:99
    [bcm10-headnode->device*[knode-01*]->interfaces*]% exit
    [bcm10-headnode->device*[knode-01*]]% set mac 00:CC:EE:FF:77:88
    [bcm10-headnode->device*[knode-01*]]% commit
    
  7. 开启电源并配置节点。