On this tutorial, we will look at how to run Kubernetes on macOS Desktop using Rancher Desktop. First we will begin by trying to understand what Kubernetes is and what Containers is. Kubernetes is a platform that was open sourced in 2014 by Google, it can run seamlessly on any environment, is extensible, and used widely to manage containerized services and workloads, that ensures deployment automation and general orchestration of applications that have been containerized. Since we also mentioned the phrase containerized, it is important that we also look at what it means. Containerization is the process by which software code is bundled with Operating System libraries as well as dependencies needed to run the code so as to form a single lightweight executables referred to as Containers. Containers can not only run on any environment, they also make it much easier to share resources such as the CPU, networks resources, storage and memory.

Rancher Desktop on the other hand, helps to operate Kubernetes and container management on your desktop. This application allows you to make a choice on the version of Kubernetes you want to execute, it is open source and can run on Linux, Mac and Windows. What Rancher desktop does is that it makes use of a virtual machine to operate containerd or dockerd and Kubernetes. Below are some of the features of Rancher Desktop that makes it unique in every way possible;

  • Kubernetes Configuration is now simple, the simple user interface offered by Rancher Desktop makes easier to figure out how Kubernetes works
  • Port forwarding Kubernetes is just but a button click away
  • Containerd, kubectl, k8s and Moby among many more are the proven projects utilized to perform the dirty work
  • Rancher Desktop makes it easy for you to match Kubernetes version that operate locally and those in production
  • Easy to work with images and containers with the use of nerdctl or Docker CLI
  • Container Management made easier with Rancher Desktop

Belo is an illustration of how Rancher Desktop works;

Run Kubernetes on macOS Desktop using Rancher Desktop

Having summarized what Kubernetes is, what containers are and what Rancher Desktop is all about, we can then proceed with the process of how to run Kubernetes on macOS Desktop using Rancher Desktop. Check below for a detailed step by step process on how the installation unfolds, stay tuned;

Step 1. Install Rancher Desktop on macOS system

Since we will need rancher desktop to run Kubernetes, we first need to install Rancher Desktop on our macOS system. Before we begin the installation, check first if you meet the following requirements;

  • macOS Catalina 10.15 or higher
  • Apple Silicon (M1) or Intel CPU with VT-x
  • Persistent internet connection
  • Recommended 8 GB of memory
  • Recommended 4 CPU

We can then proceed as follows. Go to the Rancher Desktop downloads page and tap on your preferred Rancher Desktop download, whether Intel, or Apple. Ensure to first check the type of chip your mac is using, tap on Apple icon at the top left of your desktop, then click on about this mac. Like as shown;

For our case above we are using the Intel Chip, and that is the one we are going to download. In case you are using the Apple Chip ensure to download the Apple one too. The figure below illustrates well;

  • We will download the Intel type by tapping on the downward arrow
  • Navigate to the directory where the installer has been downloaded to, which is often the Downloads section
  • Double click on the .dmg file
  • Proceed to drag Rancher Desktop to Applications folder, just like the arrow suggest below;

Step 2. Launch Rancher Desktop on macOS

To launch Rancher Desktop, proceed to the Applications folder, find Rancher Desktop then, double click on it to launch. Allow verification to finish, agree to open. Below is how it appears, once launched, check the box indicating enable Kubernetes, the tap on Accept;

  • Tap OK to allow administrative access required;
  • On the next pop up window, enter the password.
  • Below is the final output on how you get welcomed to Rancher Desktop;

Step 3. Install Kubectl on macOS system

The Kubectl command is necessary in controlling the Kubernetes cluster. To install Kubectl, we will use the Homebrew package installer. Run the command below to install kubectl;

╭─annalianie at technixleo in ~ 22-06-24 - 13:48:17
╰─○ brew install kubectl

Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
adamstark-audiofile  hwatch               mcap                 req
astro                install-peerdeps     nb                   swtpm
fastnetmon           jaq                  phrase-cli           tuc
flock                libpython-tabulate   poac                 zx
gold                 markdown-toc         [email protected]
==> New Casks
betterandbetter      elephicon            miaoyan              twitch-studio
betterdisplay        fertigt-slate        phpwebstudy          ui
cleaneronepro        fly-key              plex-htpc            wow
dixa                 localxpose           tailscale
dmg-canvas           metadatics           tmpdisk

You have 2 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

==> Downloading https://ghcr.io/v2/homebrew/core/kubernetes-cli/manifests/1.24.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/kubernetes-cli/blobs/sha256:b6c15
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha2
######################################################################## 100.0%
==> Pouring kubernetes-cli--1.24.2.monterey.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/kubernetes-cli/1.24.2: 228 files, 56.4MB
==> Running `brew cleanup kubernetes-cli`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Step 4. Proceed to Use Kubernetes on macOS System

