Centos8系统发布已有一段时间,不少小伙伴开始上手使用。kubernetes1.18也发布了,今天作者使用kubeadm在Centos8系统上部署kubernetes。
1 系统准备
查看系统版本
[root@localhost]# cat /etc/centos-release CentOS Linux release 8.1.1911 (Core)
配置网络
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=enp0s3 UUID=039303a5-c70d-4973-8c91-97eaa071c23d DEVICE=enp0s3 ONBOOT=yes IPADDR=192.168.122.21 NETMASK=255.255.255.0 GATEWAY=192.168.122.1 DNS1=223.5.5.5
添加阿里源
[root@localhost ~]# rm -rfv /etc/yum.repos.d/* [root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
配置主机名
[root@master01 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.122.21 master01.paas.com master01
关闭swap,注释swap分区
[root@master01 ~]# swapoff -a [root@master01 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Mar 31 22:44:34 2020 # # Accessible filesystems, by reference, are maintained under '/dev/disk/'. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. # # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file. # /dev/mapper/cl-root / xfs defaults 0 0 UUID=5fecb240-379b-4331-ba04-f41338e81a6e /boot ext4 defaults 1 2 /dev/mapper/cl-home /home xfs defaults 0 0 #/dev/mapper/cl-swap swap swap defaults 0 0
配置内核参数,将桥接的IPv4流量传递到iptables的链
[root@master01 ~]# cat > /etc/sysctl.d/k8s.conf <<EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --system
2 安装常用包
[root@master01 ~]# yum install vim bash-completion net-tools gcc -y
3 使用aliyun源安装docker-ce
[root@master01 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 [root@master01 ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo [root@master01 ~]# yum -y install docker-ce
安装docker-ce如果出现以下错
[root@master01 ~]# yum -y install docker-ce CentOS-8 - Base - mirrors.aliyun.com 14 kB/s | 3.8 kB 00:00 CentOS-8 - Extras - mirrors.aliyun.com 6.4 kB/s | 1.5 kB 00:00 CentOS-8 - AppStream - mirrors.aliyun.com 16 kB/s | 4.3 kB 00:00 Docker CE Stable - x86_64 40 kB/s | 22 kB 00:00 Error: Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed - cannot install the best candidate for the job - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded - package containerd.io-1.2.13-3.1.el7.x86_64 is excluded - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded - package containerd.io-1.2.2-