canonical / microk8s

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

Fails on macOS Catalina #1368

Closed jcayzac closed 10 months ago

jcayzac commented 4 years ago

None of the commands provided for setting micro8s up or for reporting issues work on Catalina:

$ microk8s install
Support for 'multipass' needs to be set up. Would you like to do that it now? [y/N]: y
==> Downloading https://github.com/CanonicalLtd/multipass/releases/download/v1.3.0/multipass-1.3.0+mac-Darwin.pkg
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/114128199/2ced4a00-a9d8-11ea-82d1-074169520188?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJ
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'multipass'.
==> Installing Cask multipass
==> Running installer for multipass; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
installer: Package name is multipass
installer: Installing at base path /
installer: The install was successful.
  🥃    multipass was successfully installed!
Waiting for multipass...
Launched: microk8s-vm
ping: snapcraft.io: Temporary failure in name resolution
An error occurred when trying to execute 'sudo ping -c 1 snapcraft.io' with 'multipass': returned exit code 2.
$ microk8s install
MicroK8s is up and running. See the available commands with `microk8s --help`.
$ microk8s stop
sudo: microk8s.stop: command not found
An error occurred when trying to execute 'sudo microk8s.stop' with 'multipass': returned exit code 1.
$ microk8s inspect
sudo: microk8s.inspect: command not found
An error occurred when trying to execute 'sudo microk8s.inspect' with 'multipass': returned exit code 1.
joedborg commented 4 years ago

Hey @jcayzac, sorry you're experiencing this issue. It's likely one of these https://multipass.run/docs/troubleshooting-networking-on-macos

Can you try to do:

microk8s uninstall
microk8s install

to see if you still get the ping error?

Thanks, Joe

ghost commented 4 years ago

Microk8s multipass works on Catalina. However, instead of microk8s.enable it needs to be microk8s enable. A few features that doesn't work are enabling Kubeflow and there seems to be issues installing helm charts.

jcayzac commented 4 years ago

@joedborg the uninstall command thanked me for using microk8s and the subsequent install command failed again with the same error.

joedborg commented 4 years ago

Microk8s multipass works on Catalina. However, instead of microk8s.enable it needs to be microk8s enable. A few features that doesn't work are enabling Kubeflow and there seems to be issues installing helm charts.

Hey @vinhdiesal, can you let me know where you're seeing microk8s.enable so I can fix it, please?

@joedborg the uninstall command thanked me for using microk8s and the subsequent install command failed again with the same error.

@jcayzac Thanks for trying. The quick option would be to use Virtualbox. If you already have it installed, you can run sudo multipass set local.driver=virtualbox. Otherwise, did you manage to go over the debugging steps in the docs I linked above?

ghost commented 4 years ago

Hi @joedborg

On the MAC OSx version of the microk8s, it doesn't take any commands with a period, for example microk8s.enable and microk8s.kubectl will result in an error no matter what comes after it, instead you have to specify microk8s enable and microk8s kubectl. I was able to enable dns, dashboard, ingress, istio, fluentd, storage, metallb, etc. What I had a hard time with is the microk8s enable kubeflow because it always complained about the juju controller and installing helm charts results in network connectivity problems. The microk8s works really well as a host. The network bridge works well as well as long as you follow enable virtual box as the driver and enter in a few commands from the multipass.run website docs section.

In the mean time, I find the best solution for using microk8s on a MAC is using Parallels with Ubuntu 20.04. My mac is performing really well as the Kubernetes host with multiple machines connecting in the cluster. Everything works including Kubeflow.

joedborg commented 4 years ago

Hi @vinhdiesal

We're aware that, if you're used to using the period separator for commands, using the space separator can be confusing. However, we do believe all of our documentation is up-to-date; showing the space separator. If you spot any that isn't, please let us know.

beskow commented 4 years ago

I had the same problem (ping: snapcraft.io: Temporary failure in name resolution). It was caused by dnsmasq already running. After uninstalling it via brew and stopping the process (sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist), microk8s install worked without errors.

mvthomster commented 4 years ago

@joedborg

@jcayzac Thanks for trying. The quick option would be to use Virtualbox. If you already have it installed, you can run sudo multipass set local.driver=virtualbox. Otherwise, did you manage to go over the debugging steps in the docs I linked above?

I had the same problem with multipass. Virtualbox did the trick for me for a quick fix. Installed from here. Then ran sudo multipass set local.driver=virtualbox.

evantorrie commented 3 years ago

I still have this problem on MacOS Big Sur when local.driver=hyperkit.

