Giter VIP home page Giter VIP logo

microservices's Introduction

Kubernetes Microservices Demo

Three simple apps in this repo:

books

To keep things simple, we don't really have a database of books. For whatever request that is made to the /api/v1/book/:id endpoint, we always return a same book.

auth

It will check the authorization token. If it matches SUPERSECUREAUTTHTOKEN, then it returns {ok: true}; otherwise, it returns {ok: false}.

gateway

/api/v1/book/:bookId validates the authentication the request by forwarding a request to auth. If it is authenticated, it will then make a request to books asking for details for the book given the bookId .

Implementations

The applications above are implemented in 3 different tech stacks. Each in separate folders:

  • scala + finch
  • typescript + express
  • python + flask

Running Services

We are using books (typescript) as an example here. But the principle is the same for ther other two apps: auth and gateway, as well as the scala and python implementations. Further details in the blog post.

Running services locally

Make sure you have typescript installed.

$ npm install -g typescript
$ tsc --version

Version 3.4.5

Build and run books_svc.

cd books_svc
npm install
npm run build
npm run serve

curl http://localhost:8080/api/v1/book/1

Running services inside a minikube cluster

Build docker images for the docker daemon inside minikube. And then create kubenete deployment and service.

eval $(minikube docker-env)
docker build ./books_svc -t books

kubectl apply -f books_svc/books-deployment.yaml
kubectl apply -f books_svc/books-service.yaml

curl $(minikube service books-service --url)/api/v1/book/1

Running services in a hybrid mode

When we have an entire system with multiple services running inside a minikube cluster and we want to develop or investigate one of them, it would be easier to launch that service locally while leaving the rest of the services running inside the cluster. It is a faster change/build/validate development cycle and we can also utilize any IDE or debugger if needed.

That's what books-service-local.yaml is for: routing requests to books from the cluster to the your local machine. In more details, it does two things:

  • Create a Headless Service without selectors. See kubernetes doc about services-networking.
  • Create an Endpoint object that point to localhost 10.0.2.2, which is the host machine instead of the VM.

The IP to reach the host machine 10.0.2.2 maybe driver dependend. Use ifconfig to find out the host IP, which should be under vboxnet0.

Some other known alternatives:

microservices's People

Contributors

dependabot[bot] avatar yzhong52 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.