canonical / microk8s

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

microk8s wont install with MacOs M1 macmini, Homebrew #4525

Open gsiawGH opened 6 months ago

gsiawGH commented 6 months ago

Summary

M1 macmini, 16G ram, using homebrew to install i've tried uninstalling multipass and microk8s, and reinstalling , and followed this

What Should Happen Instead?

using homebrew to install should work

when i get to this step: microk8s status --wait-ready i get this error: sudo: microk8s.status: command not found An error occurred when trying to execute 'sudo microk8s.status --wait-ready' with 'multipass': returned exit code 1.

Reproduction Steps

sw_vers ProductName: macOS ProductVersion: 14.3 BuildVersion: 23D56

brew uninstall microk8s brew uninstall --cask multipass brew install ubuntu/microk8s/microk8s microk8s install microk8s status --wait-ready ( get error)

multipass list Name State IPv4 Image microk8s-vm Running 192.168.64.4 Ubuntu 22.04 LTS

multipass stop microk8s-vm multipass delete microk8s-vm multipass purge microk8s install microk8s status --wait-ready ( get same error)

Introspection Report

sudo: microk8s.inspect: command not found An error occurred when trying to execute 'sudo microk8s.inspect' with 'multipass': returned exit code 1.

gsiawGH commented 6 months ago

so i deleted everything, and restarted the box

this time, when i run 'microk8s install', it actually asks for password (which it didnt before), but i get a different failure:

🍺 multipass was successfully installed! Waiting for multipass... Warning: the "--mem" long option is deprecated in favour of "--memory". Please update any scripts, etc. Launched: microk8s-vm An error occurred when trying to execute 'sudo ping -c 1 snapcraft.io' with 'multipass': returned exit code 1.

microk8s status --wait-ready sudo: microk8s.status: command not found An error occurred when trying to execute 'sudo microk8s.status --wait-ready' with 'multipass': returned exit code 1.

gsiawGH commented 6 months ago

if i do these step , it installs finally.

multipass shell microk8s-vm sudo snap install microk8s --classic --channel=1.30/stable

gsiawGH commented 6 months ago

but then the next step doesnt work:

microk8s kubectl get nodes E0518 20:21:20.727345 5311 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused E0518 20:21:20.731851 5311 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused E0518 20:21:20.735448 5311 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused E0518 20:21:20.739024 5311 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused E0518 20:21:20.742342 5311 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused The connection to the server localhost:8080 was refused - did you specify the right host or port?

gsiawGH commented 6 months ago

ok, once i followed this, i was able to continue

gsiawGH commented 6 months ago

summary to install on M1 macmini, sonoma 14.5:

brew install ubuntu/microk8s/microk8s microk8s install --cpu 2 --memory 4 --disk 15

MANUAL STEPS to INSTALL version 1.30 (using multipass container)

multipass shell microk8s-vm
sudo snap install microk8s --classic --channel=1.30/stable

MANUAL STEPS to create config file on M1 host: ~/.microk8s/config

Manually create the directory ( mkdir ~/.microk8s )
Grab the config from the VM environment directly ( multipass shell microk8s-vm, sudo microk8s config )
create a file ~/.microk8s/config with the contents 

microk8s status --wait-ready microk8s kubectl get nodes microk8s kubectl get services microk8s kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1 microk8s kubectl delete deployment kubernetes-bootcamp

folushooladipo commented 5 months ago

Yes I also experienced this problem, especially the error of:

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

Using @gsiawGH 's solution, here are the steps that worked for me:

# Said "yes" when the below asked for permission to install multipass. Else,
# you can do `brew install multipass microk8s`
brew install microk8s

# At this stage, running "microk8s install will fail". So instead I get a shell
# inside microk8s-vm and install microk8s
multipass shell microk8s-vm
sudo snap install microk8s --classic
sudo microk8s status --wait-ready
# Within the shell, confirm that microk8s is indeed running a cluster.
sudo microk8s kubectl get nodes
# Lastly within the shell, enable the dashboard
sudo microk8s enable dashboard

# Log out of the shell and back into the host system
exit

# Then configure your host's kubectl to show the 
multipass exec microk8s-vm -- sudo microk8s config > ~/kubeconfig
# Now you can run kubectl without involving microk8s from with a shell in microk8s-vm
kubectl get nodes

# Access the dashboard. This command will show you a token that you'll use to login.
microk8s dashboard-proxy