LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Router Assisted Service Discovery

Service discovery with light-router for client that is not running in a JVM.

Light-router is a service that provides consumers with another option to do service discovery if they cannot leverage client module provided by light-4j.

There are two ways to deploy light-router, and it is highly recommended for the client to own the instance of light-router.

For demo purposes, the light-router will be deployed in Kubernetes cluster master node as it has a static IP address. By following the steps below, you should have a router instance up and running and connect to multiple instances of API A in the Kubernetes cluster. Communication between API A, B, C, and D is handled with the client module inside each API.

Environment

The light-router will be deployed to the sandbox which is our development Kubernetes cluster master node.

Config

All configurations can be found at https://github.com/networknt/light-config-test/tree/master/light-router/cloud/config

Start

To start the server there is a docker-compose file in https://github.com/networknt/light-config-test/tree/master/light-router/cloud

The content of the docker-compose file:

version: '2'

services:

  light-router:
    image:  networknt/light-router:latest
    networks:
    - localnet
    ports:
    - 8080:8080
    volumes:
    - ./config:/config

#
# Networks
#
networks:
    localnet:
        # driver: bridge
        external: true

You must start the docker-compose at light-config-test/tree/master/light-router/cloud folder.

docker-compose up -d

Test

Before we start using the light-router, let’s make sure that we can access the reference APIs.

Go to the consul server http://38.113.162.50:8500/ to find an instance of API A. Here is an example.

curl -k https://38.113.162.51:2406/v1/data

And the following result should be expected.

["API D: Message 1 from port 7444","API D: Message 2 from port 7444","API B: Message 1","API B: Message 2","API C: Message 1","API C: Message 2","API A: Message 1","API A: Message 2"]

Now let’s access the router instance with the following command line.

curl -k -H "service_id: com.networknt.apia-1.0.0" https://38.113.162.50:8080/v1/data

And the result is:

["API D: Message 1 from port 7444","API D: Message 2 from port 7444","API B: Message 1","API B: Message 2","API C: Message 1","API C: Message 2","API A: Message 1","API A: Message 2"]

Summary

Light-router is an infrastructure service that can assist internal clients, and is not built on top of Java 8 for service discovery and security. It also can act as an external access point for external client to access internal service. In this case, it is playing a role of distributed API gateway.

All previous steps with Consul discovery are based on a dockerized consul instance with http connections. In production, we need to have a consul cluster and https needs to be enabled. In the next step, we are going to explore the Consul cluster with TLS connection.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Router Assisted Service Discovery” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute