Essential Guide to Getting Started with Kubernetes

By: Jhon Granados

Technology


blog/ Essential Guide to Getting Started with Kubernetes
01 October 2022


Why Kubernetes?


In a world increasingly driven by microservices and automation, Kubernetes has become a fundamental technology for deploying, scaling, and managing containerized applications.

Today, applications we use daily like Netflix or Spotify handle millions of users without crashes or interruptions. The secret? Kubernetes.


What is Kubernetes?


Kubernetes is a container orchestrator. Its job is to ensure that applications run reliably, scalably, and without interruptions—whether on your laptop, a server, or in the cloud.

Imagine your application is an orchestra:

  • Each container is a musician.
  • Kubernetes is the conductor.
  • If a musician fails, the conductor replaces them so the music doesn’t stop.

kub1


What is a container?


A container is like a magic box that contains everything needed to run an application: code, dependencies, libraries, etc. Kubernetes distributes these containers across available servers, ensuring everything works properly.


Fundamental Kubernetes Concepts


Before starting with Kubernetes, it’s important to understand some of its key components:

  • Cluster: A group of machines running Kubernetes.
  • Node: An individual machine within the cluster.
  • Pod: The smallest unit that contains containers.
  • Deployment: Defines how an app is deployed.
  • ReplicaSet: Ensures a fixed number of Pods.
  • Service: Access point to Pods from inside or outside the cluster.

kub2

As shown in image 2, Deployments define how Pods should be created and updated. ReplicaSets ensure a specific number of Pod replicas are running.


What Do You Need to Get Started?


Prerequisites:

  • Knowledge of containers (preferably Docker).
  • Familiarity with terminal and YAML.
  • Tools installed locally.

Essential tools:

  • kubectl: Command-line tool to interact with a Kubernetes cluster.
  • Minikube or Kind: Allow you to create a local Kubernetes cluster for development and testing.
  • Docker or a virtual machine: Needed to build and run containers that Kubernetes will manage. (Docker is the most common option, but a VM can be useful in certain environments).


Installing kubectl on Windows


Requirements:

  • Windows 10 or higher
  • PowerShell or Command Prompt (CMD)
  • Internet access


Download the kubectl Executable with Chocolatey

  • Open PowerShell or CMD as administrator.
  • Run the following command to download the latest version of kubectl:

choco install kubernetes-cli

Test to ensure the installed version is up to date:

kubectl version --client


Installing Minikube on Windows


Prerequisites

Before installing Minikube, make sure you have:

  • Windows 10/11 (64-bit)
  • One of these virtualization tools (VM):

    • Hyper-V
    • VirtualBox

You’ll also need:

  • kubectl
  • Chocolatey (optional but recommended for quick installation)


Install Minikube with Chocolatey


If you have Chocolatey installed, simply open PowerShell as administrator and run:

choco install minikube

This will install Minikube and add it to your PATH automatically.

  • Verify installation

Open PowerShell or CMD and run:

minikube version

You should see the installed version of Minikube.


Why Use a Virtual Machine with Minikube?


Kubernetes needs several components to function as if they were on real servers (nodes). Since you can’t easily simulate multiple physical servers on a PC, we use a virtual machine (VM) to emulate a clean, isolated environment.


Will the kubectl Practical Example Work with Minikube Without a Virtual Machine?

Yes, it works. But you need to use a driver, and that driver can be a virtual machine (like VirtualBox or Hyper-V) or Docker.

If you have Docker Desktop installed on Windows, you can run Minikube without a traditional VM by using:

minikube start --driver=docker

Docker creates a container (instead of a VM) that runs Kubernetes. It works the same but is lighter and faster.

If you do NOT have Docker or a VM available, then Minikube won’t be able to start the cluster. It needs an environment to run Kubernetes (either a VM or container).


Do You Need to Manually Install an OS Image in VirtualBox?


No. You don’t need to manually install any OS image.

Minikube automatically creates the virtual machine, installs the base OS (usually Linux), and configures Kubernetes inside it.


What Does Minikube Do When You Use VirtualBox?


When you run:

minikube start --driver=virtualbox

Minikube does all this for you:

  • Creates a new VM in VirtualBox.
  • Downloads a Linux image optimized for Kubernetes.
  • Installs and configures all Kubernetes components inside that VM.
  • Starts a functional cluster.
  • Lets you use kubectl to interact with that cluster.


Practical Example: Using kubectl with Minikube and Docker Desktop


Before starting, make sure you have installed:

  • kubectl
  • Docker Desktop (for Windows, it should have WSL 2 or Hyper-V enabled)
  • Minikube


Verify Docker is Running:


kub3

  • Start Minikube using Docker as the driver

minikube start --driver=Docker

kub4

  • Check the cluster status:

minikube status

kub5

  • Use kubectl to interact with Kubernetes

Use the command kubectl get nodes to list the nodes. You should see something like this:

kub6

  • Deploy a Simple Application

kubectl create deployment my-first-minikube --image=kicbase/echo-server:1.0

kub7

This command tells Kubernetes to create a Deployment named my-first-minikube, and that Deployment should run an application based on the container image kicbase/echo-server:1.0.


Note: What is kicbase/echo-server:1.0?


It’s a lightweight server image that simply returns whatever you send it, like HTTP headers or the client IP. It’s useful for testing because you don’t need a real app to verify that Kubernetes is serving something.

  • Once the Deployment is created, you can verify it with:

kubectl get deployments

kub8

  • Expose the Application as a Service (Make It Accessible):

kubectl expose deployment my-first-minikube --type=NodePort --port=8080

kub9

  • View the service:

kubectl get services

kub10


What Does That Mean?


  • PORT(S): 8080:30348 — the service exposes port 8080 internally and forwards it to port 30348 on the host (your machine).
  • TYPE: NodePort — means you can access the service from outside the cluster using the node’s IP and port 30348.
  • Access the application in the browser:

minikube service my-first-minikube

kub11


What Does the Output Mean?


The internal IP of the cluster (192.168.49.2) with the external port (30348) where your service is exposed.
Then, when using the minikube service command, a tunnel is created to redirect that IP/port to something more accessible from Windows:

kub12

If nothing opened in your browser when using this command, you can copy and paste http://127.0.0.1:54173 manually.

There, you should see your application's response—a JSON with the request details.

kub13

Note: Do not close the terminal

  • While it’s open, you can access the service in the browser.
  • If you close it, the tunnel breaks and 127.0.0.1:54173 will no longer work.
  • When you're done, you can stop the cluster:

minikube stop

• If you want to delete it completely:

minikube delete

  • If you want to view your cluster again from Docker Desktop, you can do it like this:

Click on Terminal. Make sure Minikube is running (1). Once Minikube is up, open a terminal (can be from Docker Desktop, CMD, or PowerShell) (2) and run the following command to start your cluster:

minikube start (3)

kub14

Finally, run the command:

minikube service my-first-minikube


Want to know more?
Schedule a call!
Contact us on WhatsApp !