准备:centos8
需要的rpm的网址:https://pkgs.org/download/epel-release 添加yum仓库:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
安装docker-ce时报错:
Error:
Problem: package docker-ce-3:19.03.6-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.2-3.3.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.el7.x86_64 is excluded
- package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
解决方法:
yum install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm
首先,yum indstall kubelet、kubeadm、kubectl,这时需要conntrack-tools,
需要先安装epel-release,
yum install -y http://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/e/epel-release-8-8.el8.noarch.rpm
然后安装
yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/conntrack-tools-1.4.4-5.el7.x86_64.rpm
然后,在http://mirrors.aliyun.com里找到对应的docker-ce、kubernetes的repo映射。
yum install docker-ce
systemmctl enable docker
systemctl enable kubelet
初始化kubernetes:
执行如下命令:
kubeadm init --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12
出现如下错误:
解决办法:
vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
关闭swap:
swapoff -a
sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab
然后执行以下命令:
kubeadm init --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
报出如下错误:
解决方案:
最好服务器的内存>=4G
kubeadm init --image-repository=registry.aliyuncs.com/google_containers --kubernetes-version=v1.17.3 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
安装flannel:
需要跨国外网进行下载,
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f kube-flannel.yml
docker pull quay.io/coreos/flannel:v0.11.0-amd64
此时会下载flannel相关组件,需要连接外国网站。
然后执行kubectl get pods,
docker image ls
kubectl get nodes
kubectl get pods -n kube-system
在node01、node02上:
docker pull registry.aliyuncs.com/google_containers/kube-proxy:v1.17.3
docker pull registry.aliyuncs.com/google_containers/pause:3.1
docker pull quay.io/coreos/flannel:v0.11.0-amd64
kubeadm join 192.168.25.128:6443 --token ayz3sd.ozl8vigng57vuall --discovery-token-ca-cert-hash sha256:9cac4e14a2b8c438bf3e2e656942f67c0467f389755ac0aa2274c6688535c3f8
作者:天龙至尊