2

I want to remove Kubernetes from a Debian machine (I didn't do the setup)

I followed the instructions from How to completely uninstall kubernetes

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

But it seems to be still installed:

# which kubeadm
/usr/local/bin/kubeadm

# which kubectl
/usr/local/bin/kubectl

# which kubelet
/usr/local/bin/kubelet

Also, apt list --installed | grep kube* does not return anything, so it make me think it was not installed via apt

Do you know how to clean this machine ? Should I just rm /usr/local/bin/kubectl etc ? I don't really like this idea..

Thanks for help

iAmoric
  • 1,787
  • 3
  • 31
  • 64
  • `apt-get` shouldn't install to `/usr/local`, I wouldn't think, so that's probably why it's not uninstalling from there. How was this / were these installations done in the first place? – underscore_d Jun 17 '20 at 13:32

1 Answers1

3

The method suggested by Rib47 on the answer you indicated is correct to completely remove and clean Kubernetes installed with apt-get.

As mentioned by underscore_d, /usr/local/bin/ isn't the directory where the packages installed by apt-get are placed.

For example, when you install kubectl using apt-get, it's placed on /usr/bin/kubectl and that's what is going to be removed by apt-get purge.

I tested it on my kubeadm cluster lab and I don't have these files at /usr/local/bin/.

You have to revisit all the steps you followed during the install process to know how exactly these files got there.

If you run kubeadm reset, I would say it's safe to remove these files. I suggest you to check if they are being used before removing using the command fuser. This command might not be installed in your linux and you can install it by running sudo apt-get install psmisc. After installing you can run it as in this example:

 $ sudo fuser /usr/bin/kubelet 
/usr/bin/kubelet:    21167e

It means this file is being used by process number 21167.

Checking this process we can see what's using it:

$ ps -aux | grep 21167
root     21167  4.1  0.5 788164 88696 ?        Ssl  08:50   0:07 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=cgroupfs --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2

If the files related to kubernetes you have under /usr/local/bin/ are not in use, I would remove them with no worries.

Mark Watney
  • 5,268
  • 2
  • 11
  • 33
  • 1
    The machine was already set up before I came, so unfortunately I don't know how it was done. But as it was a test environment, we deciced to go with a new VM so the problem does not exists anymore. Thanks anyway for the explanations – iAmoric Jun 24 '20 at 14:23