How to completely uninstall kubernetes

前端 未结 5 358
说谎
说谎 2020-12-02 15:10

I installed kubernetes cluster using kubeadm following this guide. After some period of time, I decided to reinstall K8s but run into troubles with removing all rel

相关标签:
5条回答
  • 2020-12-02 15:55

    The guide you linked now has a Tear Down section:

    Talking to the master with the appropriate credentials, run:

    kubectl drain <node name> --delete-local-data --force --ignore-daemonsets
    kubectl delete node <node name>
    

    Then, on the node being removed, reset all kubeadm installed state:

    kubeadm reset
    
    0 讨论(0)
  • 2020-12-02 15:55

    If you are clearing the cluster so that you can start again, then, in addition to what @rib47 said, I also do the following to ensure my systems are in a state ready for kubeadm init again:

    kubeadm reset -f
    rm -rf /etc/cni /etc/kubernetes /var/lib/dockershim /var/lib/etcd /var/lib/kubelet /var/run/kubernetes ~/.kube/*
    iptables -F && iptables -X
    iptables -t nat -F && iptables -t nat -X
    iptables -t raw -F && iptables -t raw -X
    iptables -t mangle -F && iptables -t mangle -X
    systemctl restart docker
    

    You then need to re-install docker.io, kubeadm, kubectl, and kubelet to make sure they are at the latest versions for your distribution before you re-initialize the cluster.

    EDIT: Discovered that calico adds firewall rules to the raw table so that needs clearing out as well.

    0 讨论(0)
  • 2020-12-02 15:58

    use kubeadm reset command. this will un-configure the kubernetes cluster.

    0 讨论(0)
  • 2020-12-02 15:58
    kubeadm reset 
    /*On Debian base Operating systems you can use the following command.*/
    # on debian base 
    sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube* 
    
    
    /*On CentOs distribution systems you can use the following command.*/
    #on centos base
    sudo yum remove kubeadm kubectl kubelet kubernetes-cni kube*
    
    
    # on debian base
    sudo apt-get autoremove
    
    #on centos base
    sudo yum autoremove
    
    /For all/
    sudo rm -rf ~/.kube
    
    0 讨论(0)
  • 2020-12-02 16:02

    In my "Ubuntu 16.04", I use next steps to completely remove and clean Kubernetes (installed with "apt-get"):

    kubeadm reset
    sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*   
    sudo apt-get autoremove  
    sudo rm -rf ~/.kube
    

    And restart the computer.

    0 讨论(0)
提交回复
热议问题