1

I have a K3s setup with calico pods [calico-node- & calico-kube-controllers-] running. On uninstalling K3s, calico pods get deleted but I see that calicoctl and iptables -S commands still running and shows data.

I want to delete calico (including calicoctl and Iptables created by calico) completely. Which commands will help me to do so ?

K3s uninstalltion command: /usr/local/bin/k3s-uninstall.sh deletes all k3s pods including calico, but calicoctl and iptables -S still works.

PS: I already tried few things -

  1. Command kubectl delete -f https://raw.githubusercontent.com/aws/amazon-vpc-cni-k8s/release-1.5/config/v1.5/calico.yaml deletes the calico-node- but calico-kube-controller , calicoctl and iptables -S are still present
  2. Kubectl delete commands in this que also not working for me, after executing these two commands still calicoctl and iptables -S are present
solveit
  • 255
  • 2
  • 11

2 Answers2

2

Deleting calico-Iptables:

Use calico-policy and add below lines at the end of script:

echo "Flush remaining calico iptables"
iptables-save | grep -i cali | iptables -F

echo "Delete remaining calico iptables"
iptables-save | grep -i cali | iptables -X

This will delete all calico iptables when you check with iptables -S

Note: Run this script only after uninstalling K3S.

Deleting calicoctl:

Simply run sudo rm $(which calicoctl) command, it will find and delete the calicoctl.

0

Here you will find a dedicated script that will remove whole calico policy. Everything you need should be in the script.

Edit: completely guide you can find here

  • Mikolaj-:: while running this script "sh remove-calico-policy.sh" the script goes in sleeping stage and didnt come out of that. the last line sleeping... it get stuck – solveit Aug 03 '21 at 10:50
  • Also calico-node-xxx pods and calicoctl still present after running this script – solveit Aug 03 '21 at 11:08
  • Where did you run this script? Note, that you need to run it on the node. This `sleep` at the end is fine, so DaemonSet doesn't die. It works as expected. I have edited the answer and send you completely guide to remove whole calico policy. – Mikołaj Głodziak Aug 03 '21 at 11:37