Giter Site home page Giter Site logo

m-thirumal / eureka-server Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 4.0 570 KB

Production-ready Spring Cloud: High Availability - Eureka Server

Java 91.18% Shell 5.05% Dockerfile 3.76%
eureka-server eureka-discovery-service eureka-service-discovery spring-boot-admin java spring-boot

eureka-server's Introduction

Eureka-server

HA-eureka.png

Dependent project

To Create jar

mvn clean install

mvn clean package -DskipTests=true

Run as jar from terminal

java -jar target/eureka-server-0.0.1-SNAPSHOT.jar

java -jar -Dspring.profiles.active=DEV-PRIMARY target/eureka-server-0.0.1-SNAPSHOT.jar

java -jar -Dspring.profiles.active=DEV-SECONDARY target/eureka-server-0.0.1-SNAPSHOT.jar

java -jar -Dspring.profiles.active=DEV-TERTIARY target/eureka-server-0.0.1-SNAPSHOT.jar

Docker

Create docker layered image using the following command

mvn package
chmod -R 777 target/
mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
chmod -R 777 target/
docker build -t eureka-server .

Run the image (with desired)

docker run --name primary --restart always -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" eureka-server
docker run --name secondary --restart always -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" eureka-server
docker run --name tertiary --restart always -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" eureka-server

# With local log

docker run --name primary --restart always --log-driver local --log-opt max-size=10m -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" eureka-server
docker run --name secondary --restart always --log-driver local --log-opt max-size=10m -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" eureka-server
docker run --name tertiary --restart always --log-driver local --log-opt max-size=10m -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" eureka-server

# Without log
docker run --name primary --restart always --log-driver none -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" eureka-server
docker run --name secondary --restart always --log-driver none -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" eureka-server
docker run --name tertiary --restart always --log-driver none -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" eureka-server

# If we use ${"HOST"} for ip-address
docker run --name primary --restart always -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" -e "HOST=172.19.250.7" eureka-server
docker run --name secondary --restart always -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" -e "HOST=172.19.250.8" eureka-server
docker run --name tertiary --restart always -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" -e "HOST=172.19.250.9" eureka-server

Start EUREKA as JAR at OS boot automatically

Add the below line in crontab -e

@reboot /{path-to-eureka-server-script}/eureka-server.sh {ENV}

Example:

@reboot /home/thirumal/git/eureka-server/eureka-server.sh DEV-PRIMARY

Note: Add cd /path-to-repo to the shell script (1'st line)

Replica

  • Make sure eureka.instance.hostname: is same as eureka.client.serviceUrl.defaultZone. Check how it's configured in PRO environment
  • If you want some of cluster to be independent set eureka.client.fetchRegistry is false. That is, don't want to fetch details from other cluster. Check UDEV environment UDEV-SECONDARY

Swagger UI

http://localhost:8761/swagger-ui/index.html http://localhost:8761/api-docs

Credentials

thirumal:thirumal

Extras - PROMETHEUS(Run the following docker command in the prometheus.ymlfile directory.

[http://localhost:8761/actuator/prometheus](Prometheus actuator endpoint)    

docker run -d -p 9090:9090 -v /Users/thirumal/git/eureka-server/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

Troubleshoot

  1. Client registering with Public IP address instead of private.
    • Solution: Need to hard code the IP address. Example

      eureka: instance: prefer-ip-address : true ip-address : xx.xx.xx.xx

eureka-server's People

Contributors

m-thirumal avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.