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

  • 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

Creating Kubernetes master

Master and Node VMs in Virtualbox

Adding bridged adapter

Network configuration

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

Configuring Kubernetes master

sudo apt-get install docker.io
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

Install and start docker very first

sudo apt-get install docker.io
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

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

Conclusion

Happy distributed computing!! 😅

Programmer | Author of Neutralinojs | Technical Writer