DEV Community

PaddyAdallah
PaddyAdallah

Posted on

Pathway to AKS — Creating a Home Lab

Pathway to AKS — Creating a Home Lab

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 and Robin Smorenburg from StreamingClouds.

Getting Started

There is a guide 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. Also included is the link 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://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/

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Start minikube:

minikube start
Enter fullscreen mode Exit fullscreen mode

Install and setup kubectl using the link below

https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

Install helm from the link below.

https://helm.sh/docs/intro/install/

Install VS Code from the link below.

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.

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

minikube dashboard
Enter fullscreen mode Exit fullscreen mode

The resulting cluster dashboard is shown:

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

View your current deployment.

kubectl get deployments
Enter fullscreen mode Exit fullscreen mode

We see that the application is ready and available.

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
Enter fullscreen mode Exit fullscreen mode

Confirm the service

kubectl get service web
Enter fullscreen mode Exit fullscreen mode

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

minikube service web --url
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)