728x90

목차

     

    실행 중인 도커(컨테이너, 볼륨, 이미지) 모두 제거

    # 이미지 목록 
    docker images
    # 이미지 삭제
    docker rmi {이미지이름}
    
    # 네트워크 목록
    docker network ls
    # 네트워크 삭제
    docker network rm {네트워크이름}
    
    # 컨테이너 조회
    docker ps
    #컨테이너 삭제
    docker rm -f {컨테이너아이디}
    
    # 볼륨 목록
    docker volume ls
    # 볼륨 삭제
    docker volume rm {볼륨이름}

     

    kubelet, docker 서비스 중지 및 부팅 시 자동실행 설정 제거

    sudo systemctl stop kubelet
    sudo systemctl disable kubelet
    
    # docker를 미리 삭제한 경우 pass
    sudo systemctl stop docker
    sudo systemctl disable docker

     

    k8s 클러스터 디렉토리 모두 제거

    rm -rf /etc/kubernetes /var/lib/kubelet /var/lib/etcd

     

    k8s 초기화

    [root@docker03 run]# kubeadm reset
    W0303 20:48:21.160930   35768 preflight.go:56] [reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
    [reset] Are you sure you want to proceed? [y/N]: y
    [preflight] Running pre-flight checks
    W0303 20:48:21.930371   35768 removeetcdmember.go:106] [reset] No kubeadm config, using etcd pod spec to get data directory
    [reset] Deleted contents of the etcd data directory: /var/lib/etcd
    [reset] Stopping the kubelet service
    [reset] Unmounting mounted directories in "/var/lib/kubelet"
    W0303 20:48:21.935927   35768 cleanupnode.go:134] [reset] Failed to evaluate the "/var/lib/kubelet" directory. Skipping its unmount and cleanup: lstat /var/lib/kubelet: no such file or directory
    W0303 20:48:21.959680   35768 cleanupnode.go:99] [reset] Failed to remove containers: output: E0303 20:48:21.958804   35775 remote_runtime.go:277] "ListPodSandbox with filter from runtime service failed" err="rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/containerd/containerd.sock: connect: no such file or directory\"" filter="&PodSandboxFilter{Id:,State:nil,LabelSelector:map[string]string{},}"
    time="2024-03-03T20:48:21+09:00" level=fatal msg="listing pod sandboxes: rpc error: code = Unavailable desc = connection error: desc = \"transport: Error while dialing dial unix /var/run/containerd/containerd.sock: connect: no such file or directory\""
    , error: exit status 1
    [reset] Deleting contents of directories: [/etc/kubernetes/manifests /etc/kubernetes/pki]
    [reset] Deleting files: [/etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]
    
    The reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d
    
    The reset process does not reset or clean up iptables rules or IPVS tables.
    If you wish to reset iptables, you must do so manually by using the "iptables" command.
    
    If your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
    to reset your system's IPVS tables.
    
    The reset process does not clean your kubeconfig files and you must remove them manually.
    Please, check the contents of the $HOME/.kube/config file.

    필자는 에러가 발생한다. 이것 때문에 재설치를 위해 삭제하는 중이다.

     

    k8s yum으로 제거

    [root@docker03 run]# yum remove -y kubeadm kubectl kubelet kubernetes-cni kube*
    Loaded plugins: fastestmirror
    Resolving Dependencies
    --> Running transaction check
    ---> Package kubeadm.x86_64 0:1.26.3-0 will be erased
    ---> Package kubectl.x86_64 0:1.26.3-0 will be erased
    ---> Package kubelet.x86_64 0:1.26.3-0 will be erased
    ---> Package kubernetes-cni.x86_64 0:1.2.0-0 will be erased
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =============================================================================================
     Package                  Arch             Version               Repository             Size
    =============================================================================================
    Removing:
     kubeadm                  x86_64           1.26.3-0              @kubernetes            45 M
     kubectl                  x86_64           1.26.3-0              @kubernetes            46 M
     kubelet                  x86_64           1.26.3-0              @kubernetes           116 M
     kubernetes-cni           x86_64           1.2.0-0               @kubernetes            49 M
    
    Transaction Summary
    =============================================================================================
    Remove  4 Packages
    
    Installed size: 255 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Erasing    : kubeadm-1.26.3-0.x86_64                                                   1/4
      Erasing    : kubelet-1.26.3-0.x86_64                                                   2/4
    warning: file /etc/kubernetes/manifests: remove failed: No such file or directory
      Erasing    : kubernetes-cni-1.2.0-0.x86_64                                             3/4
      Erasing    : kubectl-1.26.3-0.x86_64                                                   4/4
      Verifying  : kubectl-1.26.3-0.x86_64                                                   1/4
      Verifying  : kubeadm-1.26.3-0.x86_64                                                   2/4
      Verifying  : kubelet-1.26.3-0.x86_64                                                   3/4
      Verifying  : kubernetes-cni-1.2.0-0.x86_64                                             4/4
    
    Removed:
      kubeadm.x86_64 0:1.26.3-0         kubectl.x86_64 0:1.26.3-0   kubelet.x86_64 0:1.26.3-0
      kubernetes-cni.x86_64 0:1.2.0-0
    
    Complete!
    [root@docker03 run]# yum autoremove -y
    Loaded plugins: fastestmirror
    Resolving Dependencies
    --> Running transaction check
    ---> Package conntrack-tools.x86_64 0:1.4.4-7.el7 will be erased
    ---> Package cri-tools.x86_64 0:1.26.0-0 will be erased
    ---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be erased
    ---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be erased
    ---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be erased
    ---> Package socat.x86_64 0:1.7.3.2-2.el7 will be erased
    --> Finished Dependency Resolution
    --> Finding unneeded leftover dependencies
    ---> Marking libnetfilter_cthelper to be removed - no longer needed by conntrack-tools
    ---> Marking libnetfilter_cttimeout to be removed - no longer needed by conntrack-tools
    ---> Marking libnetfilter_queue to be removed - no longer needed by conntrack-tools
    ---> Marking libseccomp to be removed - no longer needed by slirp4netns
    ---> Marking libcgroup to be removed - no longer needed by policycoreutils-python
    ---> Marking audit-libs-python to be removed - no longer needed by policycoreutils-python
    ---> Marking libsemanage-python to be removed - no longer needed by policycoreutils-python
    ---> Marking setools-libs to be removed - no longer needed by policycoreutils-python
    ---> Marking python-IPy to be removed - no longer needed by policycoreutils-python
    ---> Marking checkpolicy to be removed - no longer needed by policycoreutils-python
    ---> Marking fuse3-libs to be removed - no longer needed by fuse-overlayfs
    Found and removing 11 unneeded dependencies
    --> Running transaction check
    ---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be erased
    ---> Package checkpolicy.x86_64 0:2.5-8.el7 will be erased
    ---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be erased
    ---> Package libcgroup.x86_64 0:0.41-21.el7 will be erased
    ---> Package libnetfilter_cthelper.x86_64 0:1.0.0-11.el7 will be erased
    ---> Package libnetfilter_cttimeout.x86_64 0:1.0.0-7.el7 will be erased
    ---> Package libnetfilter_queue.x86_64 0:1.0.2-2.el7_2 will be erased
    ---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be erased
    ---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be erased
    ---> Package python-IPy.noarch 0:0.75-6.el7 will be erased
    ---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be erased
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =============================================================================================
     Package                       Arch          Version               Repository           Size
    =============================================================================================
    Removing:
     conntrack-tools               x86_64        1.4.4-7.el7           @base               550 k
     cri-tools                     x86_64        1.26.0-0              @kubernetes          40 M
     fuse-overlayfs                x86_64        0.7.2-6.el7_8         @docker-repo        116 k
     policycoreutils-python        x86_64        2.5-34.el7            @docker-repo        1.2 M
     slirp4netns                   x86_64        0.4.3-4.el7_8         @docker-repo        169 k
     socat                         x86_64        1.7.3.2-2.el7         @base               1.1 M
    Removing for dependencies:
     audit-libs-python             x86_64        2.8.5-4.el7           @docker-repo        316 k
     checkpolicy                   x86_64        2.5-8.el7             @docker-repo        1.2 M
     fuse3-libs                    x86_64        3.6.1-4.el7           @docker-repo        270 k
     libcgroup                     x86_64        0.41-21.el7           @docker-repo        134 k
     libnetfilter_cthelper         x86_64        1.0.0-11.el7          @base                35 k
     libnetfilter_cttimeout        x86_64        1.0.0-7.el7           @base                39 k
     libnetfilter_queue            x86_64        1.0.2-2.el7_2         @base                45 k
     libseccomp                    x86_64        2.3.1-4.el7           @docker-repo        297 k
     libsemanage-python            x86_64        2.5-14.el7            @docker-repo        441 k
     python-IPy                    noarch        0.75-6.el7            @docker-repo        119 k
     setools-libs                  x86_64        3.3.8-4.el7           @docker-repo        1.8 M
    
    Transaction Summary
    =============================================================================================
    Remove  6 Packages (+11 Dependent packages)
    
    Installed size: 48 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Erasing    : policycoreutils-python-2.5-34.el7.x86_64                                 1/17
      Erasing    : conntrack-tools-1.4.4-7.el7.x86_64                                       2/17
      Erasing    : python-IPy-0.75-6.el7.noarch                                             3/17
      Erasing    : cri-tools-1.26.0-0.x86_64                                                4/17
      Erasing    : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                      5/17
      Erasing    : slirp4netns-0.4.3-4.el7_8.x86_64                                         6/17
      Erasing    : libseccomp-2.3.1-4.el7.x86_64                                            7/17
      Erasing    : fuse3-libs-3.6.1-4.el7.x86_64                                            8/17
      Erasing    : libnetfilter_cthelper-1.0.0-11.el7.x86_64                                9/17
      Erasing    : libnetfilter_cttimeout-1.0.0-7.el7.x86_64                               10/17
      Erasing    : libnetfilter_queue-1.0.2-2.el7_2.x86_64                                 11/17
      Erasing    : audit-libs-python-2.8.5-4.el7.x86_64                                    12/17
      Erasing    : checkpolicy-2.5-8.el7.x86_64                                            13/17
      Erasing    : setools-libs-3.3.8-4.el7.x86_64                                         14/17
      Erasing    : libcgroup-0.41-21.el7.x86_64                                            15/17
      Erasing    : libsemanage-python-2.5-14.el7.x86_64                                    16/17
      Erasing    : socat-1.7.3.2-2.el7.x86_64                                              17/17
      Verifying  : checkpolicy-2.5-8.el7.x86_64                                             1/17
      Verifying  : fuse3-libs-3.6.1-4.el7.x86_64                                            2/17
      Verifying  : conntrack-tools-1.4.4-7.el7.x86_64                                       3/17
      Verifying  : libnetfilter_queue-1.0.2-2.el7_2.x86_64                                  4/17
      Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                     5/17
      Verifying  : cri-tools-1.26.0-0.x86_64                                                6/17
      Verifying  : libsemanage-python-2.5-14.el7.x86_64                                     7/17
      Verifying  : setools-libs-3.3.8-4.el7.x86_64                                          8/17
      Verifying  : slirp4netns-0.4.3-4.el7_8.x86_64                                         9/17
      Verifying  : libnetfilter_cttimeout-1.0.0-7.el7.x86_64                               10/17
      Verifying  : python-IPy-0.75-6.el7.noarch                                            11/17
      Verifying  : libseccomp-2.3.1-4.el7.x86_64                                           12/17
      Verifying  : policycoreutils-python-2.5-34.el7.x86_64                                13/17
      Verifying  : libnetfilter_cthelper-1.0.0-11.el7.x86_64                               14/17
      Verifying  : socat-1.7.3.2-2.el7.x86_64                                              15/17
      Verifying  : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                     16/17
      Verifying  : libcgroup-0.41-21.el7.x86_64                                            17/17
    
    Removed:
      conntrack-tools.x86_64 0:1.4.4-7.el7       cri-tools.x86_64 0:1.26.0-0
      fuse-overlayfs.x86_64 0:0.7.2-6.el7_8      policycoreutils-python.x86_64 0:2.5-34.el7
      slirp4netns.x86_64 0:0.4.3-4.el7_8         socat.x86_64 0:1.7.3.2-2.el7
    
    Dependency Removed:
      audit-libs-python.x86_64 0:2.8.5-4.el7        checkpolicy.x86_64 0:2.5-8.el7
      fuse3-libs.x86_64 0:3.6.1-4.el7               libcgroup.x86_64 0:0.41-21.el7
      libnetfilter_cthelper.x86_64 0:1.0.0-11.el7   libnetfilter_cttimeout.x86_64 0:1.0.0-7.el7
      libnetfilter_queue.x86_64 0:1.0.2-2.el7_2     libseccomp.x86_64 0:2.3.1-4.el7
      libsemanage-python.x86_64 0:2.5-14.el7        python-IPy.noarch 0:0.75-6.el7
      setools-libs.x86_64 0:3.3.8-4.el7
    
    Complete!

     

    환경 변수 설정 제거

    sudo sed -i '/KUBELET_KUBEADM_EXTRA_ARGS/d' /etc/sysconfig/kubelet
    sudo sed -i '/KUBELET_EXTRA_ARGS/d' /etc/sysconfig/kubelet

     

    k8s 클러스터 관련 디렉토리 모두 제거

    rm -rf /var/lib/cni/
    rm -rf /var/lib/kubelet/*
    rm -rf /var/lib/etcd/
    rm -rf /etc/cni/
    rm -rf /etc/kubernetes
    rm -rf ~/.kube
    728x90
    TOP