服务器配置与k8s版本
系统版本:
CentOS Linux release 7.9.2009 (Core)
内核版本:
[root@k8s-node02 tmp]# uname -r
5.4.259-1.el7.elrepo.x86_64
k8s版本 v1.15.1
[root@k8s-node1 tmp]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.1",
GitCommit:"4485c6f18cee9a5d3c3b4e523bd27972b1b53892", GitTreeState:"clean",
BuildDate:"2019-07-18T09:15:32Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
一、初始化语句导致报错Flag --experimental-upload-certs has been deprecated, use–upload-certs instead解决办法:是–experimental-upload-certs 已被弃用,用 --upload-certs 代替,那就使用–upload-certs ,代替即可,正确语句如下:
kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.log
二、docker版本导致报错 [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.03.1-ce. Latest validated version: 18.09,解决办法:重装docker
使用的docker版本为18.03.1版本与k8s不匹配,这边卸载重载了docker安装的是docker-ce-18.09.8
#停止docker服务
systemctl stop docker
#卸载旧版本docker
yum erase docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
docker-ce
#删除相关配置文件
find /etc/systemd -name '*docker*' -exec rm -f {} \;
find /lib/systemd -name '*docker*' -exec rm -f {} \;
yum list docker-ce --showduplicates|sort -r # 查询docker版本
yum install docker-ce-18.09.8 -y # 安装指定版本
#启动docker与设置开机自启(不设置也会报错)
systemctl start docker
systemctl enable docker
三、error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR Swap]: running with swap on is not supported. Please disable swap解决办法:
步骤1:根据提示,禁用交换空间,执行命令:swapoff -a,执行命令:vim /etc/fstab,使用#将/swapfile none swap sw 0 0 这一行注释,再执行reboot重启服务器,再执行初始化:kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.log
步骤2:执行kubeadm reset 用以重启kubeadm,再执行初始化:kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.log
步骤3:初始化init-defaults文件到kubeadm-config.yaml,再编辑vim kubeadm-config.yaml,修改以下配置,再执行初始化:kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.log
localAPIEndpoint:
#服务器节点地址
advertiseAddress: 192.168.31.200
#kubernetes版本号
kubernetesVersion: v1.15.1
networking:
#添加pod网段
podSubnet: "10.244.0.0/16"
#serviceSubnet默认
serviceSubnet: 10.96.0.0/12
---
#复制这段进去,更改默认调度模式为ipvs
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
featureGates:
SupportIPVSProxyMode: true
mode: ipvs
因此,我这边报错极有可能是因为:
1.交换分区未禁用
2.修改模板vim kubeadm-config.yaml,漏加了一段配置
#复制这段进去,更改默认调度模式为ipvs
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
featureGates:
SupportIPVSProxyMode: true
mode: ipvs
而在初始化前,还导入了镜像,内容如下:
从阿里云拉去docker镜像,脚本如下:
#!/bin/bash
image_aliyun=("kube-apiserver-amd64:v1.15.1" "kube-controller-manager-amd64:v1.15.1" "kube-scheduler-amd64:v1.15.1" "kube-proxy-amd64:v1.15.1" "pause-amd64:3.1" "etcd-amd64:3.3.10" "coredns:1.3.1")
for image in "${image_aliyun[@]}"
do
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$image
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$image k8s.gcr.io/${image/-amd64/}
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$image
done
本地使用了一个另外个镜像
通过脚本导入:vim load-images.sh
#!/bin/bash
ls /tmp/kubeadm-basic.images > /tmp/images.txt
cd /tmp/kubeadm-basic.images
for i in $( cat /tmp/images.txt )
do
docker load -i $i
done
rm -rf /tmp/images.txt
完成后,获取初始化模板,再初始化k8s