In previous guides and article, we discussed what is microservices and how to install Kubernetes on localhost. Details of Docker was discussed as series of guides. This is slightly difficult article for the beginners. Here is step by step guide on how to run microservices on localhost with Kubernetes, Minikube, Docker for Java with MongoDB or Go language. There is minimum theory needed to know :
- Pod is an unit in Kubernetes which can consists of one or more containers guaranteed to be co-located on the host machine and share the same resources.
- Service is a set of pods which work together. Service can be exposed to an external IP address.
- Replication Controller handles replication and scaling by running a specified number of copies of a pod.
How To Run Microservices on localhost Kubernetes, Minikube, Docker
By now, we can install Minikube, kubectl, Docker from our previous guides. We need Protocol Buffers compiler as another part which is the main matter of this guide (rest resources are available as ready to use sources) :
# Make sure to use the latest version
curl -OL https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_32.zip
unzip protoc-3.2.0-linux-x86_64.zip -d protoc3
# Move protoc
sudo mv protoc3/bin/* /usr/local/bin/
# Move protoc3
sudo mv protoc3/include/* /usr/local/include/
# change owner
sudo chwon [user] /usr/local/bin/protoc
sudo chwon -R [user] /usr/local/include/google
For Ubuntu, you can use this repo instead :
sudo add-apt-repository ppa:maarten-fonville/protobuf
sudo apt-get update
Next, run Minikube :
minikube start [--vm-driver=<driver>]
We can set docker to reuse Docker daemon running inside the Minikube virtual machine which will speed up the development.
eval $(minikube docker-env)
There are actually great ready to use projects on GitHub with all configuration files which will end this tutorial as practical way to self learn and avoid flooding with too much instructions :
This ends this guide as our motive was to demonstrate the practical easy way for multiple languages.
Follow the Author of this article :