What is Kubernetes?
Kubernetes, often referred to as K8s, is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).
Kubernetes provides a scalable and flexible environment for running applications composed of multiple containers. It enables you to abstract away the underlying infrastructure and treat it as a single, unified cluster. With Kubernetes, you can define how your application should run and let the platform handle the scheduling, scaling, and fault tolerance aspects.
Some key concepts in Kubernetes include:
Pods: The basic building blocks of Kubernetes. A pod is a logical group of one or more containers that are deployed together on a single host. Containers within a pod share the same network namespace and can communicate with each other via localhost.
ReplicaSets: Used for scaling and ensuring a desired number of pod replicas are running at all times. ReplicaSets monitor the health of pods and can create or destroy pods as needed to maintain the desired state.
Services: Provides a stable network endpoint for accessing a group of pods. Services allow you to decouple the frontend of your application from the backend, enabling easy scaling and load balancing.
Deployments: A higher-level abstraction that manages ReplicaSets and provides declarative updates to your application. Deployments allow you to easily roll out changes to your application by creating new ReplicaSets with the updated version and gradually shifting traffic to them.
Namespaces: Used for organizing and isolating resources within a cluster. Namespaces provide a way to partition the cluster resources and create logical boundaries for different projects, teams, or environments.
Kubernetes also supports various advanced features such as horizontal scaling, rolling updates, service discovery, load balancing, automatic bin packing, and self-healing capabilities. It has a vast ecosystem of tools and extensions that enhance its functionality and make it easier to manage complex containerized applications.
Overall, Kubernetes is widely adopted and considered the de facto standard for container orchestration in cloud-native environments. It helps organizations deploy applications more efficiently, scale effortlessly, and achieve high availability and resilience.
What is Minikube?
Minikube is a tool that enables you to run a single-node Kubernetes cluster locally on your machine. It is designed for development and testing purposes, allowing you to experiment with Kubernetes features without the need for a full-scale cluster.
Minikube provides a lightweight Kubernetes environment that runs inside a virtual machine (VM) on your local system. It sets up a single-node cluster with a master node and a worker node, allowing you to deploy and manage applications using Kubernetes APIs.
Here are some key features and use cases of Minikube:
Local Kubernetes Testing: Minikube enables you to test your Kubernetes manifests, deployments, and services locally before deploying them to a production cluster. It helps ensure that your applications work as expected in a Kubernetes environment.
Learning Kubernetes: If you are new to Kubernetes, Minikube provides an easy way to learn and experiment with Kubernetes concepts and commands. You can explore different features, deploy sample applications, and understand how they work within a Kubernetes cluster.
Development Environment: Minikube allows developers to create a local Kubernetes cluster that closely resembles a production environment. This helps in developing and debugging applications that will eventually be deployed on a larger cluster.
CI/CD Pipelines: Minikube can be used in Continuous Integration/Continuous Deployment (CI/CD) pipelines to test Kubernetes configurations and application deployments. It enables developers to catch issues early in the development process before deploying to a production cluster.
Minikube supports different hypervisors, such as VirtualBox, HyperKit, KVM, and Docker, depending on your operating system. It provides a command-line interface (CLI) that allows you to start, stop, and interact with your local Kubernetes cluster.
While Minikube is suitable for local development and testing, it is not meant for running production workloads at scale. For production deployments, you would typically use a full-scale Kubernetes cluster on a cloud provider or on-premises infrastructure.
Overall, Minikube is a useful tool for developers and Kubernetes beginners to get started quickly and experiment with Kubernetes locally, without the need for a complex setup.
Installing Kubernetes
In order to install Kubernetes you need the following:
2 CPUs or more.
2 GB of free memory
20 GB of free disk space
Virtual machine managers like Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation
Installation
To install the latest minikube stable release on x86-64 Windows using .exe download:
Download and run the installer for the latest release.
Or if usingPowerShell
, use this command:New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing
Add the
minikube.exe
binary to yourPATH
.
Make sure to run PowerShell as Administrator.$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine) if ($oldPath.Split(';') -inotcontains 'C:\minikube'){ [Environment]::SetEnvironmentVariable('Path', $('{0};C:\minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine) }
Start Your Cluster
From a terminal with administrator access (but not logged in as root), run:
minikube start
If minikube fails to start, see the drivers page for help setting up a compatible container or virtual-machine manager.
Interact with your Cluster
If you already have kubectl installed, you can now use it to access your shiny new cluster:
kubectl get po -A
Alternatively, minikube can download the appropriate version of kubectl and you should be able to use it like this
minikube kubectl -- get po -A
Deploy Applications
SERVICE
Create a sample deployment and expose it on port 8080:
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0 kubectl expose deployment hello-minikube --type=NodePort --port=8080 kubectl get services hello-minikube minikube service hello-minikube
Your application is now available at http://localhost:8080/.
LOAD BALANCER
To access a LoadBalancer deployment, use the “minikube tunnel” command. Here is an example deployment:
kubectl create deployment balanced --image=kicbase/echo-server:1.0 kubectl expose deployment balanced --type=LoadBalancer --port=8080 minikube tunnel kubectl get services balanced
INGRESS
Enable ingress addon:
minikube addons enable ingress
The following example creates simple echo-server services and an Ingress object to route to these services.
kind: Pod apiVersion: v1 metadata: name: foo-app labels: app: foo spec: containers: - name: foo-app image: 'kicbase/echo-server:1.0' --- kind: Service apiVersion: v1 metadata: name: foo-service spec: selector: app: foo ports: - port: 8080 --- kind: Pod apiVersion: v1 metadata: name: bar-app labels: app: bar spec: containers: - name: bar-app image: 'kicbase/echo-server:1.0' --- kind: Service apiVersion: v1 metadata: name: bar-service spec: selector: app: bar ports: - port: 8080 --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress spec: rules: - http: paths: - pathType: Prefix path: /foo backend: service: name: foo-service port: number: 8080 - pathType: Prefix path: /bar backend: service: name: bar-service port: number: 8080 ---
Apply the contents
kubectl apply -f https://storage.googleapis.com/minikube-site-examples/ingress-example.yaml
Wait for ingress address
kubectl get ingress NAME CLASS HOSTS ADDRESS PORTS AGE example-ingress nginx * <your_ip_here> 80 5m45s
Manage your cluster
Pause Kubernetes without impacting deployed applications:
minikube pause
Unpause a paused instance:
minikube unpause
Halt the cluster:
minikube stop
Change the default memory limit (requires a restart):
minikube config set memory 9001
Browse the catalog of easily installed Kubernetes services:
minikube addons list
Create a second cluster running an older Kubernetes release:
minikube start -p aged --kubernetes-version=v1.16.1
Delete all of the minikube clusters:
minikube delete --all
This was all for this blog. Hope your are now able to run minikube on Windows OS. For any doubts feel free to reach out to me via LinkedIn.
Happy Learning!!!
Cheers!!