kubernetes 升级coredns 组件版本

网友投稿 339 2022-09-11

kubernetes 升级coredns 组件版本

说明:coredns主要是Kubernetes中对域名和ip解析,可以作为内网的dns解析服务器。在日常工作中原来初始化使用k8s的时候,coredns 版本较低,在安全性以及性能等问题上会有一定瑕疵。因此做使用了K8S集群一定时间后,需要对一些K8S组件进行升级。

本文章将介绍下如何升级K8S的coredns 组件。

coredns 备份

mkdir coredns && cd corednskubectl get cm -n kube-system coredns -oyaml > coredns-configmap.yamlkubectl get deploy -n kube-system coredns -oyaml > coredns-deployment-controllers.yamlkubectl get clusterrole system:coredns -oyaml > coredns-clusterrole.yamlkubectl get clusterrolebinding system:coredns -oyaml > coredns-clusterrolebinding.yaml

上述步骤说明:

创建用于存放coredns 旧版本(即当前在运行的版本)备份目录并进入导出coredns 的configmap 文件导出coredns 的deployment控制器文件导出coredns 的clusterrole. (ClusterRole是一组权限的集合,但与Role不同的是,ClusterRole可以在包括所有NameSpce和集群级别的资源或非资源类型进行鉴权。可以理解为:k8s rabac鉴权)导出coredns 的clusterrolebinding (rolebinding 是用来把一个角色绑定到一个目标对象上可以理解为:k8s rabac授权)

下载最新coredns 组件

git clone 组件

cd deployment/kubernetes/./deploy.sh -s | kubectl apply -f -

执行结果如下

[root@k8s-master kubernetes]# ./deploy.sh -s | kubectl apply -f -Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl applyserviceaccount/coredns configuredWarning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl applyclusterrole.rbac.authorization.k8s.io/system:coredns configuredWarning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl applyclusterrolebinding.rbac.authorization.k8s.io/system:coredns configuredWarning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl applyconfigmap/coredns configuredWarning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl applydeployment.apps/coredns configuredWarning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl applyservice/kube-dns configured[root@k8s-master kubernetes]#

检查升级结果

[root@k8s-master kubernetes]# kubectl -n kube-system get pod coredns-65d4dbcc75-hcvdc -o yaml |grep image f:image: {} f:imagePullPolicy: {} image: coredns/coredns:1.9.1 imagePullPolicy: IfNotPresent image: coredns/coredns:1.9.1 imageID: docker-pullable://coredns/coredns@sha256:d5a7db9ab4cb3efc22a08707385c54c328db3df32841d6c4a8ae78f102f1f49a[root@k8s-master kubernetes]#

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Kubernetes对项目Pod出入流量访问控制
下一篇:数字营销时代 做好视频营销这碗饭的“米”从何来?
相关文章

 发表评论

暂时没有评论,来抢沙发吧~