Get the App
SLTechnology News&Howtos  ›  Servers  › 

It only takes five minutes! You can run K3s on mac

Shulou Source: shulou.com Published: 2022-06-03 04:15:40 09月22日 Update

k3s is an open source, lightweight Kubernetes distribution released earlier this year by Rancher Labs, perfect for running Kubernetes in resource-constrained environments. Due to its lightweight nature, it is ideal for developers to explore and experiment on laptops. But the native k3s works better on Linux, so how do we run it on Mac?

We need a tool-Multipass. It provides a command line interface that allows users to coordinate the creation, management, and maintenance of Ubuntu Linux virtual machines to simplify application development and can be used on mac.

First we install Multipass using brew, a package management tool.

brew search multipassbrew cask install multipass

Now use Multipass to create a VM: requires 1GB of memory and 5GB of disk

multipass launch --name k3s --mem 1G --disk 5GLaunched: k3s

Wait for the VM to be created, then start a shell for the VM

multipass shell k3s

Then run curl -sfL https://get.k3s.io|sh -to install k3s

[INFO] Finding latest release[INFO] Using v0.2.0 as release[INFO] Downloading hash https://github.com/rancher/k3s/releases/download/v0.2.0/sha256sum-amd64.txt[INFO] Downloading binary https://github.com/rancher/k3s/releases/download/v0.2.0/k3s[INFO] Verifying binary download[INFO] Installing k3s to /usr/local/bin/k3s[INFO] Creating /usr/local/bin/kubectl symlink to k3s[INFO] Creating /usr/local/bin/crictl symlink to k3s[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh[INFO] systemd: Creating environment file /etc/systemd/system/k3s.service.env[INFO] systemd: Creating service file /etc/systemd/system/k3s.service[INFO] systemd: Enabling k3s unitCreated symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service. [INFO] systemd: Starting k3s

After installing k3s, run it on mac and verify it with kubectl.

multipass@k3s:~$ kubectl get nodesNAME STATUS ROLES AGE VERSIONk3s Ready 7m14s v1.13.4-k3s.1multipass@k3s:~$ kubectl get pods --all-namespacesNAMESPACE NAME READY STATUS RESTARTS AGEkube-system coredns-7748f7f6df-dnsp2 1/1 Running 0 7m15skube-system helm-install-traefik-nqvg8 0/1 Completed 0 7m15skube-system svclb-traefik-6659944cc7-f6rdc 2/2 Running 0 6m53skube-system traefik-5cc8776646-99c66 1/1 Running 0 6m53s

It's done! Now we can run k3s on mac. The next article will build on this article and deploy Jenkins Helm chart on k3s, stay tuned yo!

If you still want to know more about the use of k3s skills, welcome to attend the k3s offline workshop held in Shenzhen on October 26, Rancher Labs senior architect will introduce the functions, features and use scenarios of k3s for you in detail, and conduct live demo, and will also take you to build k3s clusters with your own notebook. Click here to sign up!

Tags: Runs commands tools features notes notebooks lightweight development management done personnel usage skills memory functions scenarios basics great work applications skills are made up of Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Docker Shulou Information vpn Microsoft