Code Monkey home page Code Monkey logo

spring-boot-microservice-eureka-zuul-docker-gateway-kubernetes's Introduction

SPRING BOOT MICROCSERVICE USING SPRING CLOUD, EUREKA, RIBBON, ZUUL, ZIPKIN, SLEUTH

This project is created to get experience on Microservices With Netflix OSS. This is a simple project by coded imperative programming with simple business requirements.

ELK Stack has been integrated for monitoring since version 1.1.0.

There are four microservices:

  • Accounts : This microservice is responsible for managing accounts. An account could be buyer, seller or an backoffice account but there is only buyer account.
  • Products : This microservice is responsible for managing products.
  • Orders : This microservice is responsible for managing orders. It doesn't know anything about account and product except id.
  • Backoffice: This microservice is provides endpoints for backoffice ui.

Backoffice microservice has an endpoint with path "/api/v1/backoffice/orders". This endpoint return a list of orders with name of product and account. It connects accounts, products and orders microservices via Feign.

EndPoints

Service EndPoint Port Method Description
Accounts /api/v1/accounts/{id} 7500 GET Return detail of specified account
Accounts /api/v1/accounts 7500 GET Return details of all acounts
Products /api/v1/products/{id} 7501 GET Return detail of specified product
Products /api/v1/products 7501 GET Return details of all products
Orders /api/v1/orders/{id} 7502 GET Return detail of order
Orders /api/v1/orders 7502 GET Return details of orders
Backoffice /api/v1/backoffice/orders 7503 GET Return orders with product name and account name

Gateways

Service EndPoint
Accounts /account/api/v1/accounts/{id}
Accounts /account/api/v1/accounts
Products /product/api/v1/products/{id}
Products /product/api/v1/products
Orders /order/api/v1/orders/{id}
Orders /order/api/v1/orders
Backoffice /backoffice/api/v1/backoffice/orders

URI for gateway : http://localhost:8762

Used Netflix OSS:

  • Netflix Eureka is used for discovery service.
  • Netflix Ribbon is used for client side load-balancing.
  • Netflix Zuul is used for gateway.

Distributed Tracing:

  • Sleuth and Zipkin

You can open Zipkin : http://localhost:9411 Zipkin Filter Zipkin Full Trace

Used ELK STACK:

  • ElasticSearch is on 6972 port
  • Logstash TCP is on 5000 port
  • Kibana is on 5601 port

Open kibana with http://localhost:5601/. You must define an index pattern (taner-*) on Management/Stack Management.

Kibana

Used Grafana

You can open Grafana : http://localhost:3000/ Predefined dashboard : http://localhost:3000/d/dLsDQIUnzb/spring-boot-observability?orgId=1&refresh=5s

Grafana has loki for log aggregation and tempo for distributed tracing backend.

Build & Run

  • >mvn clean package : to build
  • >docker-compose up --build : build docker images and containers and run containers
  • >docker-compose stop : stop the dockerized services
  • Each maven module has a Dockerfile.

In docker-compose.yml file:

  • Accounts Service : 2222 port is mapped to 7500 port of host
  • Products Service : 2222 port is mapped to 7501 port of host
  • Orders Service : 2222 port is mapped to 7502 port of host
  • Backoffice Service : 2222 port is mapped to 7503 port of host
  • Eureka Discovery Service : 8761 port is mapped to 8761 port of host
  • Spring Boot (/ Zuul) Gateway Service : 8762 port is mapped to 8762 port of host