Note: Further debugging has revealed that the culprit is the usual Cisco Anyconnect installing a DNS proxy system extension in Big Sur

dardosordi commented 3 years ago

Seems to be caused by dnsmasq. Patched it with this change to /usr/local/Cellar/microk8s/2.1.0/libexec/lib/python3.9/site-packages/vm_providers/_base_provider.py

+            self.run("sed -i -e s/^#DNS=.*/DNS=8.8.8.8/ /etc/systemd/resolved.conf".split(), hide_output=True)
+            self.run("systemctl restart systemd-resolved.service".split(), hide_output=True)
            self.run("ping -c 1 snapcraft.io".split(), hide_output=True)
tsluyter commented 2 years ago

Seems to be caused by dnsmasq. Patched it with this change to /usr/local/Cellar/microk8s/2.1.0/libexec/lib/python3.9/site-packages/vm_providers/_base_provider.py

+            self.run("sed -i -e s/^#DNS=.*/DNS=8.8.8.8/ /etc/systemd/resolved.conf".split(), hide_output=True)
+            self.run("systemctl restart systemd-resolved.service".split(), hide_output=True)
            self.run("ping -c 1 snapcraft.io".split(), hide_output=True)

This fix no longer works, as the ping itself may fail on some MacOS situations. Instead, it's better to test connectivity in a different way, for example:

+            self.run("sed -i -e s/^#DNS=.*/DNS=8.8.8.8/ /etc/systemd/resolved.conf".split(), hide_output=True)
+            self.run("systemctl restart systemd-resolved.service".split(), hide_output=True)
+             self.run("nslookup snapcraft.io".split(), hide_output=True)
-             self.run("ping -c 1 snapcraft.io".split(), hide_output=True)
tsluyter commented 2 years ago

Created pull request #2823

tdsanchez commented 2 years ago

FWIW - Root cause of this issue seems to be the Ubuntu image for microk8s doesn't actually have the microk8s snap installed.

It's kind of weak nobody from Canonical figured this out for 2 years.

neoaggelos commented 2 years ago

Hi @tdsanchez

The microk8s snap installation inside the VM is (supposed to be) performed by the installer itself, and it looks like this is failing under some conditions.

tdsanchez commented 2 years ago

The installer downloads an image that should have microk8s installed but instead it's just a regular Multipass VM with snap and nothing else installed.

sjmcdowall commented 1 year ago

I am on MacOS Monterey 12.6 - and can't get microk8s up and running -- having similar but slightly different issues from what I can see above ..

Here is a set of error messages I am seeing -- ` …/play/microk8s  microk8s install  ✔  10078  11:28:48 Launched: microk8s-vm An error occurred when trying to execute 'sudo ping -c 1 snapcraft.io' with 'multipass': returned exit code 1. …/play/microk8s  multipass exec microk8s-vm -- sudo ping -c 1 snapcraft.io  2 ↵  10079  11:29:59 PING snapcraft.io (198.18.2.5) 56(84) bytes of data.

--- snapcraft.io ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms

…/play/microk8s  multipass exec microk8s-vm -- sudo ping -c 1 1.1.1.1  1 ↵  10080  11:30:25 PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data. 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=95.2 ms

--- 1.1.1.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 95.214/95.214/95.214/0.000 ms …/play/microk8s  microk8s status --wait-ready  ✔  10081  11:30:34 sudo: microk8s.status: command not found An error occurred when trying to execute 'sudo microk8s.status --wait-ready' with 'multipass': returned exit code 1.`

I am not sure it's DNS resolution since snapcraft.io resolves to 198.18.2.5 but that just sits there .. which appears to resolve to localhost (?) via this netstat .. which means something is supposed to be running on this address?? I am pretty much a total newbie on microk8s and snap and multipass ..

This was a pure vanilla install via brew install ubuntu/microk8s/microk8s

Any help and direction would be greatly appreciated ..

TIA!

neoaggelos commented 1 year ago

The installer downloads an image that should have microk8s installed but instead it's just a regular Multipass VM with snap and nothing else installed.

This is partly true and partly false. A stock ubuntu VM is launched, and the installer then sets up MicroK8s by installing the snap

…/play/microk8s  microk8s status --wait-ready  heavy_check_mark  10081  11:30:34 sudo: microk8s.status: command not found

@sjmcdowall it appears that for some reason the installation failed. could you clean up and retry with:

# remove old vm
multipass delete microk8s-vm
multipass purge

# reinstall
microk8s install

Thanks!

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.