LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Start Consul

In the previous step, we have the environment parepared. In this step, we are going to start the consul server for other subsequent services to register and discover services.

All portal services will be registered to the Consul cluster on the official test/prod environment. To make sure that the local dev environment works the same. We are going to start the consul server locally with a docker-compose in the light-docker repository.

In the previous step, we have updated the /etc/hosts on the desktop to map the local IP address to the lightapi.net. With the latest version of the Docker, it might not correctly use the Docker HOST /etc/hosts to resolve the DNS. To ensure it works on all environments, we are going to update the docker-compose-consul.yml to add the mapping to the consul service.

Line 14 and 15 below should be updated with your local IP address.

https://github.com/networknt/light-docker/blob/master/docker-compose-consul.yml#L14

The above link is pointing to GitHub.com, but you need to update the local file that you have checked out in ~/networknt/light-docker folder. Once the update is done locally, run the following command to start the docker-compose.

cd ~/networknt/light-docker
docker-compose -f docker-compose-consul.yml up -d

The above docker-compose starts a container with only one consul node with localnet as the network name. All other services should be using the host network to register to the consul instance.

In the config, we have set the "acl_master_token":"the_one_ring" so we need to setup consul-token to the_one_ring in the secret.yml for all services. If you are using the light-4j 2.0.x and above, you don’t need the separate secret.yml file for the consulToken, but just put it into the consul.yml instead. All config files support encryption since version 2.0.0

After the docker-compose is up, we can go to the UI to check the services on the browser.

Put the following URL into the address bar of your browser, and you can see there is one service named consul that is health from the Services tab.

http://localhost:8500

As we have added lightapi.net into the /etc/hosts, you can also use the following URL to access the consul UI.

http://lightapi.net:8500

If you want to learn more about the docker-compose-consul.yml, please visit the source code in the local folder or on GitHub at https://github.com/networknt/light-docker/blob/master/docker-compose-consul.yml

In the next step, we are going to start the light-oauth2 services and let them register to the consul instance just started.

  • 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
“Start Consul” was last updated: February 6, 2020: update open banking client and portal local-router tutorials (29ae751)
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