Minikube installation | Kubernetes Tutorial
Tags: kubernetes, minikube
Published: 2022-06-05 00:45:35



<!-- wp:paragraph -->
<p><strong>If you're either working on Kubernetes as part of your job or learning Kubernetes</strong>, you will need access to a development / test Kubernetes cluster. Where you can just play without worrying about messing it up.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I have been aware of <strong>Minikube</strong> for a while because I regularly see it being mentioned in Kubernetes documentation. By the way, if you don't know, you can use <strong>Minikube</strong> to <strong>quickly stand up your own local single-node Kubernetes cluster on your laptop</strong> or desktop.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I decided to try it out as well and document my experience for both myself and you, the reader. So here we go.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Note: Your commands' outputs might look different.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Minikube Installation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I followed the instructions from this doc: <a href="https://minikube.sigs.k8s.io/docs/start/"><strong>minikube start | minikube (k8s.io)</strong></a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>One of the <strong>main requirements</strong> for installing Minikube is a <strong>Hypervisor or virtual machine manager</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I tried using <strong>Docker</strong> first, but the installation kept failing. I'll attach a screenshot of the error at the end of the article.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Install Hyperkit</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Then <strong>I decided to use Hyperkit, which I installed using the below brew command.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>~ % <strong>brew install hyperkit</strong>
==> Downloading https://ghcr.io/v2/homebrew/core/hyperkit/manifests/0.20200908
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/db4baa34ee2a779e1db4861dd34db8b2fc91786b2b7d32775b5e5de7f47af42a--hyperkit-0.20200908.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/hyperkit/blobs/sha256:26a203b17733ff5166d8c31069e3ecd5af15c74448a51d8b682689cb07e911e8
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/0ba7a770088a60dd6275860b0407ad95191aa6ddde0207b446e17a144b0e7a33--hyperkit--0.20200908.catalina.bottle.tar.gz
==> Pouring hyperkit--0.20200908.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/hyperkit/0.20200908: 5 files, 4.3MB
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/bharathram.manoharan/Library/Caches/Homebrew/yq--4.25.1... (3.0MB)
Removing: /Users/bharathram.manoharan/Library/Logs/Homebrew/oniguruma... (64B)
Removing: /Users/bharathram.manoharan/Library/Logs/Homebrew/jq... (64B)</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Install kubectl locally</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I prefer installing <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/">kubectl</a> on my local machine, even though minikube itself contains kubectl as well, just so I can work with not just this minikube cluster but the other Kubernetes clusters (EKS, My AWS Lab environment etc.)</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code><strong>brew install kubectl</strong></code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Install Minikube</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>~ % <strong>brew install minikube</strong>
==> Downloading https://ghcr.io/v2/homebrew/core/minikube/manifests/1.25.2
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/fa0034afe1330adad087a8b3dc9ac4917982d248b08a4df4cbc52ce01d5eabff--minikube-1.25.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/minikube/blobs/sha256:888a850d809aa5c62c3e3ccb40b059faf52a4519881f08bf93ec1267558b622e
Already downloaded: /Users/bharathram.manoharan/Library/Caches/Homebrew/downloads/bd6123a468a67f63dd664bec951b99b78c45f2eabe18150eeaafb7ddd3ff4827--minikube--1.25.2.monterey.bottle.tar.gz
==> Pouring minikube--1.25.2.monterey.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/minikube/1.25.2: 9 files, 72.3MB
==> Running `brew cleanup minikube`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3><strong>(Optional)</strong> Set a memory limit for minikube (set a limit according to your system's capacity)</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>~ % <strong>minikube config set memory 8g</strong>
❗  These changes will take effect upon a minikube delete and then a minikube start</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Start minikube with Hyperkit as driver</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>~ % <strong>minikube start --driver=hyperkit</strong>
😄  minikube v1.25.2 on Darwin 12.4
✨  Using the hyperkit driver based on user configuration
👍  Starting control plane node minikube in cluster minikube
🔥  Creating hyperkit VM (CPUs=2, Memory=8192MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
    ▪ kubelet.housekeeping-interval=5m
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  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" cluster and "default" namespace by default</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Verify the minikube installation</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code> ~ % <strong>kubectl config get-contexts minikube</strong>
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
*         minikube   minikube   minikube   default

~ % <strong>kubectl get nodes</strong>
NAME       STATUS   ROLES                  AGE   VERSION
minikube   Ready    control-plane,master   11m   v1.23.3</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":3} -->
<h3>Stop minikube when not needed</h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>~ % <strong>minikube stop</strong>
✋  Stopping node "minikube"  ...
🛑  1 node stopped.</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p><strong>Appendix</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>When I used Docker as the driver of my minikube while starting my cluster, I got the below error.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>~ % <strong>minikube start --driver=docker</strong>
😄  minikube v1.25.2 on Darwin 12.4
✨  Using the docker driver based on user configuration
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🔥  Creating docker container (CPUs=2, Memory=8192MB) ...
❗  This container is having trouble accessing https://k8s.gcr.io
💡  To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...- <strong>E0604 17:30:28.313962   78446 start.go:126] Unable to get host IP: resolve dns to ip: docker exec -t minikube dig +short host.docker.internal: exit status 9
stdout:
;; connection timed out; no servers could be reached
</strong>

stderr:

    ▪ kubelet.housekeeping-interval=5m
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  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" cluster and "default" namespace by default</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p><strong>Resources:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="https://minikube.sigs.k8s.io/docs/start/">minikube start | minikube (k8s.io)</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/">Install and Set Up kubectl on macOS | Kubernetes</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="https://minikube.sigs.k8s.io/docs/drivers/hyperkit/">hyperkit | minikube (k8s.io)</a></p>
<!-- /wp:paragraph -->