How to use this box with Vagrant:

Vagrant.configure("2") do |config|
  config.vm.box = "cuiw/k8s-centos8-base"
  config.vm.box_version = "1.0.0"
end
vagrant init cuiw/k8s-centos8-base \
  --box-version 1.0.0
vagrant up

This version was created 8 months ago.

#关闭防火墙
systemctl stop firewalld && systemctl disable firewalld

#关闭 seLinux
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

#关闭 swap 分区
sed -ri 's/.*swap.*/#&/' /etc/fstab

#将桥接的 IPV4 流量传递到 iptables 的链
cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

#同步时间
1 date #查看时间是否正确,不正确则执行以下步骤
2 rm -rf /etc/localtime
3 ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
4 设置时区
    tzselect
5 同步时间
    yum install -y ntpdate
    ntpdate cn.pool.ntp.org
6 date

# yum源
vi /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

vi /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

#安装
yum install docker-ce kubelet kubeadm kubectl
systemctl enable docker
systemctl enable kubelet

#注意,这里我遇到一个问题,docker的驱动类型和kubelet的驱动类型不同,需要统一一下。修改docker的驱动类型为systemd
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
1 provider for this version.
  • virtualbox Hosted by Vagrant Cloud (1.24 GB)