Virtualbox虚拟机官网:https://www.virtualbox.org

image-20210529144037945

Virtualbox安装CentOS且配置IP

  1. 虚拟机安装CentOS并分配2个CPU Core,用于运行Kubeadm

    image-20210529144323147

    image-20210529144433942

    image-20210529144511730

    image-20210529144543776

    image-20210529144628035

    image-20210529144722641

    启动虚拟机,选择已下载系统镜像.ios文件,进行CentOS系统安装

  2. 配置虚拟机双网卡实现固定IP,且能访问外网

    查看虚拟机网络,点击”管理“->”主机网络管理器“,记住IP地址,并选择”手动配置网卡“,修改ip为”192.168.99.1“

    image-20210529151205144

    image-20210529151637459

    image-20210529152213779

    • 网卡1:仅主机host-only

      image-20210529152332346

    • 网卡2:网络转换地址NAT

      image-20210529152456037

  1. 重启虚拟机,ping www.baidu.com返回成功

    image-20210529152802643

  2. 设置外部网络访问虚拟机

    • 设置静态ip。编辑网络配置文件,编辑网络设置文件

      1
      vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

      image-20210529153330532

      ONBOOT=yes表示开机启动

      BOOTPROTO=static为静态IP生效,IP地址为192.168.99.101

    • 重启网络

      1
      systemctl restart network
    • 查看生效的静态IP地址

      image-20210529153712744

    • 查看enp0s3网卡ip

      image-20210529154030381

    • 此时虚拟机既可以访问外网,也能够和宿主机进行通信

      image-20210529154255568

  3. 在宿主机中配置Master和work节点域名

    1
    vi /etc/hosts

    加入以下内容

    1
    2
    3
    192.168.99.101 master
    192.168.99.102 node1
    192.168.99.103 node2