Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring cloud netflix #1

Merged
merged 14 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3.0"

services:
eureka-server:
container_name: eureka
image: springcloud/eureka
ports:
- "8761:8761"
redis:
container_name: redis
image: redis
ports:
- "6379:6379"
mongo:
container_name: mongo
image: mongo
ports:
- "27017:27017"
volumes:
- "${MONGO_VOLUME}:/var/lib/mongodb"
7 changes: 7 additions & 0 deletions docker/kubernetes/ui-interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ metadata:
name: ui-interface
data:
application.yaml: |-
ribbon:
eureka:
enabled: false
client:
enabled: true
ServerListRefreshInterval: 50

spring:
cloud:
gateway:
Expand Down
32 changes: 0 additions & 32 deletions docker/mongo.yml

This file was deleted.

31 changes: 31 additions & 0 deletions docker/starter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

docker-compose up 2>docker.log &

cd ..

PROJECT_HOME=`pwd`

HELLO_SERVICE_JAR_DIR=$PROJECT_HOME/hello-service/build/libs
MESSAGE_SERVICE_JAR_DIR=$PROJECT_HOME/message-service/build/libs
UI_JAR_DIR=$PROJECT_HOME/ui/target

echo "The content of PROJECT_HOME is: $PROJECT_HOME"
echo "The content of HELLO_SERVICE_JAR_DIR is: $HELLO_SERVICE_JAR_DIR"
echo "The content of MESSAGE_SERVICE_JAR_DIR is: $MESSAGE_SERVICE_JAR_DIR"
echo "The content of UI_JAR_DIR is: $UI_JAR_DIR"


echo "start of hello-service"
cd $HELLO_SERVICE_JAR_DIR
java -jar -Dspring.profiles.active=netflix hello-service.jar >$PROJECT_HOME/hello-service.log &


echo "start of message-service"
cd $MESSAGE_SERVICE_JAR_DIR
java -jar -Dspring.profiles.active=netflix message-service.jar >$PROJECT_HOME/message-service.log &


#echo "start of ui"
#cd $UI_JAR_DIR
#java -jar -Dspring.profiles.active=netflix ui-interface.jar >$PROJECT_HOME/ui-interface.log &
8 changes: 3 additions & 5 deletions hello-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ dependencies {

implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-config'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon'


compile 'org.projectlombok:lombok:1.18.6'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand All @@ -52,3 +48,5 @@ docker {
pull true
noCache true
}

apply from: rootProject.file('profile.gradle');
12 changes: 12 additions & 0 deletions hello-service/profile.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if (project.hasProperty('kubernetes')) {
println("kubernetes")
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-config'
}
} else if (project.hasProperty('netflix')) {
println("netflix")
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
}
}
4 changes: 4 additions & 0 deletions hello-service/profiles/kubernetes_build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-config'
}
3 changes: 3 additions & 0 deletions hello-service/profiles/netflix_build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
}
85 changes: 0 additions & 85 deletions hello-service/src/main/kubernetes/hello-service-k8s.yml

This file was deleted.

9 changes: 9 additions & 0 deletions hello-service/src/main/resources/application-netflix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server:
use-forward-headers: true
port: 7070

hello-service-uri: http://message-service/message/random

management:
server:
port: 7071
6 changes: 3 additions & 3 deletions message-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-config'

implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
Expand All @@ -36,6 +33,7 @@ dependencies {
testImplementation 'io.projectreactor:reactor-test'
}


dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
Expand Down Expand Up @@ -64,3 +62,5 @@ docker {
pull true
noCache true
}

apply from: rootProject.file('profile.gradle');
12 changes: 12 additions & 0 deletions message-service/profile.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if (project.hasProperty('kubernetes')) {
println("kubernetes")
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-config'
}
} else if (project.hasProperty('netflix')) {
println("netflix")
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
}
}
4 changes: 4 additions & 0 deletions message-service/profiles/kubernetes_build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes'
implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-config'
}
3 changes: 3 additions & 0 deletions message-service/profiles/netflix_build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@ class MessageRoute(private val messageRepository: MessageRepository) {
}
.flatMap { noContent().build() }
}

DELETE("/message/{messageId}") {
val messageId = it.pathVariable("messageId")
messageRepository.deleteById(messageId)
.flatMap { noContent().build() }
}
}
}
87 changes: 0 additions & 87 deletions message-service/src/main/kubernetes/message-service-k8s.yml

This file was deleted.

Loading