Proceed by utlizing the kubectl command, check below for more information.

To obtain running nodes, use the command;

╭─annalianie at technixleo in ~ 22-06-24 - 14:21:40
╰─○ kubectl get nodes
NAME                   STATUS   ROLES                  AGE   VERSION
lima-rancher-desktop   Ready    control-plane,master   43m   v1.23.6+k3s1

To get more information on the nodes, run the command;

╭─annalianie at technixleo in ~ 22-06-24 - 14:22:03
╰─○ kubectl describe nodes
Name:               lima-rancher-desktop
Roles:              control-plane,master
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/instance-type=k3s
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=lima-rancher-desktop
                    kubernetes.io/os=linux
                    node-role.kubernetes.io/control-plane=true
                    node-role.kubernetes.io/master=true
                    node.kubernetes.io/instance-type=k3s
Annotations:        alpha.kubernetes.io/provided-node-ip: 192.168.100.243
                    flannel.alpha.coreos.com/backend-data: {"VNI":1,"VtepMAC":"46:ac:5d:b1:ff:d6"}
                    flannel.alpha.coreos.com/backend-type: vxlan
                    flannel.alpha.coreos.com/kube-subnet-manager: true
                    flannel.alpha.coreos.com/public-ip: 192.168.100.243
                    k3s.io/hostname: lima-rancher-desktop
                    k3s.io/internal-ip: 192.168.100.243
                    k3s.io/node-args:
                      ["server","--https-listen-port","6443","--flannel-iface","rd0","--container-runtime-endpoint","/run/k3s/containerd/containerd.sock"]
                    k3s.io/node-config-hash: ZGMYEYUTLWKUB5YF5MZI3RECQFE6LXA3AHIUA5OGZTKDNTGEHNPQ====
                    k3s.io/node-env: {"K3S_DATA_DIR":"/var/lib/rancher/k3s/data/8c2b0191f6e36ec6f3cb68e2302fcc4be850c6db31ec5f8a74e4b3be403101d8"}
                    node.alpha.kubernetes.io/ttl: 0
                    volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp:  Fri, 24 Jun 2022 13:38:21 +0300
Taints:             <none>
Unschedulable:      false
Lease:
  HolderIdentity:  lima-rancher-desktop
  AcquireTime:     <unset>
  RenewTime:       Fri, 24 Jun 2022 14:22:31 +0300
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  MemoryPressure   False   Fri, 24 Jun 2022 14:19:29 +0300   Fri, 24 Jun 2022 13:38:21 +0300   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Fri, 24 Jun 2022 14:19:29 +0300   Fri, 24 Jun 2022 13:38:21 +0300   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Fri, 24 Jun 2022 14:19:29 +0300   Fri, 24 Jun 2022 13:38:21 +0300   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Fri, 24 Jun 2022 14:19:29 +0300   Fri, 24 Jun 2022 13:38:31 +0300   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:  192.168.100.243
  Hostname:    lima-rancher-desktop
Capacity:
  cpu:                2
  ephemeral-storage:  102625208Ki
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             4032864Ki
  pods:               110
Allocatable:
  cpu:                2
  ephemeral-storage:  99833802265
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             4032864Ki
  pods:               110
System Info:
  Machine ID:                 ac7c8e15ed5f2f50b22950c8cf9362c1
  System UUID:                ac7c8e15ed5f2f50b22950c8cf9362c1
  Boot ID:                    3d2ac670-becc-4a37-94b4-a5da53880b0d
  Kernel Version:             5.15.40-0-virt
  OS Image:                   Alpine Linux v3.15
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  containerd://1.5.11
  Kubelet Version:            v1.23.6+k3s1
  Kube-Proxy Version:         v1.23.6+k3s1
