Skip to content

Sample repo to illustrate the usage of Spring Cloud Gateway and Consul. Other microservices use micronaut.

License

Notifications You must be signed in to change notification settings

mlim1972/gateway-consul

Repository files navigation

Introduction

This repo is a sample code to show the usage of an API Gateway. The project uses Spring Cloud Gateway as the main API Gateway. In addition, the Gateway integrates with Consul as the Service Discovery. The objective of this project is three folds:

  • Utilize an API Gateway
  • Configure and utilize Consul as the main discovery service
  • Services are referenced by name and not IP/port

Services

There are 3 services created in this sample project:

  • gateway: this is the Spring Cloud Gateway
  • service1: this is the service that is exposed by the gateway. This service is written using micronaut
  • service2: this service is referenced by service1. This service is written using micronaut

Requirements

  • Java 11. The services are set to use java 11
  • Docker. Consul is started using docker

Running

First we need to start Consul by running run-consul.sh. This script uses docker to pull the latest consul image and runs it locally. After consul starts, the UI will be available at: http://localhost:8500

After consul starts, the other services can also start up using the following command:

./run-services.sh

Once all the services are started, the Gateway will forward `/api/billing' to service1. Then, service1 will utilize service2 for some of the information.

To stop the services run the following command:

./stop-services.sh

About

Sample repo to illustrate the usage of Spring Cloud Gateway and Consul. Other microservices use micronaut.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published