ThnkBIG

View Original

KubeCon NA 2022 Prep: Install Containers and Kubernetes on M1 Mac

Overview

The time has come for our annual pilgrimage to the source of all cloud native communities that the cloud native computing foundation has provided for us. KubeCon is the foundations flagship conference. Technologists from leading open source projects will share their collective knowledge throughout the week, and its an event that shouldn't be missed. As we are prepping for the deluge of talks and hackery that will be taking place at KubeCon NA 2022 in Detroit Oct 24 - 28, we will be highlighting some tips and tricks of cloud native technologies to ensure you are day zero ready.

In the last year or so since Apple Silicon debuted in the MacBook Pro, developers have had time to try multiple configurations with varying degrees of success. Gone are the days of simplistic virtual box and vmware fusion backed local vms. However, all hope is not lost, as there have been new combatants in the Mac vm arena. One such contender is Colima, which means container in Lima. No matter if you are deploying to public cloud or private cloud, having a solid local development environment where you test your application running is essential.

Enter Colima

Colima is a foss project that enables containers to run on Mac with ease, and has the feels of virtualbox and vagrant.

Colima has a few interesting features such as:

  • M1 Macs and Intel support

  • Intel and Simple CLI interface

  • Docker and Containerd support

  • Port Forwarding

  • Volume mounts

  • Kubernetes

Putting it Altogether

Now that we’ve gotten that out of the way, lets install Colima, Docker, and Minikube and see what we end up with

Install Colima

$ brew install colima

Check if Colima installed

$ colima version
colima version 0.4.5
git commit: c0743565c722d9af03bbfd8f75910ac876bf3b56

runtime: docker
arch: aarch64
client: v20.10.11
server: v20.10.18

Install Docker

$ brew install docker docker-compose

Install Minikube…What is Minikube?

Minikube is a tool that allows us to create a local Kubernetes cluster based on local system requirements. Minikube can be installed with homebrew

$ brew install minikube

Start Colima

$ colima start 
INFO[0000] starting colima                              
INFO[0000] runtime: docker                              
INFO[0000] preparing network ...                         context=vm
INFO[0000] creating and starting ...                     context=vm
INFO[0039] provisioning ...                              context=docker
INFO[0040] starting ...                                  context=docker
INFO[0045] done 

Start Minikube to create our Kubernetes cluster

$ minikube start             
πŸ˜„  minikube v1.27.0 on Darwin 13.0 (arm64)
❗  Kubernetes 1.25.0 has a known issue with resolv.conf. minikube is using a workaround that should work for most use cases.
❗  For more information, see: https://github.com/kubernetes/kubernetes/issues/112135
✨  Using the docker driver based on existing profile
πŸ‘  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
    > index.docker.io/kicbase/sta...:  0 B [______________________] ?% ? p/s 0s
    > index.docker.io/kicbase/sta...:  0 B [______________________] ?% ? p/s 0s
    > gcr.io/k8s-minikube/kicbase...:  0 B [______________________] ?% ? p/s 0s
    > index.docker.io/kicbase/sta...:  0 B [______________________] ?% ? p/s 0s
E1002 18:59:47.896075   13944 cache.go:203] Error downloading kic artifacts:  failed to download kic base image or any fallback image
πŸƒ  Updating the running docker "minikube" container ...
🐳  Preparing Kubernetes v1.25.0 on Docker 20.10.17 ...
πŸ”Ž  Verifying Kubernetes components...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ„  Done! kubectl is now configured to use "minikube

Get Kubernetes Nodes Info from Minikube

$ kubectl get nodes -o wide
NAME       STATUS   ROLES           AGE     VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
minikube   Ready    control-plane   5m58s   v1.25.0   

Get Kubernetes Namespaces

$ kubectl get ns           
NAME              STATUS   AGE
default           Active   6m14s
kube-node-lease   Active   6m15s
kube-public       Active   6m15s
kube-system       Active   6m15s

Lets create a new namespace called sample-app

$ kubectl create ns sample-app
namespace/sample-app created

Now lets verify the namespace was created without issue

$ kubectl get ns              
NAME              STATUS   AGE
default           Active   105m
kube-node-lease   Active   105m
kube-public       Active   105m
kube-system       Active   105m
sample-app        Active   2m4s

➜ kubectl get ns sample-app -o yaml
apiVersion: v1
kind: Namespace
metadata:
  creationTimestamp: "2022-10-03T00:28:30Z"
  labels:
    kubernetes.io/metadata.name: sample-app
  name: sample-app
  resourceVersion: "4788"
  uid: 73f16ddd-f63c-44ba-a89d-dd74b106f659
spec:
  finalizers:
  - kubernetes
status:
  phase: Active

Conclusion

So Colima looks like a great path forward alongside Minikube and Docker in order to deploy a Kubernetes cluster on your Mac operating system. We hope this helps you get going on your M1 Mac and ready for KubeCon. We look forward to seeing you in Detroit. Always ThnkBIG!