[Kubernetes (K8S) MicroK8s] Use Homebrew (brew) to install MicroK8s Kubernetes (K8S) on macOS

MicroK8s

MicroK8s is the smallest, fastest, fully-conformant Kubernetes that tracks upstream releases and makes clustering trivial. MicroK8s is great for offline development, prototyping, and testing. Use it on a VM as a small, cheap, reliable k8s for CI/CD. It’s also the best production grade Kubernetes for appliances. Develop IoT apps for k8s and deploy them to MicroK8s on your Linux boxes.

Prerequisites

  • Xcode Command Line Tools

    The Xcode Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS which is consists of the macOS SDK and command-line tools such as Clang, which are installed at this

    For more information about installing and using Xcode Command Line Tools, see the Xcode Command Line Tools

    1
    % xcode-select --install

    After you entered the previous command on Terminal, a pop-up window will appear for confirmation. Click Install to continue.

  • Homebrew

    Homebrew is the Missing Package Manager for macOS (or Linux).

    For more information about installing and using Homebrew, see the Homebrew - https://brew.sh/.

    Install Homebrew (brew).

    1
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Installation

Install microk8s.

1
% brew install ubuntu/microk8s/microk8s

This will download and install a version of Multipass, a VM system for running
Ubuntu and other packages required by MicroK8s.

The second stage is to initialise the MicroK8s environment, This is done by
running the microk8s command which was added to your system in the
previous step:

1
% microk8s install

MicroK8s will run all the components necessary to set up and run a full
Kubernetes environment. On some systems, this can take a minute or two. We
can check when the system is ready by running:

1
% microk8s status --wait-ready

MicroK8s bundles its own version of kubectl for accessing Kubernetes. Use it
to run commands to monitor and control your Kubernetes. For example, to view your node:

1
2
3
4
% microk8s kubectl get nodes

# …or to see the running services:
% microk8s kubectl get services

Usages

Deploy an app

Of course, Kubernetes is meant for deploying apps and services. You can use
the kubectl command to do that as with any Kuberenetes. Try
installing a demo app:

1
% microk8s kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1

It may take a minute or two to install, but you can check the status:

1
% microk8s kubectl get pods

Use add-ons

MicroK8s uses the minimum of components for a pure, lightweight Kubernetes.

However, plenty of extra features are available with a few keystrokes using “add-ons” – pre-packaged components that will provide extra capabilities for your Kubernetes, from simple DNS management to machine learning with Kubeflow!

To start it is recommended to add DNS management to facilitate communication between services. For applications which need storage, the ‘storage’ add-on provides directory space on the host. These are easy to set up:

1
% microk8s enable dns storage

8. Starting and Stopping MicroK8s

MicroK8s will continue running until you decide to stop it. You can stop and start MicroK8s with these simple commands:

1
2
3
4
5
% microk8s stop

# … will stop MicroK8s and its services. You can start again any time by running:

% microk8s start

You can also just reinitialise your Kubernetes with microk8s reset.

FAQs

Error: [email protected]: the bottle needs the Apple Command Line Tools to be installed.

1
2
3
4
5
6
7
8
9
10
11
12
$ brew install ubuntu/microk8s/microk8s
...
Error: [email protected]: the bottle needs the Apple Command Line Tools to be installed.
You can install them, if desired, with:
xcode-select --install

You can try to install from source with:
brew install --build-from-source [email protected]
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.

Install Xode command line tools

1
2
% xcode-select --install
xcode-select: note: install requested for command line developer tools

After you entered the previous command on Terminal, a pop-up window will appear for confirmation. Click Install to continue.

Then, a standard License Agreement will appear. If you want to, you can read them all. Click Agree to continue the installation process.

A pop-up window will appear informing you of the download progress. This time you do nothing. Wait until the download process finished. This can take a long time, it depends on your internet speed.

Or you can install via build from python source.

1
% brew install --build-from-source [email protected]

launch failed: Remote “release” is unknown or unreachable

1
2
3
4
5
6
7
8
% microk8s install
...
🍺 multipass was successfully installed!
Waiting for multipass...
launch failed: Remote "release" is unknown or unreachable
...
An error occurred with the instance when trying to launch with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.

Check your local network and retry it, especially behind proxy.

References

[1] Install MicroK8s on a Mac | Ubuntu - https://ubuntu.com/tutorials/install-microk8s-on-mac-os#1-overview

[2] MicroK8s - Zero-ops Kubernetes for developers, edge and IoT - https://microk8s.io/

[3] Xcode Command Line Tools Installation FAQ - https://www.godo.dev/tutorials/xcode-command-line-tools-installation-faq/

[4] Downloads and Resources - Xcode - Apple Developer - https://developer.apple.com/xcode/resources/

[5] Homebrew - https://brew.sh/

[6] Install Tools | Kubernetes - https://kubernetes.io/docs/tasks/tools/

[7] Kubernetes