PodCIDR:                      10.42.0.0/24
PodCIDRs:                     10.42.0.0/24
ProviderID:                   k3s://lima-rancher-desktop
Non-terminated Pods:          (5 in total)
  Namespace                   Name                                       CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age
  ---------                   ----                                       ------------  ----------  ---------------  -------------  ---
  kube-system                 coredns-d76bd69b-sb6zg                     100m (5%)     0 (0%)      70Mi (1%)        170Mi (4%)     43m
  kube-system                 local-path-provisioner-6c79684f77-lmhrw    0 (0%)        0 (0%)      0 (0%)           0 (0%)         43m
  kube-system                 metrics-server-7cd5fcb6b7-6697x            100m (5%)     0 (0%)      70Mi (1%)        0 (0%)         43m
  kube-system                 svclb-traefik-ghh2d                        0 (0%)        0 (0%)      0 (0%)           0 (0%)         43m
  kube-system                 traefik-df4ff85d6-hxcmv                    0 (0%)        0 (0%)      0 (0%)           0 (0%)         43m
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests    Limits
  --------           --------    ------
  cpu                200m (10%)  0 (0%)
  memory             140Mi (3%)  170Mi (4%)
  ephemeral-storage  0 (0%)      0 (0%)
  hugepages-1Gi      0 (0%)      0 (0%)
  hugepages-2Mi      0 (0%)      0 (0%)
Events:
  Type     Reason                   Age                From                   Message
  ----     ------                   ----               ----                   -------
  Normal   Starting                 44m                kube-proxy
  Normal   NodeHasSufficientPID     44m (x2 over 44m)  kubelet                Node lima-rancher-desktop status is now: NodeHasSufficientPID
  Normal   NodeAllocatableEnforced  44m                kubelet                Updated Node Allocatable limit across pods
  Warning  InvalidDiskCapacity      44m                kubelet                invalid capacity 0 on image filesystem
  Normal   NodeHasSufficientMemory  44m (x2 over 44m)  kubelet                Node lima-rancher-desktop status is now: NodeHasSufficientMemory
  Normal   NodeHasNoDiskPressure    44m (x2 over 44m)  kubelet                Node lima-rancher-desktop status is now: NodeHasNoDiskPressure
  Normal   Starting                 44m                kubelet                Starting kubelet.
  Normal   Synced                   44m                cloud-node-controller  Node synced successfully
  Normal   NodeReady                44m                kubelet                Node lima-rancher-desktop status is now: NodeReady
  Normal   RegisteredNode           43m                node-controller        Node lima-rancher-desktop event: Registered Node lima-rancher-desktop in Controller

List services in the namespace;

╭─annalianie at technixleo in ~ 22-06-24 - 14:22:49
╰─○ kubectl get services
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.43.0.1    <none>        443/TCP   61m

List all pods in all namespaces;

╭─annalianie at technixleo in ~ 22-06-24 - 14:40:14
╰─○ kubectl get pods --all-namespaces
NAMESPACE     NAME                                      READY   STATUS      RESTARTS   AGE
kube-system   coredns-d76bd69b-sb6zg                    1/1     Running     0          64m
kube-system   local-path-provisioner-6c79684f77-lmhrw   1/1     Running     0          64m
kube-system   metrics-server-7cd5fcb6b7-6697x           1/1     Running     0          64m
kube-system   helm-install-traefik-crd-kcjkl            0/1     Completed   0          64m
kube-system   svclb-traefik-ghh2d                       2/2     Running     0          63m
kube-system   helm-install-traefik-8xmzm                0/1     Completed   0          64m
kube-system   traefik-df4ff85d6-hxcmv                   1/1     Running     0          63m

List supported resource types;

