Topic outline

  • The Bonsai Kube: Kubernetes K3s Installation with Multipass + MetalLB + Portainer

    You need Multipass installed on your machine, if not done yet, please head to or download the multipass package directly and install it.

    Deploy K3s and Portainer on Multipass machines :

    git clone
    cd multipass-k3s-rancher
    export KUBECONFIG=k3s.yaml
    kubectl get nodes

    Install Helm2

    kubectl -n kube-system create serviceaccount tiller
    kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
    helm init --service-account tiller

    Related post

    For more information about the implementation, please refer to the follwoing blog post:
    K3S with MetalLB on Multipass VMs

    • Kubernetes K3s Installation with k3d

      The easiest and fastest way to install Kubenretes is to use the k3d tool to install K3s in docker containers on your local machine. This is one of the preferred methods to install Kubernetes on your local machine for our trainings, although we recommend to have k3s installed in multipass VMs with Portainer as described above.

      Get k3d

      There are many options to install k3d, all of them are easy:
      Use the install script to grab the latest release:

      • wget: wget -q -O - | bash
      • curl: curl -s | bash
      • Use Homebrewbrew install k3d (Homebrew is avaiable for MacOS and Linux)
      • Grab a release from the release tab and install it yourself.

      Create your first k3d made k3s cluster

      k3d create --name dev --workers=3 --api-port 6551 --publish 8081:80
      export KUBECONFIG="$(k3d get-kubeconfig --name='dev')"
      kubectl cluster-info
      kubectl get nodes
      kubectl get pods -A
      # delete the cluster if not needed
      k3d delete --name=dev

      • Kubernetes Kubeadm Installation with Multipass + MetalLB

        In some cases, e.g. if you're going to take the CKA / CKAD exam, it is recommended to have Kubeadm installed on your local machine. The following commands will install Kubeadm with Containerd runtime in Multipass VMs and deploys MetalLB on top:

        git clone
        cd kubeadm-multipass
        export KUBECONFIG=kubeconfig.yaml
        kubectl get nodes
        # Install MetalLB
        # Deploy nginx for testing
        kubectl apply -f nginx-deployment.yaml
        kubectl expose deployment nginx-deployment --type=LoadBalancer --port=80
        kubectl get svc
        curl http://EXTERNAL-IP
        # cleanup if not needed

        • Rancher RKE and Rancher Server Installation on Multipass VMs

          Those Ops or sometimes Devs who'd like to get familiar with a full-fledged Rancher Kubernetes Engine and Rancher Server on their local machine using Multipass VMs to reduce their cloud costs, might want to use this repo:

          • Merging contexts (e.g. merge 2 kubeconfigs from 2 cluster contexts)

            Sometimes you'll need to merge multiple kubeconfigs into a single file, here you go:

            KUBECONFIG=file1:file2:file3 kubectl config view --merge --flatten > my_new_kubeconfig
            cp ~/.kube/config ~/.kube/config.bak
            KUBECONFIG=/my/new/kubeconfig:~/.kube/config.bak kubectl config view --flatten > my_new_kubeconfig
            # test it
            export KUBECONFIG=my_new_kubeconfig
            kx cp my_new_kubeconfig ~/.kube/config

            Don't miss: Mastering the KUBECONFIG file by Ahmet Alp Balkan: