收获
主要步骤和过程
master节点升级
1.master节点上升级kubeadm
# 查看软件包的版本
yum list --showduplicates kubeadm --disableexcludes=kubernetes
# 安装最新版本kubeadm和kubectl
yum install -y kubeadm-1.14.0-0 --disableexcludes=kubernetes
# 查看kubeadm version
kubeadm version
# 查看更新计划
kubeadm upgrade plan
# 通过更新计划和version 判断kubeadm 是否更新成功
查看所需镜像并通过脚本拉取。
# 查看所需镜像
kubeadm config images list
# 根据镜像名称编辑脚本,并使用脚本拉取镜像。脚本编写见后文
# 执行脚本拉取镜像
./pull_images.sh
926329751cadbbc22f769179080c69cf43bfc0e5
升级master节点
sudo kubeadm upgrade apply v1.14.0
yum install -y kubelet-1.14.0-0 kubectl-1.14.0-0 --disableexcludes=kubernetes
sudo systemctl restart kubelet
升级worker
# 先下载相关镜像,主要是proxy和coredns
#升级kubeadm
yum install -y kubeadm-1.14.0-0 --disableexcludes=kubernetes
# 驱逐工作负载,master上执行
kubectl drain $NODE --ignore-daemonsets
# 更新kubelet
sudo kubeadm upgrade node
yum install -y kubelet-1.14.0-0 kubectl-1.14.0-0 --disableexcludes=kubernetes
sudo systemctl restart kubelet
kubectl uncordon $NODE
验证是否成功
kubectl get nodes
后续升级步骤类似,只需要注意里面的坑就好,坑我已经放在关键问题里面了,升级的步骤建议按照官方的步骤来走。
journalctl -f -u kubelet
vim /etc/cni/net.d/10-flannel.conflist
{
"name": "cbr0",
"cniVersion": "0.3.1",
"plugins": [
{
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": true
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
Worker start to fail CSINodeIfo: error updating CSINode annotation
解决方法:在/var/lib/kubelet/config.yaml文件末尾追加两行文字。
featureGates:
CSIMigration: false
kubectl taint node $NODE node.kubernetes.io/not-ready-
sudo kubeadm upgrade apply v1.16.0 --ignore-preflight-errors=CoreDNSUnsupportedPlugins
kubectl get namespace cattle-prometheus -o json > tmp.json
# 删除掉spec里面的内容。
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/cattle-prometheus/finalize
kubectl get nodes
命令发现version为1.18。但实际上我最多也就升级到了1.16。在github上有个类似的issue解决了此问题,通过kubectl get nodes查看到的版本实际上是kubelet的版本,需要对kubelet进行降级处理即可。降级命令yum -y downgrade kubelet-1.16.0-0
1.14镜像脚本下载
vim pull_images1.14.sh
# 设置国内镜像源
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/google_containers
# 拉取镜像
docker pull ${MY_REGISTRY}/kube-apiserver:v1.14.0
docker pull ${MY_REGISTRY}/kube-controller-manager:v1.14.0
docker pull ${MY_REGISTRY}/kube-scheduler:v1.14.0
docker pull ${MY_REGISTRY}/kube-proxy:v1.14.0
docker pull ${MY_REGISTRY}/pause:3.1
docker pull ${MY_REGISTRY}/etcd:3.3.0
docker pull ${MY_REGISTRY}/coredns:1.3.1
# 添加tag
docker tag ${MY_REGISTRY}/kube-apiserver:v1.14.0 k8s.gcr.io/kube-apiserver:v1.14.0
docker tag ${MY_REGISTRY}/kube-controller-manager:v1.14.0 k8s.gcr.io/kube-controller-manager:v1.14.0
docker tag ${MY_REGISTRY}/kube-scheduler:v1.14.0 k8s.gcr.io/kube-scheduler:v1.14.0
docker tag ${MY_REGISTRY}/kube-proxy:v1.14.0 k8s.gcr.io/kube-proxy:v1.14.0
docker tag ${MY_REGISTRY}/pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/etcd:3.3.0 k8s.gcr.io/etcd:3.3.0
docker tag ${MY_REGISTRY}/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
# 移除其他tag的镜像
docker rmi ${MY_REGISTRY}/kube-apiserver:v1.14.0
docker rmi ${MY_REGISTRY}/kube-controller-manager:v1.14.0
docker rmi ${MY_REGISTRY}/kube-scheduler:v1.14.0
docker rmi ${MY_REGISTRY}/kube-proxy:v1.14.0
docker rmi ${MY_REGISTRY}/pause:3.1
docker rmi ${MY_REGISTRY}/etcd:3.3.0
docker rmi ${MY_REGISTRY}/coredns:1.3.1
1.15镜像脚本下载
vim pull_image1.15.sh
# 设置国内镜像源
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/google_containers
# 拉取镜像
docker pull ${MY_REGISTRY}/kube-apiserver:v1.15.0
docker pull ${MY_REGISTRY}/kube-controller-manager:v1.15.0
docker pull ${MY_REGISTRY}/kube-scheduler:v1.15.0
docker pull ${MY_REGISTRY}/kube-proxy:v1.15.0
docker pull ${MY_REGISTRY}/pause:3.1
docker pull ${MY_REGISTRY}/etcd:3.3.0
docker pull ${MY_REGISTRY}/coredns:1.3.1
# 添加tag
docker tag ${MY_REGISTRY}/kube-apiserver:v1.15.0 k8s.gcr.io/kube-apiserver:v1.15.0
docker tag ${MY_REGISTRY}/kube-controller-manager:v1.15.0 k8s.gcr.io/kube-controller-manager:v1.15.0
docker tag ${MY_REGISTRY}/kube-scheduler:v1.15.0 k8s.gcr.io/kube-scheduler:v1.15.0
docker tag ${MY_REGISTRY}/kube-proxy:v1.15.0 k8s.gcr.io/kube-proxy:v1.15.0
docker tag ${MY_REGISTRY}/pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/etcd:3.3.0 k8s.gcr.io/etcd:3.3.0
docker tag ${MY_REGISTRY}/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
# 移除其他tag的镜像
docker rmi ${MY_REGISTRY}/kube-apiserver:v1.15.0
docker rmi ${MY_REGISTRY}/kube-controller-manager:v1.15.0
docker rmi ${MY_REGISTRY}/kube-scheduler:v1.15.0
docker rmi ${MY_REGISTRY}/kube-proxy:v1.15.0
docker rmi ${MY_REGISTRY}/pause:3.1
docker rmi ${MY_REGISTRY}/etcd:3.3.0
docker rmi ${MY_REGISTRY}/coredns:1.3.1
1.16镜像脚本下载
vim pull_image_1.16.sh
# 设置国内镜像源
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/google_containers
# 拉取镜像
docker pull ${MY_REGISTRY}/kube-apiserver:v1.16.0
docker pull ${MY_REGISTRY}/kube-controller-manager:v1.16.0
docker pull ${MY_REGISTRY}/kube-scheduler:v1.16.0
docker pull ${MY_REGISTRY}/kube-proxy:v1.16.0
docker pull ${MY_REGISTRY}/pause:3.1
docker pull ${MY_REGISTRY}/etcd:3.3.15-0
docker pull ${MY_REGISTRY}/coredns:1.6.2
# 添加tag
docker tag ${MY_REGISTRY}/kube-apiserver:v1.16.0 k8s.gcr.io/kube-apiserver:v1.16.0
docker tag ${MY_REGISTRY}/kube-controller-manager:v1.16.0 k8s.gcr.io/kube-controller-manager:v1.16.0
docker tag ${MY_REGISTRY}/kube-scheduler:v1.16.0 k8s.gcr.io/kube-scheduler:v1.16.0
docker tag ${MY_REGISTRY}/kube-proxy:v1.16.0 k8s.gcr.io/kube-proxy:v1.16.0
docker tag ${MY_REGISTRY}/pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/etcd:3.3.15-0 k8s.gcr.io/etcd:3.3.15-0
docker tag ${MY_REGISTRY}/coredns:1.6.2 k8s.gcr.io/coredns:1.6.2
# 移除其他tag的镜像
docker rmi ${MY_REGISTRY}/kube-apiserver:v1.16.0
docker rmi ${MY_REGISTRY}/kube-controller-manager:v1.16.0
docker rmi ${MY_REGISTRY}/kube-scheduler:v1.16.0
docker rmi ${MY_REGISTRY}/kube-proxy:v1.16.0
docker rmi ${MY_REGISTRY}/pause:3.1
docker rmi ${MY_REGISTRY}/etcd:3.3.15-0
docker rmi ${MY_REGISTRY}/coredns:1.6.2
https://my.oschina.net/u/2306127/blog/309587
https://blog.51cto.com/foxhound/2490073
https://v1-15.docs.kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade-1-14/
k8s 节点 not ready原因排查
k8s升级出现问题
删除掉namespace