╭─annalianie at technixleo in ~ 22-06-24 - 14:42:45
╰─○ kubectl api-resources
NAME                              SHORTNAMES   APIVERSION                             NAMESPACED   KIND
bindings                                       v1                                     true         Binding
componentstatuses                 cs           v1                                     false        ComponentStatus
configmaps                        cm           v1                                     true         ConfigMap
endpoints                         ep           v1                                     true         Endpoints
events                            ev           v1                                     true         Event
limitranges                       limits       v1                                     true         LimitRange
namespaces                        ns           v1                                     false        Namespace
nodes                             no           v1                                     false        Node
persistentvolumeclaims            pvc          v1                                     true         PersistentVolumeClaim
persistentvolumes                 pv           v1                                     false        PersistentVolume
pods                              po           v1                                     true         Pod
podtemplates                                   v1                                     true         PodTemplate
replicationcontrollers            rc           v1                                     true         ReplicationController
resourcequotas                    quota        v1                                     true         ResourceQuota
secrets                                        v1                                     true         Secret
serviceaccounts                   sa           v1                                     true         ServiceAccount
services                          svc          v1                                     true         Service
mutatingwebhookconfigurations                  admissionregistration.k8s.io/v1        false        MutatingWebhookConfiguration
validatingwebhookconfigurations                admissionregistration.k8s.io/v1        false        ValidatingWebhookConfiguration
customresourcedefinitions         crd,crds     apiextensions.k8s.io/v1                false        CustomResourceDefinition
apiservices                                    apiregistration.k8s.io/v1              false        APIService
controllerrevisions                            apps/v1                                true         ControllerRevision
daemonsets                        ds           apps/v1                                true         DaemonSet
deployments                       deploy       apps/v1                                true         Deployment
replicasets                       rs           apps/v1                                true         ReplicaSet
statefulsets                      sts          apps/v1                                true         StatefulSet
tokenreviews                                   authentication.k8s.io/v1               false        TokenReview
localsubjectaccessreviews                      authorization.k8s.io/v1                true         LocalSubjectAccessReview
selfsubjectaccessreviews                       authorization.k8s.io/v1                false        SelfSubjectAccessReview
selfsubjectrulesreviews                        authorization.k8s.io/v1                false        SelfSubjectRulesReview
subjectaccessreviews                           authorization.k8s.io/v1                false        SubjectAccessReview
horizontalpodautoscalers          hpa          autoscaling/v2                         true         HorizontalPodAutoscaler
cronjobs                          cj           batch/v1                               true         CronJob
jobs                                           batch/v1                               true         Job
certificatesigningrequests        csr          certificates.k8s.io/v1                 false        CertificateSigningRequest
leases                                         coordination.k8s.io/v1                 true         Lease
endpointslices                                 discovery.k8s.io/v1                    true         EndpointSlice
events                            ev           events.k8s.io/v1                       true         Event
flowschemas                                    flowcontrol.apiserver.k8s.io/v1beta2   false        FlowSchema
prioritylevelconfigurations                    flowcontrol.apiserver.k8s.io/v1beta2   false        PriorityLevelConfiguration
helmchartconfigs                               helm.cattle.io/v1                      true         HelmChartConfig
helmcharts                                     helm.cattle.io/v1                      true         HelmChart
addons                                         k3s.cattle.io/v1                       true         Addon
nodes                                          metrics.k8s.io/v1beta1                 false        NodeMetrics
pods                                           metrics.k8s.io/v1beta1                 true         PodMetrics
ingressclasses                                 networking.k8s.io/v1                   false        IngressClass
ingresses                         ing          networking.k8s.io/v1                   true         Ingress
networkpolicies                   netpol       networking.k8s.io/v1                   true         NetworkPolicy
runtimeclasses                                 node.k8s.io/v1                         false        RuntimeClass
poddisruptionbudgets              pdb          policy/v1                              true         PodDisruptionBudget
podsecuritypolicies               psp          policy/v1beta1                         false        PodSecurityPolicy
clusterrolebindings                            rbac.authorization.k8s.io/v1           false        ClusterRoleBinding
clusterroles                                   rbac.authorization.k8s.io/v1           false        ClusterRole
rolebindings                                   rbac.authorization.k8s.io/v1           true         RoleBinding
roles                                          rbac.authorization.k8s.io/v1           true         Role
priorityclasses                   pc           scheduling.k8s.io/v1                   false        PriorityClass
csidrivers                                     storage.k8s.io/v1                      false        CSIDriver
csinodes                                       storage.k8s.io/v1                      false        CSINode
csistoragecapacities                           storage.k8s.io/v1beta1                 true         CSIStorageCapacity
storageclasses                    sc           storage.k8s.io/v1                      false        StorageClass
volumeattachments                              storage.k8s.io/v1                      false        VolumeAttachment
ingressroutes                                  traefik.containo.us/v1alpha1           true         IngressRoute
ingressroutetcps                               traefik.containo.us/v1alpha1           true         IngressRouteTCP
ingressrouteudps                               traefik.containo.us/v1alpha1           true         IngressRouteUDP
middlewares                                    traefik.containo.us/v1alpha1           true         Middleware
middlewaretcps                                 traefik.containo.us/v1alpha1           true         MiddlewareTCP
serverstransports                              traefik.containo.us/v1alpha1           true         ServersTransport
tlsoptions                                     traefik.containo.us/v1alpha1           true         TLSOption
tlsstores                                      traefik.containo.us/v1alpha1           true         TLSStore
traefikservices                                traefik.containo.us/v1alpha1           true         TraefikService

Conclusion

Up to this point, we have reached the end of our guide on how to run Kubernetes on macOS using Rancher Desktop. This article focuses on giving you insights on Kubernetes, Containers and Containerization. It also gives you a brief description about Rancher Desktop and what it does when it comes to Kubernetes and Containers as well as an illustration on how Rancher works. We have also looked at how to install Rancher Desktop on macOS as well how to install and use Kubectl. Try this method on your end and share your feedback with us regarding the installation and usage. The following articles are also of macOS and Linux;

LEAVE A REPLY

Please enter your comment!
Please enter your name here