Getting started with Kubernetes on MacOS in 2020

Kristofer Lundgren
2 min readNov 5, 2020

Following these instructions, you will end up with a multi host kubernetes cluster running on your local workstation.

We use two main components that uses minimal resources, and are very easy to setup:

  • k3s (https://k3s.io/)
    “K3s is a highly available, certified Kubernetes distribution designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances.”
  • k3d (https://k3d.io/)
    “k3d is a lightweight wrapper to run k3s (Rancher Lab’s minimal Kubernetes distribution) in docker.”

Prerequisites

Download and install:

Install required components using CLI

brew upgrade # Upgrade Homebrew and components
brew install k3d
brew install kubernetes-cli
brew install kubectx
brew install helm
  • k3d (https://k3d.io/)
    “k3d is a lightweight wrapper to run k3s (Rancher Lab’s minimal Kubernetes distribution) in docker.”
  • kubernetes-cli (https://kubernetes.io/docs/reference/kubectl/overview/)
    “The kubectl command line tool lets you control Kubernetes clusters.”
    If you have installed Docker Desktop, kubectl may already be available.
  • kubectx (https://kubectx.dev/)
    kubectx is a utility to manage and switch between kubectl(1) contexts.”
  • helm (https://helm.sh/)
    “Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.”
    Helm in not used in this example, but you will use it eventually.

Start kubernetes cluster

# Create a local kubernetes cluster and
# proxy TCP ports 30000–30100 on host to the cluster:

k3d cluster create mycluster --agents 3 -p "30000-30100:30000-30100@server[0]"
# Update ~/.kube/config with created cluster(s):
k3d kubeconfig merge --all -d
# List available clusters:
kubectx
# Set mycluster as active cluster:
kubectx k3d-mycluster
# Get cluster info:
kubectl cluster-info

Deploy services in your kubernetes cluster

TBD.

Delete local kubernetes cluster(s)

k3d cluster delete --all

--

--

Kristofer Lundgren

A systems engineer using DevOps principles on a daily basis.