Simulating a data center with Kubernetes using virtual machines in your computer

These days I was doing an experiment. I was trying to simulate a phyiscal private cloud environment inside a local computer using virtual machines. Because I needed to setup Kubernetes locally. This experiment has no side effects unlike my previous one 😂 since we are going to use virtual machines only 😎.


Kubernetes internal architecture is bit complex. Basically it’s a container orchestration system. In earlier time applications were monolithic (Entire app is running on a single server or virtual machine). But nowadays micro-services came over the classical monolithic approach due to critical drawbacks of monolithic systems.

  • Modifications and Improvements is hard in large monolithic applications
  • No proper load balancing and requests are handled in generic threads in main server

Micro-services are usually deployed in to containers. Supports if there are 100 micro-services in your application. It’s hard to scale and manage. Container orchestration systems (Kubernetes) solves this problem by managing containers automatically by providing another abstraction level on top of containers.

Kubernetes architecture

Let’s setup VMs

For the virtual machine creation I am going to use Oracle Virtualbox.

Creating Kubernetes master

Kubernetes master is controlling the nodes (can be VMs or physical machines). Let’s go ahead and create 2 machines with Ubuntu server edition iso (No GUI)

Master and Node VMs in Virtualbox

Adding bridged adapter

For each VM you have to change NAT adapter in to bridged adapter since NAT only allows to browse internet and also outside users can’t directly connect with guest machine. See more

Network configuration

Mm.. how to setup Kubernetes then (How to make the cluster)

If you used Amazon EKS or Google Kubernetes Engine they setup all the things within minutes. Setting up Kubernetes from scratch is hard. This is where Rancher came to play the game. It makes the cluster creation process easier using Docker containers.

Configuring Kubernetes master

Install and start docker very first

sudo apt-get install
sudo service docker start

Install rancher server

$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:stable

Find the master’s ip by running commad ifconfig

Go to <your master ip>:8080 on your browser

Wow it’s works right! 🤪 . Now you need to enable the Kubernetes environment in rancher. Go ahead and create new environment as per below.

Default -> Manage Environments -> Add Environment

Adding a Kubernetes Node

Kubernetes master is now fine 💪. Let’s add a node. Specially a node can be a physical computer or a virtual machine. Here we are going to use the second virtual machine which was created earlier. Make sure to do the network configuration for this one as well.

Install and start docker very first

sudo apt-get install
sudo service docker start

Click add host in Kubernetes enviroment. Simply we need to follow the steps as per below. In this case only thing is we need to run the given script in Kubernetes node. It will setup and start all the required services

Running a sample microservice

Create a stack very first. Simply stack is a collection of services or load balancers. I am running nginx server for the demonstration purpose.

Find the node’s ip address using same method used in master. Go to extracted ip address on your browser


This approach can be used if you need to setup Kubernetes development environment locally. Try adding load balancer and try adding another node even. I am trying to add a Windows node. It looks hard because we will not be able to run hyper-v inside a virtual machine because the virtualbox needs hyper-v disabled. Anyway 😋, We’ll meet in next article.

Happy distributed computing!! 😅



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store