An open API service indexing awesome lists of open source software.

https://github.com/baratharivazhagan/springboot-microservices-workshop

This repository contains microservices samples built using spring boot and spring cloud application development frameworks
https://github.com/baratharivazhagan/springboot-microservices-workshop

eureka-server microservice microservices-workshop spring-boot spring-cloud zuul-proxy

Last synced: 6 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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](images/eureka-server.png)

### How to run the project ?

* Clone the repository

```sh
git clone https://github.com/BarathArivazhagan/springboot-microservices-workshop.git
```

* Execute below script to build all the applications

```sh
cd springboot-microservices-workshop
./build.sh
```
* On windows, perform maven build
```
cd springboot-microservices-workshop
mvn clean package
```

* Start the applications

```sh

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

```

### 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
```Shell
$ docker-compose build
```

* Push the images to the repository

```Shell
$ docker-compose push
```

* Run the applications

```Shell
$ docker-compose up -d
```

### Kubernetes Support

To deploy the applications as docker containers inside kubernetes cluster

[Katacoda K8s Playground](https://www.katacoda.com/courses/kubernetes/playground)

```Shell
$ 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 :

```Shell
# 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 :

- verify the pods

```Shell
$ 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
```

- verify the services

```Shell
$ kubectl get services

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
config-server ClusterIP 10.101.203.112 8888/TCP 7m
eureka-client-app1 ClusterIP 10.104.65.88 8081/TCP 7m
eureka-client-app2 ClusterIP 10.105.214.129 8082/TCP 7m
eureka-server ClusterIP 10.109.231.205 8080/TCP 7m
kubernetes ClusterIP 10.96.0.1 443/TCP 1h
zuul-proxy ClusterIP 10.100.161.43 8085/TCP 7m
```

- Test the services

```Shell
$ 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/
HELLO FROM EUREKA CLIENT 2

root@debug1:/# curl http://zuul-proxy:8085/app2/
HELLO FROM EUREKA CLIENT 2
```