项目作者: BarathArivazhagan

项目描述 :
This repository contains microservices samples built using spring boot and spring cloud application development frameworks
高级语言: Java
项目地址: git://github.com/BarathArivazhagan/springboot-microservices-workshop.git


springboot-microservices-workshop

This repository contains microservices samples built using spring boot and spring cloud application development frameworks.

Projects :


































Name Port Description
eureka-server 8080 Eureka service registration server
eureka-client-app1 8081 Eureka service discovery client registered with eureka-server
eureka-client-app2 8082 Eureka service discovery client registered with eureka-server
zuul-proxy 8085 Zuul reverse proxy server acting as reverse proxy pass to other microservices
config-server 8888 Configuration server acting as a hub for centralized configuration

Compatability Matrix

choose the branch based on below maintained versions.






































Branch/Version Spring Boot Spring Cloud
master 2.1.5.RELEASE Greenwich.SR1
1.0.x 1.5.10.RELEASE Dalston.RELEASE
1.1.x 1.5.12.RELEASE Edgware.RELEASE
2.0.x 1.5.12.RELEASE Finchley.RELEASE
2.1.x 2.1.3.RELEASE Greenwich.RELEASE
2.1.4 2.1.4.RELEASE Greenwich.RELEASE

Eureka Server Registration View :

eureka-service : http://localhost:8080/

eureka-server

How to run the project ?

  • Clone the repository
  1. git clone https://github.com/BarathArivazhagan/springboot-microservices-workshop.git
  • Execute below script to build all the applications
  1. cd springboot-microservices-workshop
  2. ./build.sh
  • On windows, perform maven build

    1. cd springboot-microservices-workshop
    2. mvn clean package
  • Start the applications

  1. cd springboot-microservices-workshop
  2. cd eureka-server
  3. ./mvnw spring-boot:run
  4. cd eureka-client-app1
  5. ./mvnw spring-boot:run
  6. cd eureka-client-app2
  7. ./mvnw spring-boot:run
  8. cd zuul-proxy
  9. ./mvnw spring-boot:run
  10. cd config-server
  11. ./mvnw spring-boot:run

Docker support

Take advantage of docker compose to quickly build and run applications as containers.

Note: Dont forget tochange the docker image names as per docker repository

  • Build docker images

    1. $ docker-compose build
  • Push the images to the repository

  1. $ docker-compose push
  • Run the applications
  1. $ docker-compose up -d

Kubernetes Support

To deploy the applications as docker containers inside kubernetes cluster

Katacoda K8s Playground

  1. $ git clone https://github.com/BarathArivazhagan/springboot-microservices-workshop.git && cd k8s
  2. $ kubectl create -f k8s.yaml
  3. configmap/spring-config-map created
  4. configmap/eureka-server-config-map created
  5. configmap/config-server-config-map created
  6. configmap/zuul-proxy-config-map created
  7. deployment.apps/eureka-server created
  8. deployment.apps/eureka-client-app1 created
  9. deployment.apps/eureka-client-app2 created
  10. deployment.apps/zuul-proxy created
  11. deployment.apps/config-server created
  12. service/eureka-server created
  13. service/eureka-client-app1 created
  14. service/eureka-client-app2 created
  15. service/zuul-proxy created
  16. service/config-server created

Test the microservices in local :

  1. # eureka client app1 url
  2. $ curl http://localhost:8081/
  3. HELLO FROM EUREKA CLIENT 1
  4. # eureka client app2 url
  5. $ curl http://localhost:8082/
  6. HELLO FROM EUREKA CLIENT 2
  7. # zuul proxy url for eureka client app1
  8. $ curl http://localhost:8085/app1/
  9. HELLO FROM EUREKA CLIENT 1
  10. ## zuul proxy url for eureka client app2
  11. $ curl http://localhost:8085/app2/
  12. HELLO FROM EUREKA CLIENT 2

Test the microservices in K8s clsuter :

  • verify the pods
  1. $ kubectl get pods
  2. NAME READY STATUS RESTARTS AGE
  3. config-server-798f96964f-8h2p7 1/1 Running 0 6m
  4. eureka-client-app1-5f775d994d-mhqmt 1/1 Running 0 6m
  5. eureka-client-app2-68c775f67b-9vvmq 1/1 Running 0 6m
  6. eureka-server-6bb9ccd47f-l2m47 1/1 Running 0 6m
  7. zuul-proxy-7c8f4597fd-lbrfd 1/1 Running 0 6m
  • verify the services
  1. $ kubectl get services
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. config-server ClusterIP 10.101.203.112 <none> 8888/TCP 7m
  4. eureka-client-app1 ClusterIP 10.104.65.88 <none> 8081/TCP 7m
  5. eureka-client-app2 ClusterIP 10.105.214.129 <none> 8082/TCP 7m
  6. eureka-server ClusterIP 10.109.231.205 <none> 8080/TCP 7m
  7. kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
  8. zuul-proxy ClusterIP 10.100.161.43 <none> 8085/TCP 7m
  • Test the services
  1. $ kubectl run debug -it --rm --restart=Never --image=barathece91/debug
  2. root@debug1:/# curl http://eureka-client-app1:8081
  3. HELLO FROM EUREKA CLIENT 1
  4. root@debug1:/# curl http://eureka-client-app2:8082
  5. HELLO FROM EUREKA CLIENT 2
  6. root@debug1:/# curl http://zuul-proxy:8085/app1/
  7. <b>HELLO FROM EUREKA CLIENT 2</b>
  8. root@debug1:/# curl http://zuul-proxy:8085/app2/
  9. <b>HELLO FROM EUREKA CLIENT 2</b>