Enabling microk8s addons dashboard, storage and dns leads to error

Hello,

following the official tutorial for installing microk8S and enabling add-ons as described leads to this error message:

Traceback (most recent call last):
  File "/snap/microk8s/2262/scripts/wrappers/enable.py", line 43, in <module>
    enable(prog_name="microk8s enable")
  File "/snap/microk8s/2262/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/microk8s/2262/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/microk8s/2262/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/microk8s/2262/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/microk8s/2262/scripts/wrappers/enable.py", line 36, in enable
    enabled_addons, _ = get_status(get_available_addons(get_current_arch()), True)
  File "/snap/microk8s/2262/scripts/wrappers/status.py", line 157, in get_status
    kube_output = kubectl_get("all")
  File "/snap/microk8s/2262/scripts/wrappers/common/utils.py", line 169, in kubectl_get
    return run("kubectl", kubeconfig, "get", cmd, "--all-namespaces", die=False)
  File "/snap/microk8s/2262/scripts/wrappers/common/utils.py", line 39, in run
    result.check_returncode()
  File "/snap/microk8s/2262/usr/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '('kubectl', '--kubeconfig=/var/snap/microk8s/2262/credentials/client.config', 'get', 'all', '--all-namespaces')' returned non-zero exit status 1.

info on workstation:

  • distro: ubuntu 21.10
  • microk8s version: v1.21.1 installed through snap!

is there a way to solve this?

more data

 sudo journalctl -u snap.microk8s.daemon-kubelite

