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) :
1 2 3 4 5 6 7 8 9 10 11 | # 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 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 :
---
1 2 | sudo add-apt-repository ppa:maarten-fonville/protobuf sudo apt-get update |
Next, run Minikube :
1 2 | minikube start [--vm-driver=<driver>] kubectl cluster-info |
We can set docker to reuse Docker daemon running inside the Minikube virtual machine which will speed up the development.
1 | 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 :
1 2 | https://github.com/tinrab/kubernetes-go-grpc-tutorial https://github.com/piomin/sample-spring-microservices/tree/kubernetes |
This ends this guide as our motive was to demonstrate the practical easy way for multiple languages.
Tagged With monikube rails local microservoces , how to deploy docker microservice in kubernets using minikube , how to run kubernetes on docker , kubermnetes externalip localhost , minikube kubernetes docker-compose architecture , what is the localhost login credentials for minikube , why does DevSpaces run my kubernetes app on localhost?