canonical / microk8s

MicroK8s is a small, fast, single-package Kubernetes for datacenters and the edge.
https://microk8s.io
Apache License 2.0
8.51k stars 772 forks source link

microk8s processes not stopped when removing the snap #4464

Open bboozzoo opened 8 months ago

bboozzoo commented 8 months ago

Summary

I've installed microk8s from 1.29-strict/edge. I have not created any new pods. After running snap remove --purge microk8s, I see the following processes still running:

...
root        4300       1  0 11:04 ?        00:00:00 /snap/microk8s/6695/bin/containerd-shim-runc-v2 -namespace k8s.io -id 71ec26d969383b2b75811b0ec95f2b22778aca89499e775510b8cd39e0af9543 -address /var/snap/microk8s/common/run/containerd.sock
65535       4319    4300  0 11:04 ?        00:00:00 /pause
...
root        4760    4300  0 11:05 ?        00:00:00 /usr/local/bin/runsvdir -P /etc/service/enabled
root        5295       1  0 11:05 ?        00:00:00 /snap/microk8s/6695/bin/containerd-shim-runc-v2 -namespace k8s.io -id c48304a4faf6db3005fe707fd58db9c07ad4bbd2ef3a87e9fe6d110cdc00e987 -address /var/snap/microk8s/common/run/containerd.sock
65535       5315    5295  0 11:05 ?        00:00:00 /pause
root        5498       1  0 11:05 ?        00:00:00 /snap/microk8s/6695/bin/containerd-shim-runc-v2 -namespace k8s.io -id 418f2894f3f0ddbb83f5d40c2227bce57f3afec0f0827541dbb10b7cd4f0c584 -address /var/snap/microk8s/common/run/containerd.sock
65535       5517    5498  0 11:05 ?        00:00:00 /pause
root        5548    5295  0 11:05 ?        00:00:01 /coredns -conf /etc/coredns/Corefile
lxd         5607    5498  0 11:05 ?        00:00:00 /usr/bin/kube-controllers
...

With some experimentation, I was able to confirm that if any pods are started before, they keep running even after snap remove. So a workaround I've added in snapd spread tests is to:

microk8s kubectl delete pods --all
microk8s kubectl delete nodes --all
microk8s stop

What Should Happen Instead?

I believe those should be part of the snap remove hook, which is invoked when removing the last revision of microk8s in the system.

Reproduction Steps

  1. snap install microk8s --channel=1.29-strict/edge
  2. snap remove --purge microk8s
  3. ps -ef and inspect the process list

Can you suggest a fix?

The remove hooks is an appropriate place for cleaning up.

neoaggelos commented 8 months ago

Hi @bboozzoo

Thank you for raising this. This is currently a limitation with the strictly confined version of MicroK8s, and should not be a problem with the classic flavor.