Coder Social home page Coder Social logo

shuaicj / spring-cloud-example Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 382 KB

A simple demo of Spring Cloud, and can run directly in docker-compose or kubernetes/minikube.

License: MIT License

Java 93.91% Dockerfile 6.09%
spring-cloud spring-cloud-learning spring-cloud-example docker-compose minikube kubernetes

spring-cloud-example's Introduction

Spring Cloud Example

An example for learning Spring Cloud.

Overview

Modules

  • cloud-config - usage of spring cloud config
  • cloud-gateway - usage of spring cloud netflix zuul
  • cloud-registry - usage of spring cloud netflix eureka
  • cloud-service-a - service-a provides endpoints /hello and /unstable
  • cloud-service-b - service-b provides endpoints /hello and /unstable

Requirements

  • JDK 8
  • Maven 3.3.9+
  • Docker 1.12.0+

Run in docker-compose

Make sure the port 8080 and 8761 is available, and the docker daemon can use 8G+ memory.

$ mvn package
$ docker-compose up

It will take two or three minutes for all services are ready. If everything is ok, each service will be running with 2 instances except cloud-gateway. Check the eureka page http://localhost:8761.

To verify if the services are working, repeat the following commands for several times:

$ curl http://localhost:8080/a/hello?name=shuaicj
$ curl http://localhost:8080/b/hello?name=shuaicj

and focus on the content printed out:

  • Check the IPs of the same service. It means multiple service instances are working.
  • Check if [FALLBACK] appears. It means Netflix Hystrix is working.

Run in minikube

Make sure the port 30000 and 30001 is available, and the minikube can use 8G+ memory.

$ kubectl create -f k8s

It will take two or three minutes for all services are ready. If everything is ok, each service will be running with 2 instances except cloud-gateway. Check the eureka page which is implied by minikube service registry --url.

To verify if the services are working, repeat the following commands for several times:

$ curl $(minikube service gateway --url)/a/hello?name=shuaicj
$ curl $(minikube service gateway --url)/b/hello?name=shuaicj

and focus on the content printed out:

  • Check the IPs of the same service. It means multiple service instances are working.
  • Check if [FALLBACK] appears. It means Netflix Hystrix is working.

See Also

shuaicj/spring-cloud-tutorials

spring-cloud-example's People

Contributors

shuaicj avatar

Stargazers

 avatar  avatar

Watchers

 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.