This repository contains microservices samples built using spring boot and spring cloud application development frameworks
This repository contains microservices samples built using spring boot and spring cloud application development frameworks.
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 |
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-service : http://localhost:8080/
git clone https://github.com/BarathArivazhagan/springboot-microservices-workshop.git
cd springboot-microservices-workshop
./build.sh
On windows, perform maven build
cd springboot-microservices-workshop
mvn clean package
Start the applications
cd springboot-microservices-workshop
cd eureka-server
./mvnw spring-boot:run
cd eureka-client-app1
./mvnw spring-boot:run
cd eureka-client-app2
./mvnw spring-boot:run
cd zuul-proxy
./mvnw spring-boot:run
cd config-server
./mvnw spring-boot:run
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
$ docker-compose build
Push the images to the repository
$ docker-compose push
$ docker-compose up -d
To deploy the applications as docker containers inside kubernetes cluster
$ git clone https://github.com/BarathArivazhagan/springboot-microservices-workshop.git && cd k8s
$ kubectl create -f k8s.yaml
configmap/spring-config-map created
configmap/eureka-server-config-map created
configmap/config-server-config-map created
configmap/zuul-proxy-config-map created
deployment.apps/eureka-server created
deployment.apps/eureka-client-app1 created
deployment.apps/eureka-client-app2 created
deployment.apps/zuul-proxy created
deployment.apps/config-server created
service/eureka-server created
service/eureka-client-app1 created
service/eureka-client-app2 created
service/zuul-proxy created
service/config-server created
Test the microservices in local :
# eureka client app1 url
$ curl http://localhost:8081/
HELLO FROM EUREKA CLIENT 1
# eureka client app2 url
$ curl http://localhost:8082/
HELLO FROM EUREKA CLIENT 2
# zuul proxy url for eureka client app1
$ curl http://localhost:8085/app1/
HELLO FROM EUREKA CLIENT 1
## zuul proxy url for eureka client app2
$ curl http://localhost:8085/app2/
HELLO FROM EUREKA CLIENT 2
Test the microservices in K8s clsuter :
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
config-server-798f96964f-8h2p7 1/1 Running 0 6m
eureka-client-app1-5f775d994d-mhqmt 1/1 Running 0 6m
eureka-client-app2-68c775f67b-9vvmq 1/1 Running 0 6m
eureka-server-6bb9ccd47f-l2m47 1/1 Running 0 6m
zuul-proxy-7c8f4597fd-lbrfd 1/1 Running 0 6m
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
config-server ClusterIP 10.101.203.112 <none> 8888/TCP 7m
eureka-client-app1 ClusterIP 10.104.65.88 <none> 8081/TCP 7m
eureka-client-app2 ClusterIP 10.105.214.129 <none> 8082/TCP 7m
eureka-server ClusterIP 10.109.231.205 <none> 8080/TCP 7m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
zuul-proxy ClusterIP 10.100.161.43 <none> 8085/TCP 7m
$ kubectl run debug -it --rm --restart=Never --image=barathece91/debug
root@debug1:/# curl http://eureka-client-app1:8081
HELLO FROM EUREKA CLIENT 1
root@debug1:/# curl http://eureka-client-app2:8082
HELLO FROM EUREKA CLIENT 2
root@debug1:/# curl http://zuul-proxy:8085/app1/
<b>HELLO FROM EUREKA CLIENT 2</b>
root@debug1:/# curl http://zuul-proxy:8085/app2/
<b>HELLO FROM EUREKA CLIENT 2</b>