canonical / microk8s

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

An error occurred when trying to execute 'sudo ls -1 /snap/bin/' with 'multipass': returned exit code 2. #3036

Open imoisharma opened 2 years ago

imoisharma commented 2 years ago

Please run microk8s inspect and attach the generated tarball to this issue. An error occurred when trying to execute 'sudo microk8s.inspect' with 'multipass': returned exit code 1.

Hi there,

I am trying to install microk8s on MAC M1 and it doesn't work. I have 10 Core CPU, 32 GB RAM. And, it's failed with this error as mentioned above

➜  ~ microk8s --help
Usage: microk8s [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  install         Installs MicroK8s. Use --cpu, --mem, --disk and --channel to configure your setup.
  uninstall       Removes MicroK8s
ls: cannot access '/snap/bin/': No such file or directory
An error occurred when trying to execute 'sudo ls -1 /snap/bin/' with 'multipass': returned exit code 2.

We appreciate your feedback. Thank you for using microk8s.

ktsakalozos commented 2 years ago

Hi @imoisharma, does the multipass vm run? You should be able to start it with microk8s start. The VM is not available you should be able to create one by calling microk8s install.

imoisharma commented 2 years ago

Hi @imoisharma, does the multipass vm run? You should be able to start it with microk8s start. The VM is not available you should be able to create one by calling microk8s install.

Hi @ktsakalozos, see the below result

➜  ~ microk8s install
MicroK8s is up and running. See the available commands with `microk8s --help`.
➜  ~ microk8s start
sudo: microk8s.start: command not found
An error occurred when trying to execute 'sudo microk8s.start' with 'multipass': returned exit code 1.
ktsakalozos commented 2 years ago

Do you see the multipass VM? What do you see with multipass list? Can you multipass shell inside the microk8s-vm? Is microk8s installed inside the VM? What does snap info microk8s show?

imoisharma commented 2 years ago

Do you see the multipass VM? What do you see with multipass list? Can you multipass shell inside the microk8s-vm? Is microk8s installed inside the VM? What does snap info microk8s show?

Please find all the information below:


➜  ~ microk8s start
sudo: microk8s.start: command not found
An error occurred when trying to execute 'sudo microk8s.start' with 'multipass': returned exit code 1.
➜  ~ multipass list
Name                    State             IPv4             Image
microk8s-vm             Running           192.168.64.2     Ubuntu 18.04 LTS
➜  ~ multipass shell
One quick question before we launch … Would you like to help
the Multipass developers, by sending anonymous usage data?
This includes your operating system, which images you use,
the number of instances, their properties and how long you use them.
We’d also like to measure Multipass’s speed.

Send usage data (yes/no/Later)? yes
Thank you!
Launched: primary
Mounted '/Users/mohit.sharma' into 'primary:Home'
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-105-generic aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri Apr  8 10:29:59 AEST 2022

  System load:             0.69
  Usage of /:              27.1% of 4.68GB
  Memory usage:            20%
  Swap usage:              0%
  Processes:               109
  Users logged in:         0
  IPv4 address for enp0s1: 192.168.64.3
  IPv6 address for enp0s1: fdb4:7c55:accf:c21f:5054:ff:fee2:5351

0 updates can be applied immediately.

The list of available updates is more than a week old.
To check for new updates run: sudo apt update

ubuntu@primary:~$ snap info microk8s
name:      microk8s
summary:   Kubernetes for workstations and appliances
publisher: Canonical✓
store-url: https://snapcraft.io/microk8s
contact:   https://github.com/ubuntu/microk8s
license:   Apache-2.0
description: |
  MicroK8s is a small, fast, secure, single node Kubernetes that installs on
  just about any Linux box. Use it for offline development, prototyping,
  testing, or use it on a VM as a small, cheap, reliable k8s for CI/CD. It's
  also a great k8s for appliances - develop your IoT apps for k8s and deploy
  them to MicroK8s on your boxes.
snap-id: EaXqgt1lyCaxKaQCU349mlodBkDCXRcg
channels:
  1.23/stable:      v1.23.5         2022-04-01 (3054) 192MB classic
  1.23/candidate:   v1.23.5         2022-04-01 (3054) 192MB classic
  1.23/beta:        v1.23.5         2022-04-01 (3054) 192MB classic
  1.23/edge:        v1.23.5         2022-04-07 (3121) 190MB classic
  latest/stable:    v1.23.5         2022-04-02 (3054) 192MB classic
  latest/candidate: v1.23.5         2022-04-01 (3085) 194MB classic
  latest/beta:      v1.23.5         2022-04-01 (3085) 194MB classic
  latest/edge:      v1.23.5         2022-04-07 (3122) 198MB classic
  1.24/stable:      –
  1.24/candidate:   –
  1.24/beta:        v1.24.0-beta.0  2022-04-01 (3086) 194MB classic
  1.24/edge:        v1.24.0-alpha.4 2022-03-31 (3077) 194MB classic
  1.22/stable:      v1.22.6         2022-02-06 (2952) 168MB classic
  1.22/candidate:   v1.22.6         2022-01-27 (2952) 168MB classic
  1.22/beta:        v1.22.8         2022-04-01 (3060) 168MB classic
  1.22/edge:        v1.22.8         2022-04-07 (3119) 169MB classic
  1.21/stable:      v1.21.11        2022-04-01 (3061) 167MB classic
  1.21/candidate:   v1.21.11        2022-04-01 (3061) 167MB classic
  1.21/beta:        v1.21.11        2022-04-01 (3061) 167MB classic
  1.21/edge:        v1.21.11        2022-04-07 (3120) 167MB classic
  1.20/stable:      v1.20.13        2021-12-08 (2762) 189MB classic
  1.20/candidate:   v1.20.13        2021-12-08 (2762) 189MB classic
  1.20/beta:        v1.20.13        2021-12-08 (2762) 189MB classic
  1.20/edge:        v1.20.14        2022-01-11 (2852) 185MB classic
  1.19/stable:      v1.19.15        2021-09-30 (2535) 184MB classic
  1.19/candidate:   v1.19.15        2021-09-29 (2535) 184MB classic
  1.19/beta:        v1.19.15        2021-09-29 (2535) 184MB classic
  1.19/edge:        v1.19.16        2022-01-07 (2823) 180MB classic
  1.18/stable:      v1.18.20        2021-07-18 (2272) 169MB classic
  1.18/candidate:   v1.18.20        2021-07-12 (2272) 169MB classic
  1.18/beta:        v1.18.20        2021-07-12 (2272) 169MB classic
  1.18/edge:        v1.18.20        2021-11-03 (2651) 169MB classic
  1.17/stable:      v1.17.17        2021-04-03 (1923) 149MB classic
  1.17/candidate:   v1.17.17        2021-04-03 (1923) 149MB classic
  1.17/beta:        v1.17.17        2021-04-03 (1923) 149MB classic
  1.17/edge:        v1.17.17        2021-01-13 (1923) 149MB classic
  1.16/stable:      v1.16.15        2020-09-11 (1672) 150MB classic
  1.16/candidate:   v1.16.15        2020-09-03 (1672) 150MB classic
  1.16/beta:        v1.16.15        2020-09-03 (1672) 150MB classic
  1.16/edge:        v1.16.15        2020-09-02 (1672) 150MB classic
  1.15/stable:      v1.15.11        2020-03-27 (1305) 144MB classic
  1.15/candidate:   v1.15.11        2020-03-27 (1305) 144MB classic
  1.15/beta:        v1.15.11        2020-03-27 (1305) 144MB classic
  1.15/edge:        v1.15.11        2020-03-26 (1305) 144MB classic
  1.14/stable:      v1.14.10        2019-12-20 (1121) 164MB classic
  1.14/candidate:   ↑
  1.14/beta:        ↑
  1.14/edge:        v1.14.10        2020-03-26 (1306) 164MB classic
  1.13/stable:      v1.13.6         2019-05-20  (580) 173MB classic
  1.13/candidate:   ↑
  1.13/beta:        ↑
  1.13/edge:        ↑
  1.12/stable:      v1.12.9         2019-06-07  (613) 197MB classic
  1.12/candidate:   ↑
  1.12/beta:        ↑
  1.12/edge:        ↑
  1.11/stable:      –
  1.11/candidate:   –
  1.11/beta:        –
  1.11/edge:        v1.11.1         2018-07-24  (138) 164MB classic
  1.10/stable:      –
  1.10/candidate:   –
  1.10/beta:        –
  1.10/edge:        v1.11.1         2018-07-24  (137) 164MB classic```
ktsakalozos commented 2 years ago

I do not see the MicroK8s installed in the VM. Could you snap install microk8s --classic --channel=1.23/stable inside the microk8s-vm?

imoisharma commented 2 years ago

I do not see the MicroK8s installed in the VM. Could you snap install microk8s --classic --channel=1.23/stable inside the microk8s-vm?

I have installed manually inside the Microk8s-vm

ubuntu@primary:~$ snap info microk8s
name:      microk8s
summary:   Kubernetes for workstations and appliances
publisher: Canonical✓
store-url: https://snapcraft.io/microk8s
contact:   https://github.com/ubuntu/microk8s
license:   unset
description: |
  MicroK8s is a small, fast, secure, single node Kubernetes that installs on
  just about any Linux box. Use it for offline development, prototyping,
  testing, or use it on a VM as a small, cheap, reliable k8s for CI/CD. It's
  also a great k8s for appliances - develop your IoT apps for k8s and deploy
  them to MicroK8s on your boxes.
commands:
  - microk8s.add-node
  - microk8s.cilium
  - microk8s.config
  - microk8s.ctr
  - microk8s.dashboard-proxy
  - microk8s.dbctl
  - microk8s.disable
  - microk8s.enable
  - microk8s.helm
  - microk8s.helm3
  - microk8s.inspect
  - microk8s.istioctl
  - microk8s.join
  - microk8s.juju
  - microk8s.kubectl
  - microk8s.leave
  - microk8s.linkerd
  - microk8s
  - microk8s.refresh-certs
  - microk8s.remove-node
  - microk8s.reset
  - microk8s.start
  - microk8s.status
  - microk8s.stop
services:
  microk8s.daemon-apiserver:            simple, enabled, inactive
  microk8s.daemon-apiserver-kicker:     simple, enabled, active
  microk8s.daemon-cluster-agent:        simple, enabled, active
  microk8s.daemon-containerd:           notify, enabled, active
  microk8s.daemon-control-plane-kicker: simple, enabled, inactive
  microk8s.daemon-controller-manager:   simple, enabled, inactive
  microk8s.daemon-etcd:                 simple, enabled, inactive
  microk8s.daemon-flanneld:             simple, enabled, inactive
  microk8s.daemon-k8s-dqlite:           simple, enabled, active
  microk8s.daemon-kubelet:              simple, enabled, inactive
  microk8s.daemon-kubelite:             simple, enabled, active
  microk8s.daemon-proxy:                simple, enabled, inactive
  microk8s.daemon-scheduler:            simple, enabled, inactive
  microk8s.daemon-traefik:              simple, enabled, inactive
snap-id:      EaXqgt1lyCaxKaQCU349mlodBkDCXRcg
tracking:     1.23/stable
refresh-date: today at 15:27 AEST
channels:
  1.23/stable:      v1.23.5         2022-04-01 (3054) 192MB classic
  1.23/candidate:   v1.23.5         2022-04-01 (3054) 192MB classic
  1.23/beta:        v1.23.5         2022-04-01 (3054) 192MB classic
  1.23/edge:        v1.23.5         2022-04-07 (3121) 190MB classic
  latest/stable:    v1.23.5         2022-04-02 (3054) 192MB classic
  latest/candidate: v1.23.5         2022-04-01 (3085) 194MB classic
  latest/beta:      v1.23.5         2022-04-01 (3085) 194MB classic
  latest/edge:      v1.23.5         2022-04-07 (3122) 198MB classic
  1.24/stable:      –
  1.24/candidate:   –
  1.24/beta:        v1.24.0-beta.0  2022-04-01 (3086) 194MB classic
  1.24/edge:        v1.24.0-alpha.4 2022-03-31 (3077) 194MB classic
  1.22/stable:      v1.22.6         2022-02-06 (2952) 168MB classic
  1.22/candidate:   v1.22.6         2022-01-27 (2952) 168MB classic
  1.22/beta:        v1.22.8         2022-04-01 (3060) 168MB classic
  1.22/edge:        v1.22.8         2022-04-07 (3119) 169MB classic
  1.21/stable:      v1.21.11        2022-04-01 (3061) 167MB classic
  1.21/candidate:   v1.21.11        2022-04-01 (3061) 167MB classic
  1.21/beta:        v1.21.11        2022-04-01 (3061) 167MB classic
  1.21/edge:        v1.21.11        2022-04-07 (3120) 167MB classic
  1.20/stable:      v1.20.13        2021-12-08 (2762) 189MB classic
  1.20/candidate:   v1.20.13        2021-12-08 (2762) 189MB classic
  1.20/beta:        v1.20.13        2021-12-08 (2762) 189MB classic
  1.20/edge:        v1.20.14        2022-01-11 (2852) 185MB classic
  1.19/stable:      v1.19.15        2021-09-30 (2535) 184MB classic
  1.19/candidate:   v1.19.15        2021-09-29 (2535) 184MB classic
  1.19/beta:        v1.19.15        2021-09-29 (2535) 184MB classic
  1.19/edge:        v1.19.16        2022-01-07 (2823) 180MB classic
  1.18/stable:      v1.18.20        2021-07-18 (2272) 169MB classic
  1.18/candidate:   v1.18.20        2021-07-12 (2272) 169MB classic
  1.18/beta:        v1.18.20        2021-07-12 (2272) 169MB classic
  1.18/edge:        v1.18.20        2021-11-03 (2651) 169MB classic
  1.17/stable:      v1.17.17        2021-04-03 (1923) 149MB classic
  1.17/candidate:   v1.17.17        2021-04-03 (1923) 149MB classic
  1.17/beta:        v1.17.17        2021-04-03 (1923) 149MB classic
  1.17/edge:        v1.17.17        2021-01-13 (1923) 149MB classic
  1.16/stable:      v1.16.15        2020-09-11 (1672) 150MB classic
  1.16/candidate:   v1.16.15        2020-09-03 (1672) 150MB classic
  1.16/beta:        v1.16.15        2020-09-03 (1672) 150MB classic
  1.16/edge:        v1.16.15        2020-09-02 (1672) 150MB classic
  1.15/stable:      v1.15.11        2020-03-27 (1305) 144MB classic
  1.15/candidate:   v1.15.11        2020-03-27 (1305) 144MB classic
  1.15/beta:        v1.15.11        2020-03-27 (1305) 144MB classic
  1.15/edge:        v1.15.11        2020-03-26 (1305) 144MB classic
  1.14/stable:      v1.14.10        2019-12-20 (1121) 164MB classic
  1.14/candidate:   ↑
  1.14/beta:        ↑
  1.14/edge:        v1.14.10        2020-03-26 (1306) 164MB classic
  1.13/stable:      v1.13.6         2019-05-20  (580) 173MB classic
  1.13/candidate:   ↑
  1.13/beta:        ↑
  1.13/edge:        ↑
  1.12/stable:      v1.12.9         2019-06-07  (613) 197MB classic
  1.12/candidate:   ↑
  1.12/beta:        ↑
  1.12/edge:        ↑
  1.11/stable:      –
  1.11/candidate:   –
  1.11/beta:        –
  1.11/edge:        v1.11.1         2018-07-24  (138) 164MB classic
  1.10/stable:      –
  1.10/candidate:   –
  1.10/beta:        –
  1.10/edge:        v1.11.1         2018-07-24  (137) 164MB classic
installed:          v1.23.5                    (3054) 192MB classic
ubuntu@primary:~$ exit
logout
➜  ~ microk8s install
MicroK8s is up and running. See the available commands with `microk8s --help`.
➜  ~ microk8s --help
Usage: microk8s [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  install         Installs MicroK8s. Use --cpu, --mem, --disk and --channel to configure your setup.
  uninstall       Removes MicroK8s
ls: cannot access '/snap/bin/': No such file or directory
An error occurred when trying to execute 'sudo ls -1 /snap/bin/' with 'multipass': returned exit code 2.
➜  ~
imoisharma commented 2 years ago

Hi @ktsakalozos, any updates or ideas/recommendations for me?

ktsakalozos commented 2 years ago

If you uninstall and reinstall does it work?

The code that is failing is in _get_microk8s_commands [1] that ends up being a call from the host inside the VM. That call should look something like multipass exec microk8s-vm -- ls -1 /snap/bin. This should work for you in your machine assuming multipass is successfully installed. Is it possible that multipass is not in your path?

[1] https://github.com/canonical/microk8s/blob/master/installer/cli/microk8s.py#L384 [2] https://github.com/canonical/microk8s/blob/master/installer/vm_providers/_multipass/_multipass_command.py#L228

imoisharma commented 2 years ago

Hi @ktsakalozos,

I notice one more thing which I am not sure about as I am very new to microk8s as I have used mostly minikube for past development. When I go inside the VM, then I can see the microk8s status and all pods up and running.

But, I can't the microk8s kubectl get pods command from the mac terminal itself? Is there a way to run everything directly from the mac terminal directly rather than running inside the VM itself?


Also, the above command results
lxc
lxd
lxd.benchmark
lxd.buginfo
lxd.check-kernel
lxd.lxc
lxd.lxc-to-lxd
lxd.migrate
microk8s
microk8s.add-node
microk8s.cilium
microk8s.config
microk8s.ctr
microk8s.dashboard-proxy
microk8s.disable
microk8s.enable
microk8s.helm
microk8s.helm3
microk8s.inspect
microk8s.istioctl
microk8s.join
microk8s.juju
microk8s.kubectl
microk8s.leave
microk8s.linkerd
microk8s.refresh-certs
microk8s.remove-node
microk8s.reset
microk8s.start
microk8s.status
microk8s.stop
➜  ~```
ssmeo commented 1 year ago

I have the same issue with installing the microk8s on windows 10 machine. Are there any updates on this?

ssmeo commented 1 year ago

@imoisharma i think you installed micro8s inside a different machine:

ubuntu@primary:~$ snap info microk8s name: microk8s

This is "primary" not "microk8s-vm"

Happened because you used "multipass shell" instead of "multipass shell microk8s-vm"

ssmeo commented 1 year ago

In my case that was a DNS connection issue described in multipass documentation.

I guess this issue can be closed

amatai commented 7 months ago

Still happens on MacOS with the following error

> microk8s install
Launched: microk8s-vm
An error occurred when trying to execute 'sudo ping -c 1 snapcraft.io' with 'multipass': returned exit code 1.

Resolved with similar command above

> multipass shell microk8s-vm
ubuntu@microk8s-vm:~$ sudo snap install microk8s --classic --channel=1.28/stable
marijus-ravickas commented 6 months ago

MacOS is still failing. Did everything as from previous comment, but got error:

> microk8s status
microk8s is not running. Use microk8s inspect for a deeper inspection.
An error occurred when trying to execute 'sudo microk8s.status' with 'multipass': returned exit code 1.

Resolved with:

> microk8s reset
Disabling all addons
Disabling addon : core/cert-manager
Disabling addon : core/cis-hardening
... 

> microk8s status
microk8s is running
high-availability: no
  datastore master nodes: 127.0.0.1:19001
  datastore standby nodes: none
...

> mkdir ~/.microk8s
> multipass exec microk8s-vm sudo microk8s config > ~/.microk8s/config
> microk8s kubectl get all --all-namespaces
NAMESPACE     NAME                                          READY   STATUS    RESTARTS   AGE
kube-system   pod/calico-kube-controllers-796fb75cc-5gnl7   1/1     Running   0          41m
kube-system   pod/calico-node-kdvg5                         1/1     Running   0          41m