一、查看当前coredns版本
[root@k8s-master01 ~]# kubectl get pod -n kube-system coredns-6ccb5d565f-8fjrk -oyaml | grep image
image: coredns/coredns:1.8.0
imagePullPolicy: IfNotPresent
image: coredns/coredns:1.8.0
二、升级
2.1、coredns介绍
# coredns官网:https://github.com/coredns/coredns
# 老版本用:kube-dns
# 新版的都用:coredns3
# 部署文档:https://github.com/coredns/deployment/tree/master/kubernetes
2.2、备份原来的cm、deploy、clusterrole、clusterrolebinding
[root@k8s-master01 ~]# kubectl get cm -n kube-system coredns -oyaml > coredns-config.yaml
[root@k8s-master01 ~]# kubectl get deploy -n kube-system coredns -oyaml > coredns-controllers.yaml
[root@k8s-master01 ~]# kubectl get clusterrole system:coredns -oyaml > coredns-clusterrole.yaml
[root@k8s-master01 ~]# kubectl get clusterrolebinding system:coredns -oyaml > coredns-clusterrolebinding.yaml
2.3、升级
# 1、下载文件
[root@k8s-master01 ~]# git clone https://github.com/coredns/deployment.git
# 2、升级
[root@k8s-master01 ~]# cd deployment/kubernetes/
[root@k8s-master01 kubernetes]# ./deploy.sh -s | kubectl apply -f -