🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] **基于CentOS 7.5版本安装** # 2.1、系统升级及设置 ``` ## 升级CentOS软件包及内核 yum -y update yum -y install yum-plugin-fastestmirror rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm yum -y --enablerepo=elrepo-kernel install kernel-ml ## 设置默认启动内核为最新安装版本 grub2-set-default 0 grub2-mkconfig -o /boot/grub2/grub.cfg ## 安装工具集 yum install yum-utils ipvsadm telnet wget net-tools ## 删除旧内核 ## That means you've only 2 or 3 versions of kernel installed. If you have more than 3 version installed, the command will automatically remove old kernel from your system package-cleanup --oldkernels ## 设置 DefaultCPUAccounting DefaultMemoryAccounting ## http://www.jinbuguo.com/systemd/systemd-system.conf.html vi /etc/systemd/system.conf [Manager] DefaultCPUAccounting=yes DefaultMemoryAccounting=yes # 设置关闭防火墙及SELINUX systemctl stop firewalld && systemctl disable firewalld setenforce 0 vi /etc/selinux/config SELINUX=disabled # 关闭Swap swapoff -a && sysctl -w vm.swappiness=0 vi /etc/fstab # /dev/mapper/centos-swap swap swap defaults 0 0 ## 设置Docker所需参数 cat << EOF | tee /etc/sysctl.d/k8s.conf net.ipv4.ip_forward = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl -p /etc/sysctl.d/k8s.conf ``` ***** # 2.2、安装 Docker ``` yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum list docker-ce --showduplicates | sort -r yum install docker-ce-18.06.1.ce-3.el7 systemctl start docker && systemctl enable docker ``` ***** # 2.3、安装 LXCSF ``` # 下载编译工具 yum install git automake libtool fuse-devel ​ # 编译 LXCSF git clone git://github.com/lxc/lxcfs cd lxcfs/ ./bootstrap.sh ./configure make mkdir -p /var/lib/lxcfs make install # 创建LXCFS启动服务 cat << EOF | tee /usr/lib/systemd/system/lxcfs111.service [Unit] Description=FUSE filesystem for LXC ConditionVirtualization=!container Before=lxc.service Documentation=man:lxcfs(1) ​ [Service] ExecStart=/usr/local/bin/lxcfs /var/lib/lxcfs/ KillMode=process Restart=on-failure ExecStopPost=-/bin/fusermount -u /var/lib/lxcfs Delegate=yes ​ [Install] WantedBy=multi-user.target EOF # 设置开机启动 systemctl daemon-reload systemctl start lxcfs && systemctl enable lxcfs ``` ***** # 2.4、安装 CNI 网络插件 ``` mkdir -p /opt/cni/bin cd /opt/cni/bin wget https://github.com/containernetworking/plugins/releases/download/v0.7.1/cni-plugins-amd64-v0.7.1.tgz tar -xzvf cni-plugins-amd64-v0.7.1.tgz rm -rf cni-plugins-amd64-v0.7.1.tgz ``` ***** # 2.5、安装 kubectl 客户端 ``` wget https://dl.k8s.io/v1.12.1/kubernetes-client-linux-amd64.tar.gz tar -xzvf kubernetes-client-linux-amd64.tar.gz mv kubernetes/client/bin/kubectl /usr/local/bin/ rm -rf kubernetes* ```