zoukankan      html  css  js  c++  java
  • kubernetes使用kubeadm升级集群

    升级前准本 

    官网: https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-upgrade/
    查看可升级的组件

    [root@hadoop01 yum.repos.d]# kubeadm upgrade plan
    [upgrade/config] Making sure the configuration is correct:
    [upgrade/config] Reading configuration from the cluster...
    [upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
    [preflight] Running pre-flight checks.
    [upgrade] Making sure the cluster is healthy:
    [upgrade] Fetching available versions to upgrade to
    [upgrade/versions] Cluster version: v1.16.0
    [upgrade/versions] kubeadm version: v1.16.2
    External components that should be upgraded manually before you upgrade the control plane with 'kubeadm upgrade apply':
    COMPONENT   CURRENT   AVAILABLE
    Etcd        3.3.11    3.3.15-0
    
    Upgrade to the latest version in the v1.16 series:
    
    COMPONENT            CURRENT   AVAILABLE
    API Server           v1.16.0   v1.16.2
    Controller Manager   v1.16.0   v1.16.2
    Scheduler            v1.16.0   v1.16.2
    Kube Proxy           v1.16.0   v1.16.2
    CoreDNS              1.6.2     1.6.2
    
    You can now apply the upgrade by executing the following command:
    
        kubeadm upgrade apply v1.16.2
    
    _____________________________________________________________________

    上面提示升级之前先升级外部组件etcd,如果kubelet,kubectl,kubeadm版本低则也需要升级
    先导出配置文件

    [root@hadoop03 ~]# kubectl -n kube-system get cm kubeadm-config -oyaml >  kubeadm-config.yaml

    查看版本kubeadm/kubelet/kubectl

    [root@cx--0008 ~]# kubeadm version
    kubeadm version: &version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"archive", BuildDate:"2019-11-25T09:06:09Z", GoVersion:"go1.12.7", Compiler:"gc", Platform:"linux/amd64"}
    [root@hadoop03 ~]# kubectl version
    Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:27:17Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
    [root@hadoop03 ~]# kubelet --version
    Kubernetes v1.16.0

    1 升级ectd组件

      单独升级

    2 升级kubeadm/kubelet/kubectl

      2.1) 使用yum列出可用版本
      一般情况下yum list只会列出最新版本

    [root@cx--0008 ~]# yum list kubectl --showduplicates | sort -r | grep "1.16"
    kubectl.x86_64                       1.16.3-0                        @kubernetes
    kubectl.x86_64                       1.16.0-0                        kubernetes 
    kubectl.x86_64                       1.16.1-0                        kubernetes 
    kubectl.x86_64                       1.16.2-0                        kubernetes 
    kubectl.x86_64                       1.16.3-0                        kubernetes
    [root@cx--0008 ~]# yum list kubeadm --showduplicates | sort -r | grep "1.16"
    kubeadm.x86_64                       1.16.3-0                        @kubernetes
    kubeadm.x86_64                       1.16.0-0                        kubernetes 
    kubeadm.x86_64                       1.16.1-0                        kubernetes 
    kubeadm.x86_64                       1.16.2-0                        kubernetes 
    kubeadm.x86_64                       1.16.3-0                        kubernetes
    [root@cx--0008 ~]# yum list kubelet --showduplicates | sort -r | grep "1.16"
    kubelet.x86_64                       1.16.3-0                        kubernetes 
    kubelet.x86_64                       1.16.3-0                        @kubernetes
    kubelet.x86_64                       1.16.2-0                        kubernetes 
    kubelet.x86_64                       1.16.1-0                        kubernetes 
    kubelet.x86_64                       1.16.0-0                        kubernetes 

      2.1) 安装

    [root@hadoop01 yum.repos.d]# yum -y install kubeadm.x86_64-1.16.2-0
    [root@hadoop01 yum.repos.d]# yum -y install kubelet.x86_64-1.16.2-0
    [root@hadoop01 yum.repos.d]# yum -y install kubectl.x86_64-1.16.2-0

    3 升级集群

      3.1) 下载升级所需镜像
      在执行kubeadm upgrade apply v1.16.2之前我们先要把需要的镜像版本下载好,以便执行命令就不用长久的等待
      这里我们根据kubectl -n kube-system get cm kubeadm-config -oyaml >  kubeadm-config.yaml 集群配置文件把kubernetesVersion改为要升级的版本号

    [root@hadoop01 ~]# kubeadm config images list --config kubeadm-config.yaml
    registry.aliyuncs.com/google_containers/kube-apiserver:v1.16.2
    registry.aliyuncs.com/google_containers/kube-controller-manager:v1.16.2
    registry.aliyuncs.com/google_containers/kube-scheduler:v1.16.2
    registry.aliyuncs.com/google_containers/kube-proxy:v1.16.2
    registry.aliyuncs.com/google_containers/pause:3.1
    registry.aliyuncs.com/google_containers/coredns:1.6.2
    [root@hadoop01 ~]# kubeadm config images pull --config kubeadm-config.yaml
    [config/images] Pulled registry.aliyuncs.com/google_containers/kube-apiserver:v1.16.2
    [config/images] Pulled registry.aliyuncs.com/google_containers/kube-controller-manager:v1.16.2
    [config/images] Pulled registry.aliyuncs.com/google_containers/kube-scheduler:v1.16.2
    [config/images] Pulled registry.aliyuncs.com/google_containers/kube-proxy:v1.16.2
    [config/images] Pulled registry.aliyuncs.com/google_containers/pause:3.1
    [config/images] Pulled registry.aliyuncs.com/google_containers/coredns:1.6.2

      3.2 升级开始

    [root@hadoop01 yum.repos.d]# kubeadm upgrade apply --certificate-renewal=false --config=kubeadm-config.yaml
    
    ////[root@hadoop01 yum.repos.d]# kubeadm upgrade apply  --certificate-renewal=false v1.16.2

      注意: 如果我们的证书有效期是10年或者100年,就不必更新证书了,不然就设 --certificate-renewal=true,更多详细参数请查看官网



  • 相关阅读:
    html基础知识
    Python yield 使用浅析
    XSS跨站攻击
    box-sizing的用法(笔记)
    编译原理中DFA最小化
    提醒自己!!!
    Eclipse下运行maven项目失败且Tomcat服务器也启动不了
    Descriptio Resource Path LocationType Archive for required library: 'D:/apache-maven/apache-maven-3.6.0/mavenrepository/org/springframework/spring-aspects/4.3.7.RELEASE/spring-aspects-4.3.7.RELEASE.
    Eclispe创建maven工程缺失web.xml报web.xml is missing and <failOnMissingWebXml> is set to true的错误
    ssm 出现 Method threw 'org.apache.ibatis.binding.BindingException' exception.Invalid bound statement (not found)……
  • 原文地址:https://www.cnblogs.com/linyouyi/p/11932805.html
Copyright © 2011-2022 走看看