KUBERNETES

  • kubectl create -f containerized-accounts/k8n/deployment.yml

  • kubectl create -f containerized-accounts/k8n/service.yml

  • kubectl port-forward svc/containerized-accounts 7500:7500

  • curl localhost:7500/account/api/v1/accounts

  • kubectl create -f containerized-products/k8n/deployment.yml

  • kubectl create -f containerized-products/k8n/service.yml

  • kubectl port-forward svc/containerized-products 7501:7501

  • curl http://localhost:7501/product/api/v1/products

  • kubectl create -f containerized-orders/k8n/deployment.yml

  • kubectl create -f containerized-orders/k8n/service.yml

  • kubectl port-forward svc/containerized-orders 7502:7502

  • curl localhost:7502/order/api/v1/orders

  • kubectl create -f containerized-main/k8n/deployment.yml

  • kubectl create -f containerized-main/k8n/service.yml

  • kubectl port-forward svc/containerized-main 7503:7503

  • curl localhost:7503/backoffice/api/v1/backoffice/orders

  • kubectl create -f containerized-discovery/k8n/deployment.yml

  • kubectl create -f containerized-discovery/k8n/service.yml

  • kubectl port-forward svc/discovery 8761:8761

  • kubectl create -f containerized-gateway/k8n/deployment.yml

  • kubectl create -f containerized-gateway/k8n/service.yml

  • kubectl port-forward svc/gateway 8762:8762

  • curl localhost:8762/backoffice/api/v1/backoffice/orders

VERSIONS

2.0.2

  • feign-micrometer dependency and Capability bean added to send trace-id on resttemplate calls

      @Bean
      public Capability capability(final MeterRegistry registry) {
        return new MicrometerCapability(registry);
      }
    
      <dependency>
      	<groupId>io.github.openfeign</groupId>
      	<artifactId>feign-micrometer</artifactId>
      </dependency>
    
  • micrometer-tracing-bridge-brave added to generate trace-id and span-id

      <dependency>
          <groupId>io.micrometer</groupId>
          <artifactId>micrometer-tracing-bridge-brave</artifactId>
      </dependency>
    
  • Integrate Grafana OSS : Grafana, Loki, Tempo

2.0.1

  • Update Spring-Boot version to 3.2.1
  • Start to use micrometer tracing
  • Zipkin will be replaced by Grafana

2.0.0

  • Add kubernetes yaml files (still using Eureka discovery)

1.3.0

  • Update Spring Boot version to 2.5.1
  • Switch to Spring Boot Gateway

1.2.0

  • Sleuth and Zipkin Integration
  • Making some refactorings
  • Lombok Integration

1.1.0

  • ElasticSearch, Kibana, Logstash integration

1.0.0 SNAPSHOT

  • Spring-Boot 2.3.1.RELEASE
  • Java 11
  • Docker Image updated
  • Spring-Cloud artifacts have been changed
  • Open Feign integrated

0.0.1

  • Spring-Boot 2.0.2.RELEASE
  • Java 8

RESOURCES

spring-boot-microservice-eureka-zuul-docker-gateway-kubernetes's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-microservice-eureka-zuul-docker-gateway-kubernetes's Issues

Port binding

In the docker file of the gateway module this is port 8761 is exposed et in the docker-compose.yml file the host is bound to port 8762. should we rather expose the port 8762 and not that of the discovery server 8761?

gateway Dockerfie content

FROM openjdk:11-jdk-slim
MAINTAINER Taner Diler [email protected]
ADD target/containerized-gateway.jar containerized-gateway.jar
ENTRYPOINT ["java", "-jar", "/containerized-gateway.jar"]
EXPOSE 8761 #we

docker-compose.yml

gateway:
image: tanerdiler/service-gateway
container_name: service-gateway
build:
context: ./containerized-gateway
dockerfile: Dockerfile
ports:
- "8762:8762"
links:
- discovery
- logstash
- zipkin

i get error

please, help me!!!
i run docker-compose up --build then get the error.

image

Calling Account Container from another container via Gateway

Can you please tell me i have container which is not inside eureka or zuul proxy but it is build with Docker-compse so same network.

Example :

Service A not eureka client or part of Zuul

Service B(Authorization server) Eureka Client and Zuul routing is defined

Zuul -Proxy defined
authorization:
path: /authserver/**
url: http://authorization:8082

Now from Service A i am calling rest call http://zuul-server:8401/authserver/oauth/token i am getting 404 can you please help me out

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.