This project is a cloud-native implementation of a voting app, using modern technologies like Spring Boot, Spring Cloud and Spring Data.
You can freely set up your own questions and thumbnails, by setting configuration through Spring properties.
The app has been updated to Spring Boot 3.3, and uses Spring Cloud Discovery to find the frontend and backend. The backend is hidden behind apps.internal
route to prevent unwanted access, only the frontend can call this service.
This app is made of 2 microservices: a backend and a Web UI frontend. These microservices leverage a RabbitMQ instance to share messages and a Redis instance to store data.
You need a JDK 17+ to build this both microservices from the parent folder:
$ ./mvwn clean package
Create 3 services:
- A Redis service called
redis
. - A RabbitMQ service called
rabbit
. - A Service Discovery service called
discovery
.
Review the manifest.yml under polls-frontend
. the run:
cf push
Review the manifest.yml under polls-backend
, then run:
cf push
Check your frontend apps's URL in Apps Manager (it will be randomly generated) and open the app.
Check the service discovery dashboard to see both apps registered.
In Apps Manager, replace the public route for polls-backend
with one under the apps.internal
domain. This will prevent outside access to the backend, since apps.internal
is only accessible from other apps that have permission.
At first - the communcation will fail. Create a network policy between polls-frontend
and polls-backend
on port 8080. Things will now work as expected.
Create a config server service:
cf create-service p.config-server standard config -c '{"git": { "uri": "https://github.com/odedia/cloudnativepoll-config.git", "label": "main" } }'
Uncomment:
<!--dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-config-client</artifactId>
</dependency-->
Add the service config
to both manifests.
cf push both apps
mvn clean package && cd polls-backend && cf push && cd ../polls-frontend && cf push
Contributions are always welcome!
Feel free to open issues & send PR.
Copyright © 2021 VMware, Inc. or its affiliates.
This project is licensed under the Apache Software License version 2.0.