Skip to content

Commit d4314a7

Browse files
committed
Downgrade spring boot to version 2.0.4.RELEASE and adding readme
1 parent 47ed388 commit d4314a7

File tree

9 files changed

+413
-268
lines changed

9 files changed

+413
-268
lines changed

README.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
# Spring Kubernetes Services Showcase
2-
3-
Kubernetes is leading orchestration framework
4-
[Kubernetes Installation](readme/Kubernetes_Installation.md)
5-
[Docker Registry](readme/Kubernetes_Installation.md)
6-
1+
# Spring Kubernetes Micro Services Showcase
2+
3+
[Kubernetes](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/) is leading orchestration framework which enables automated deployments, scaling, and management of containerized applications.
4+
Spring Kubernetes Micro Services is a showcase application which uses the new [Spring Cloud Kubernetes](https://spring.io/projects/spring-cloud-kubernetes) framework to manage service discovery and is deployed on kubernetes network.
5+
The application provides services to fetch the generated report documents using [Spring Batch](https://spring.io/projects/spring-batch) and stored on a [Minio cloud storage](https://min.io/).
6+
The application has below services.
7+
8+
* [Discovery Service](discovery-service/README.md): Eureka discovery service allows micro services to find and communicate with each other.
9+
* [Data Service](data-service/README.md): Data service provides reactive services using Spring WebFlux to store and fetch various report documents data.
10+
* [Storage Service](storage-service/README.md): Analytics services consume data from various sources, mainly finance-service and data-service and provide analytical details regarding the
11+
* [Document Service](document-service/README.md): Analytics services consume data from various sources, mainly finance-service and data-service and provide analytical details regarding the
12+
13+
Follow the below documentation in order to setup this application using Kubernetes.
14+
15+
* [Kubernetes Architecture](http://emprovisetech.blogspot.com/2018/12/kubernetes-container-orchestration-at.html): Blog post discussing Kubernetes concepts, architecture and various commands in depth.
16+
* [Kubernetes Installation](readme/Kubernetes_Installation.md): Setup Kubernetes Master and Worker nodes for [Ubuntu Bionic](http://releases.ubuntu.com/18.04/). Please refer to various documentations online for respective operating systems.
17+
* [Docker Registry](readme/Docker_Registry.md): Docker registry setup is required to distribute docker images to various Kubernetes pods.
18+
* [Kubernetes Commands](readme/Kubernetes_Commands.md): Kubernetes commands provides some frequently used commands to deploy and delete/clean up Kubernetes services and debug or troubleshoot kubernetes pods.

data-service/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Data Service
2+
=============
3+
4+
Data service provides various services to save and fetch data from [MongoDB](https://www.mongodb.com/) database.
5+
[Spring WebFlux](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) framework is used for reactive programming in order to stream the result records from MongoDB.
6+
7+
### Installation and Running of MongoDB
8+
9+
* Download latest [Windows MongoDB release](https://www.mongodb.org/dl/win32/x86_64-2008plus-ssl) and extract the zip file.
10+
* Create directories **data** and **logs** in MONGODB_HOME directory, were MONGODB_HOME is the path to the unzipped mongodb directory.
11+
* Create file **mongo.log** in MONGODB_HOME/logs directory.
12+
* Create **mongod.cfg** file using [MongoDB configuration options](https://docs.mongodb.com/v3.2/reference/configuration-options/) in MONGODB_HOME/bin directory. Alternatively copy **mongod.cfg** file from spring-microservices/data-service/config and add to MONGODB_HOME/bin directory.
13+
* Find & edit the token **@logs@** with path "MONGODB_HOME\logs" and **@data@** with path "MONGODB_HOME\data".
14+
* Go to MONGODB_HOME\bin directory and execute the command "mongod --config mongod.cfg" to run mongodb.
15+
* MongoDB runs on default port 27017.
16+
17+
All the above steps can be executed directly by running below runMongodb gradle task for windows.
18+
19+
$ gradle runMongodb
20+
21+
22+
### Running the Data Service
23+
24+
Optionally **spring.profiles.active** can be passed with value **production** which enables logback to send all logs to Elastic Stack instead of logging in the console by default.
25+
26+
$ java -jar data-service/build/libs/data-service-0.0.1-SNAPSHOT.jar
27+
-Dspring.profiles.active=production
28+
29+
### Notes
30+
31+
* Data service uses [MapStruct](http://mapstruct.org/) for mapping between domain object to DTO object. MapStruct requires [mapstruct-processor](https://github.com/mapstruct/mapstruct) to be configured in gradle to generate the corresponding Mapper implementation for defined MapStruct interface. Hence it is highly recommended to **run gradle build before running data-service** to avoid Spring NoSuchBeanDefinitionException for MapStruct autowirings.

data-service/build.gradle

+132-132
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
1-
buildscript {
2-
ext {
3-
springBootVersion = '2.1.4.RELEASE'
4-
mongodbVersion = '4.0.1'
5-
}
6-
repositories {
7-
mavenCentral()
8-
jcenter()
9-
}
10-
dependencies {
11-
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
12-
classpath("de.undercouch:gradle-download-task:3.4.3")
13-
}
14-
}
15-
16-
plugins {
17-
id "net.ltgt.apt" version "0.19"
18-
}
19-
20-
apply plugin: 'java'
21-
apply plugin: 'org.springframework.boot'
22-
apply plugin: 'io.spring.dependency-management'
23-
apply plugin: 'de.undercouch.download'
24-
25-
group = 'com.emprovise.service'
26-
version = '0.0.1-SNAPSHOT'
27-
sourceCompatibility = 1.8
28-
29-
repositories {
30-
mavenCentral()
31-
maven { url "https://repo.spring.io/milestone" }
32-
}
33-
34-
ext {
35-
springCloudVersion = 'Finchley.RELEASE'
36-
mapstructVersion = "1.2.0.Final"
37-
}
38-
39-
dependencies {
40-
41-
if (isProd) {
42-
compile('org.springframework.cloud:spring-cloud-starter-kubernetes:1.0.1.RELEASE')
43-
compile('org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:1.0.1.RELEASE')
44-
} else {
45-
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
46-
}
47-
48-
compile('org.springframework.boot:spring-boot-starter-actuator')
49-
compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive')
50-
compile('org.springframework.boot:spring-boot-starter-webflux')
51-
compile('org.springframework.boot:spring-boot-starter-batch')
52-
compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}"
53-
compile('org.slf4j:slf4j-api')
54-
runtime('net.logstash.logback:logstash-logback-encoder:5.1')
55-
runtime('com.h2database:h2')
56-
testCompile('org.springframework.boot:spring-boot-starter-test')
57-
testCompile('io.projectreactor:reactor-test')
58-
apt "org.mapstruct:mapstruct-processor:${mapstructVersion}"
59-
}
60-
61-
dependencyManagement {
62-
imports {
63-
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
64-
}
65-
}
66-
67-
processResources {
68-
filesMatching("**/application.properties") {
69-
expand(project.properties)
70-
}
71-
}
72-
73-
tasks.withType(JavaCompile) {
74-
options.compilerArgs = [
75-
'-Amapstruct.suppressGeneratorTimestamp=true'
76-
]
77-
}
78-
79-
task runJar(type: JavaExec, dependsOn: jar) {
80-
main = "-jar"
81-
args jar.archivePath
82-
}
83-
84-
def pullCommonDir = new File(buildDir, 'repo')
85-
pullCommonDir.mkdirs()
86-
def mongodbHome = new File("${buildDir}/libs/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}")
87-
88-
task downloadMongoDB(type: Download) {
89-
src "http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip"
90-
dest "${buildDir}/repo"
91-
overwrite false
92-
}
93-
94-
task extractMongoDB(dependsOn: downloadMongoDB) {
95-
doLast {
96-
if(!file("${mongodbHome}").exists()) {
97-
copy {
98-
from zipTree("${pullCommonDir}/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip")
99-
into new File(buildDir, "libs")
100-
}
101-
}
102-
}
103-
}
104-
105-
task configMongoDB(dependsOn: extractMongoDB) {
106-
doLast {
107-
def mongodbBinDir = new File("${mongodbHome}/bin", "mongod.cfg")
108-
109-
if (!mongodbBinDir.exists()) {
110-
println "setting up mongodb config file..."
111-
112-
def mongodbDataDir = new File("${mongodbHome}", 'data')
113-
mongodbDataDir.mkdirs()
114-
115-
def mongodbLogDir = new File("${mongodbHome}", 'logs')
116-
mongodbLogDir.mkdirs()
117-
def mongodbLogFile = new File("${mongodbLogDir}/mongo.log")
118-
119-
copy {
120-
from "${projectDir.path}/config/mongod.cfg"
121-
into "${mongodbHome}/bin"
122-
filter { line -> line.replaceAll("@logs@", "${mongodbLogFile}".replace("\\", "/") ) }
123-
filter { line -> line.replaceAll("@data@", "${mongodbDataDir}".replace("\\", "/")) }
124-
}
125-
}
126-
}
127-
}
128-
129-
task runMongodb(type: Exec, dependsOn: configMongoDB) {
130-
workingDir "${mongodbHome}/bin"
131-
commandLine 'cmd', '/c', "mongod --config mongod.cfg"
132-
}
1+
buildscript {
2+
ext {
3+
springBootVersion = '2.0.4.RELEASE'
4+
mongodbVersion = '4.0.1'
5+
}
6+
repositories {
7+
mavenCentral()
8+
jcenter()
9+
}
10+
dependencies {
11+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
12+
classpath("de.undercouch:gradle-download-task:3.4.3")
13+
}
14+
}
15+
16+
plugins {
17+
id "net.ltgt.apt" version "0.19"
18+
}
19+
20+
apply plugin: 'java'
21+
apply plugin: 'org.springframework.boot'
22+
apply plugin: 'io.spring.dependency-management'
23+
apply plugin: 'de.undercouch.download'
24+
25+
group = 'com.emprovise.service'
26+
version = '0.0.1-SNAPSHOT'
27+
sourceCompatibility = 1.8
28+
29+
repositories {
30+
mavenCentral()
31+
maven { url "https://repo.spring.io/milestone" }
32+
}
33+
34+
ext {
35+
springCloudVersion = 'Finchley.RELEASE'
36+
mapstructVersion = "1.2.0.Final"
37+
}
38+
39+
dependencies {
40+
41+
if (isProd) {
42+
compile('org.springframework.cloud:spring-cloud-starter-kubernetes:1.0.1.RELEASE')
43+
compile('org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:1.0.1.RELEASE')
44+
} else {
45+
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
46+
}
47+
48+
compile('org.springframework.boot:spring-boot-starter-actuator')
49+
compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive')
50+
compile('org.springframework.boot:spring-boot-starter-webflux')
51+
compile('org.springframework.boot:spring-boot-starter-batch')
52+
compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}"
53+
compile('org.slf4j:slf4j-api')
54+
runtime('net.logstash.logback:logstash-logback-encoder:5.1')
55+
runtime('com.h2database:h2')
56+
testCompile('org.springframework.boot:spring-boot-starter-test')
57+
testCompile('io.projectreactor:reactor-test')
58+
apt "org.mapstruct:mapstruct-processor:${mapstructVersion}"
59+
}
60+
61+
dependencyManagement {
62+
imports {
63+
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
64+
}
65+
}
66+
67+
processResources {
68+
filesMatching("**/application.properties") {
69+
expand(project.properties)
70+
}
71+
}
72+
73+
tasks.withType(JavaCompile) {
74+
options.compilerArgs = [
75+
'-Amapstruct.suppressGeneratorTimestamp=true'
76+
]
77+
}
78+
79+
task runJar(type: JavaExec, dependsOn: jar) {
80+
main = "-jar"
81+
args jar.archivePath
82+
}
83+
84+
def pullCommonDir = new File(buildDir, 'repo')
85+
pullCommonDir.mkdirs()
86+
def mongodbHome = new File("${buildDir}/libs/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}")
87+
88+
task downloadMongoDB(type: Download) {
89+
src "http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip"
90+
dest "${buildDir}/repo"
91+
overwrite false
92+
}
93+
94+
task extractMongoDB(dependsOn: downloadMongoDB) {
95+
doLast {
96+
if(!file("${mongodbHome}").exists()) {
97+
copy {
98+
from zipTree("${pullCommonDir}/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip")
99+
into new File(buildDir, "libs")
100+
}
101+
}
102+
}
103+
}
104+
105+
task configMongoDB(dependsOn: extractMongoDB) {
106+
doLast {
107+
def mongodbBinDir = new File("${mongodbHome}/bin", "mongod.cfg")
108+
109+
if (!mongodbBinDir.exists()) {
110+
println "setting up mongodb config file..."
111+
112+
def mongodbDataDir = new File("${mongodbHome}", 'data')
113+
mongodbDataDir.mkdirs()
114+
115+
def mongodbLogDir = new File("${mongodbHome}", 'logs')
116+
mongodbLogDir.mkdirs()
117+
def mongodbLogFile = new File("${mongodbLogDir}/mongo.log")
118+
119+
copy {
120+
from "${projectDir.path}/config/mongod.cfg"
121+
into "${mongodbHome}/bin"
122+
filter { line -> line.replaceAll("@logs@", "${mongodbLogFile}".replace("\\", "/") ) }
123+
filter { line -> line.replaceAll("@data@", "${mongodbDataDir}".replace("\\", "/")) }
124+
}
125+
}
126+
}
127+
}
128+
129+
task runMongodb(type: Exec, dependsOn: configMongoDB) {
130+
workingDir "${mongodbHome}/bin"
131+
commandLine 'cmd', '/c', "mongod --config mongod.cfg"
132+
}

discovery-service/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Discovery Service (Netflix Eureka)
2+
=============
3+
4+
Discovery discovery allows services to find and communicate with other services regardless of their IP address.
5+
[Netflix Eureka](http://cloud.spring.io/spring-cloud-netflix/single/spring-cloud-netflix.html#_service_discovery_eureka_clients) Server is a service registry while Eureka Client is a Discovery client.
6+
It provides a REST API for managing service instance registration and for querying available instances.
7+
8+
NOTE: The discovery service is used **ONLY FOR LOCAL TESTING**. For production Spring Cloud Kubernetes enables service discovery.
9+
10+
### Running the Discovery Service (For Local Testing Only)
11+
12+
Optionally **spring.profiles.active** can be passed with value **production** which enables logback to send all logs to Elastic Stack instead of logging in the console by default.
13+
14+
$ java -jar discovery-service/build/libs/discovery-service-0.0.1-SNAPSHOT.jar
15+
-Dspring.profiles.active=production

document-service/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Document Service
2+
=============
3+
4+
Document service provides services to access reporting data and fetching the report documents.
5+
It mainly uses [OpenFeign Clients](https://github.com/OpenFeign/feign) and [Netflix Hystrix](https://github.com/Netflix/Hystrix) circuit breakers to invoke [Data Service](/../data-service/README.md) and [Storage Service](/../storage-service/README.md).
6+
7+
### Running the Document Service
8+
9+
Optionally **spring.profiles.active** can be passed with value **production** which enables logback to send all logs to Elastic Stack instead of logging in the console by default.
10+
11+
$ java -jar document-service/build/libs/document-service-0.0.1-SNAPSHOT.jar
12+
-Dspring.profiles.active=production

0 commit comments

Comments
 (0)