Pathway to AKS — Creating a Home Lab
Published: 2023-02-22 18:23:10


## Pathway to AKS — Creating a Home Lab

![](https://cdn-images-1.medium.com/max/3840/1*LmOd9MCUdk-cPVYwTLjJOQ.png)

Hello folks,

Setting up a home lab is often the most suitable way to learn and understand Kubernetes. The lab allows you to learn the technology in a controlled environment, limiting the blast radius should you encounter any shortcomings. This write-up targets people getting started with K8s and wondering how to go about it, especially on their Azure journey. It is courtesy of [Kevin Evans](https://www.linkedin.com/in/kevinevans01/) and [Robin Smorenburg](https://www.linkedin.com/in/smorenburg/) from [StreamingClouds](https://www.youtube.com/watch?v=dtUUphSax9o).

**Getting Started**

There is a [guide](https://www.youtube.com/watch?v=C7I6EseqWyM) in setting up your workstation for Infrastructure as code (IaC) for Azure Development to cover the workstation prerequisites. It includes some baseline tools, such as Windows Subsystems for Linux, and IaC toolings, such as Terraform, Bicep, and Azure CLI. Before you go ahead with this, check out the video** [**here](https://www.youtube.com/watch?v=C7I6EseqWyM). Also included is the [link ](https://github.com/streamingclouds/windows-infra-workstation-setup)to the GitHub repository to walk you through setting up your workstation.

For this setup, we choose to use Docker. Docker supports the Open Container Initiative. We install Docker to run our daemons. We will then use minikube for the Kubernetes platform. Minikube bootstraps a single node Kubernetes Cluster inside Docker. Kubectl is used to interact with our platform, whether hosted on-prem or in the cloud. Helm is a templating engine that creates K8s manifests. It helps you define, install and upgrade your apps in Kubernetes to package your app. We use the extensions in VS Code and interact with our clusters inside VS Code. Finally, we deploy a simple hello world Test application.

**Setup**

Docker

We use the docker extension on VSCode. To install Docker, download Docker Desktop from the link below. Be sure to review the system requirements. Also, ensure that virtualization is enabled o your CPU. Here is a link to [enable virtualization](https://support.hp.com/us-en/document/ish_5637142-5637191-16#:~:text=Turn%20on%20the%20computer%2C%20and,settings%20and%20exit%20BIOS%20Setup.).

[https://docs.docker.com/desktop/install/windows-install/](https://docs.docker.com/desktop/install/windows-install/)

Minikube

The link below is a guide on installing minikube on your machine. The system requirements are listed for the various operating systems.

[https://minikube.sigs.k8s.io/docs/start/](https://minikube.sigs.k8s.io/docs/start/)

After the installation, you need to configure minikube for docker permissions by adding your current user to the docker group. Use the command below:

    sudo usermod -aG docker $USER && newgrp docker

Minikube uses drivers for its K8s. Therefore, we instruct it to use the docker driver. Otherwise, we may run into problems down the road.

    minikube config set driver docker

Start minikube:

    minikube start

Install and setup kubectl using the link below

[https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/)

Install helm from the link below.

[https://helm.sh/docs/intro/install/](https://helm.sh/docs/intro/install/)

Install VS Code from the link below.

[https://code.visualstudio.com/download](https://code.visualstudio.com/download)

Launch VS Code and install the Kubernetes extension. For Windows users, install WSL as well.

Opening the Kubernetes extension lists the clusters that you have.

![](https://cdn-images-1.medium.com/max/3118/1*sgsmLJWgqpCyb30VW5l_Iw.png)

Run the command below to list and enable the metric server add-on on minikube using an image from Docker.

    minikube dashboard

The resulting cluster dashboard is shown:

![](https://cdn-images-1.medium.com/max/3008/1*4yeXdxZb3snfkY7VD3lSBQ.png)

Minikube is preferred over Kubernetes in Docker because it has a lot of add-ons that you can install with a single command. There are a lot of prepackaged pods in the minikube executable that can alter your cluster services and features. For example,

    minikube addons enable ingress

it installs an nginx controller.

**Deploy.**

Download the hello-world app to run locally and deploy it.

    kubectl create deployment web--image=gcr.io/google-samples/hello-app:1.0

View your current deployment.

    kubectl get deployments

We see that the application is ready and available.

![](https://cdn-images-1.medium.com/max/2000/1*D97gxuHpP-NjBiXKqu3bcQ.png)

When it comes to K8s, you’ve got to expose the instance with particular services, e.g., ssh, https, HTTP, etc.

Expose the instance as a service on port 8080

    kubectl expose deployment web --type=NodePort --port=8080

Confirm the service

    kubectl get service web

![](https://cdn-images-1.medium.com/max/2000/1*yrNRDml2H4WaEV5af4DtAw.png)

Get the URL to access the web console. This gives you a local URL to access the service.

    minikube service web --url

![](https://cdn-images-1.medium.com/max/2000/1*MUrlCEAzD_DddP3N7wvC_A.png)

Cloud Installation

You have the option of running this deployment on the cloud. The procedure is to add the Azure cloud extension to VS Code and sign in to Azure. It pulls all your tenants in Azure and can run commands on Azure from VS Code.

Helm

Helm is used to deploy applications inside your cluster. For example, when you want to monitor your application cluster, you can install Prometheus using a Helm chart. The chart will create a deployment, services, daemon sets, and other resources needed to run that application inside your cluster.

The other benefit is that if you are a developer and want to distribute your K8s, you create a helm chart. This way, people can quickly onboard their apple through that cluster without having to write everything themselves.

Thank you for your audience.