-- Journal begins at Sat 2021-07-10 19:24:50 CEST, ends at Sat 2021-07-10 20:37:42 CEST. --
juil. 10 19:24:57 mikanolab systemd[1]: Started Service for snap application microk8s.daemon-kubelite.
juil. 10 19:24:59 mikanolab microk8s.daemon-kubelite[1823]: + export PATH=/snap/microk8s/2262/usr/sbin:/snap/microk8s/2262/usr/bin:/snap/microk8s/2262/sbin:/snap/microk8s/2262/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/>
juil. 10 19:24:59 mikanolab microk8s.daemon-kubelite[1823]: + PATH=/snap/microk8s/2262/usr/sbin:/snap/microk8s/2262/usr/bin:/snap/microk8s/2262/sbin:/snap/microk8s/2262/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/us>
juil. 10 19:24:59 mikanolab microk8s.daemon-kubelite[2697]: ++ /snap/microk8s/2262/bin/uname -m
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + ARCH=x86_64
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + export LD_LIBRARY_PATH=:/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-linux-gnu:/snap/microk8s/2262/usr/lib/x86_64-linux-gnu
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + LD_LIBRARY_PATH=:/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-linux-gnu:/snap/microk8s/2262/usr/lib/x86_64-linux-gnu
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + export LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void::/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-li>
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void::/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-linux-gnu>
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + export XDG_RUNTIME_DIR=/var/snap/microk8s/common/run
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + XDG_RUNTIME_DIR=/var/snap/microk8s/common/run
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + mkdir -p /var/snap/microk8s/common/run
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + source /snap/microk8s/2262/actions/common/utils.sh
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + app=kubelite
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + '[' -e /var/snap/microk8s/2262/var/lock/lite.lock ']'
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + '[' -e /var/snap/microk8s/2262/var/lock/clustered.lock ']'
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + refresh_opt_in_local_config start-control-plane true kubelite
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + local opt=--start-control-plane
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + local value=true
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + local config_file=/var/snap/microk8s/2262/args/kubelite
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + local replace_line=--start-control-plane=true
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[2786]: ++ grep -qE '^--start-control-plane=' /var/snap/microk8s/2262/args/kubelite
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + run_with_sudo /snap/microk8s/2262/bin/sed -i 's;^--start-control-plane=.*;--start-control-plane=true;' /var/snap/microk8s/2262/args/kubelite
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + '[' -n /var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void::/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-linux-gnu:/snap/mi>
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + GLOBAL_LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void::/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-li>
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + local LD_LIBRARY_PATH=
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + '[' /snap/microk8s/2262/bin/sed == preserve_env ']'
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + sudo LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void::/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap/microk8s/2262/lib/x86_64-linu>
juil. 10 19:25:00 mikanolab sudo[2787]:     root : PWD=/var/snap/microk8s/2262 ; USER=root ; ENV=LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void::/snap/microk8s/2262/lib:/snap/microk8s/2262/usr/lib:/snap>
juil. 10 19:25:00 mikanolab sudo[2787]: pam_unix(sudo:session): session opened for user root by (uid=0)
juil. 10 19:25:00 mikanolab sudo[2787]: pam_unix(sudo:session): session closed for user root
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + '[' -e /var/snap/microk8s/2262/var/lock/stopped.lock ']'
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + n=0
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[1823]: + '[' 0 -ge 20 ']'
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[2798]: + grep default
juil. 10 19:25:00 mikanolab microk8s.daemon-kubelite[2797]: + ip route
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[1823]: + break
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[1823]: + '[' -e /var/snap/microk8s/2262/args/ha-conf ']'
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2875]: ++ get_opt_in_config --storage-dir kube-apiserver
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2875]: ++ local opt=--storage-dir
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2875]: ++ local config_file=/var/snap/microk8s/2262/args/kube-apiserver
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2875]: ++ val=
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2879]: +++ grep -qE '^--storage-dir=' /var/snap/microk8s/2262/args/kube-apiserver
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2886]: +++ grep -E '^--storage-dir' /var/snap/microk8s/2262/args/kube-apiserver
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2887]: +++ cut -d= -f2
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2875]: ++ val='${SNAP_DATA}/var/kubernetes/backend/'
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2875]: ++ echo '${SNAP_DATA}/var/kubernetes/backend/'
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[1823]: + storage_param='${SNAP_DATA}/var/kubernetes/backend/'
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2905]: ++ eval echo '${SNAP_DATA}/var/kubernetes/backend/'
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2905]: +++ echo /var/snap/microk8s/2262/var/kubernetes/backend/
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[1823]: + storage_dir=/var/snap/microk8s/2262/var/kubernetes/backend/
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2906]: ++ grep -qE '^failure-domain' /var/snap/microk8s/2262/args/ha-conf
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2908]: ++ get_opt_in_config failure-domain ha-conf
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2908]: ++ local opt=failure-domain
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2908]: ++ local config_file=/var/snap/microk8s/2262/args/ha-conf
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2908]: ++ val=
juil. 10 19:25:01 mikanolab microk8s.daemon-kubelite[2909]: +++ grep -qE '^failure-domain=' /var/snap/microk8s/2262/args/ha-conf

It is highly likely that microk8s isn’t ready yet.
Can you try microk8s status if it is up and running?

Hello indeed microk8s status reveals that it is not running, and then the microk8s inspect command reveals this output:

Inspecting Certificates
Inspecting services
  Service snap.microk8s.daemon-cluster-agent is running
 **FAIL:  Service snap.microk8s.daemon-containerd is not running**
For more details look at: sudo journalctl -u snap.microk8s.daemon-containerd
  Service snap.microk8s.daemon-apiserver-kicker is running
  Service snap.microk8s.daemon-kubelite is running
  Copy service arguments to the final report tarball
Inspecting AppArmor configuration
Gathering system information
  Copy processes list to the final report tarball
  Copy snap list to the final report tarball
  Copy VM name (or none) to the final report tarball
  Copy disk usage information to the final report tarball
  Copy memory usage information to the final report tarball
  Copy server uptime to the final report tarball
  Copy current linux distribution to the final report tarball
  Copy openSSL information to the final report tarball
  Copy network configuration to the final report tarball
Inspecting kubernetes cluster
  Inspect kubernetes cluster
Inspecting juju
  Inspect Juju
Inspecting kubeflow
  Inspect Kubeflow

thanks for the awesome information.