From 8e9ac16dbf64f7775000a4f2b97d5e980ce5f6da Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Wed, 29 Apr 2020 14:17:40 +0200 Subject: [PATCH] Initial commit --- apps/docker-compose.yaml | 18 ++++ apps/helloworld-api/Dockerfile | 4 + apps/helloworld-api/HELP.md | 24 ++++++ apps/helloworld-api/pom.xml | 86 +++++++++++++++++++ .../HelloWorldApiApplication.java | 23 +++++ .../resources/application-docker.properties | 1 + .../src/main/resources/application.properties | 1 + .../src/main/resources/bootstrap-docker.yml | 4 + .../src/main/resources/bootstrap.yml | 4 + .../HelloWorldApiApplicationTests.java | 13 +++ base/admin/Dockerfile | 4 + base/admin/pom.xml | 77 +++++++++++++++++ .../example/admin/AdminServerApplication.java | 15 ++++ .../resources/application-docker.properties | 14 +++ .../src/main/resources/application.properties | 14 +++ .../src/main/resources/bootstrap-docker.yml | 4 + base/admin/src/main/resources/bootstrap.yml | 4 + .../example/admin/DemoApplicationTests.java | 13 +++ base/config/Dockerfile | 4 + base/config/pom.xml | 72 ++++++++++++++++ .../config/ConfigServerApplication.java | 15 ++++ .../resources/application-docker.properties | 29 +++++++ .../src/main/resources/application.properties | 23 +++++ .../src/main/resources/config/common.yml | 25 ++++++ .../config/hello-world-api-docker.yaml | 25 ++++++ .../resources/config/hello-world-api.yaml | 25 ++++++ .../example/config/DemoApplicationTests.java | 13 +++ base/docker-compose.yaml | 28 ++++++ base/eureka/Dockerfile | 4 + base/eureka/HELP.md | 15 ++++ base/eureka/pom.xml | 66 ++++++++++++++ .../com/example/eureka/EurekaApplication.java | 15 ++++ .../resources/application-docker.properties | 3 + .../src/main/resources/application.properties | 3 + .../eureka/EurekaApplicationTests.java | 13 +++ base/kubernetes/deployment-eureka.yaml | 24 ++++++ base/pom.xml | 14 +++ start.bash | 20 +++++ stop.bash | 7 ++ 39 files changed, 766 insertions(+) create mode 100644 apps/docker-compose.yaml create mode 100644 apps/helloworld-api/Dockerfile create mode 100644 apps/helloworld-api/HELP.md create mode 100644 apps/helloworld-api/pom.xml create mode 100644 apps/helloworld-api/src/main/java/com/example/helloworldapi/HelloWorldApiApplication.java create mode 100644 apps/helloworld-api/src/main/resources/application-docker.properties create mode 100644 apps/helloworld-api/src/main/resources/application.properties create mode 100644 apps/helloworld-api/src/main/resources/bootstrap-docker.yml create mode 100644 apps/helloworld-api/src/main/resources/bootstrap.yml create mode 100644 apps/helloworld-api/src/test/java/com/example/helloworldapi/HelloWorldApiApplicationTests.java create mode 100644 base/admin/Dockerfile create mode 100644 base/admin/pom.xml create mode 100644 base/admin/src/main/java/com/example/admin/AdminServerApplication.java create mode 100644 base/admin/src/main/resources/application-docker.properties create mode 100644 base/admin/src/main/resources/application.properties create mode 100644 base/admin/src/main/resources/bootstrap-docker.yml create mode 100644 base/admin/src/main/resources/bootstrap.yml create mode 100644 base/admin/src/test/java/com/example/admin/DemoApplicationTests.java create mode 100644 base/config/Dockerfile create mode 100644 base/config/pom.xml create mode 100644 base/config/src/main/java/com/example/config/ConfigServerApplication.java create mode 100644 base/config/src/main/resources/application-docker.properties create mode 100644 base/config/src/main/resources/application.properties create mode 100644 base/config/src/main/resources/config/common.yml create mode 100644 base/config/src/main/resources/config/hello-world-api-docker.yaml create mode 100644 base/config/src/main/resources/config/hello-world-api.yaml create mode 100644 base/config/src/test/java/com/example/config/DemoApplicationTests.java create mode 100644 base/docker-compose.yaml create mode 100644 base/eureka/Dockerfile create mode 100644 base/eureka/HELP.md create mode 100644 base/eureka/pom.xml create mode 100644 base/eureka/src/main/java/com/example/eureka/EurekaApplication.java create mode 100644 base/eureka/src/main/resources/application-docker.properties create mode 100644 base/eureka/src/main/resources/application.properties create mode 100644 base/eureka/src/test/java/com/example/eureka/EurekaApplicationTests.java create mode 100644 base/kubernetes/deployment-eureka.yaml create mode 100644 base/pom.xml create mode 100755 start.bash create mode 100755 stop.bash diff --git a/apps/docker-compose.yaml b/apps/docker-compose.yaml new file mode 100644 index 0000000..25e97b9 --- /dev/null +++ b/apps/docker-compose.yaml @@ -0,0 +1,18 @@ +--- +version: '3.3' + +services: + + hello-world: + build: + context: helloworld-api/ + environment: + - spring_profiles_active=docker + ports: + - "8080:8080" + networks: + - base_default + +networks: + base_default: + external: true diff --git a/apps/helloworld-api/Dockerfile b/apps/helloworld-api/Dockerfile new file mode 100644 index 0000000..5ee7f40 --- /dev/null +++ b/apps/helloworld-api/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:8-jdk-alpine +ARG JAR_FILE=target/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/apps/helloworld-api/HELP.md b/apps/helloworld-api/HELP.md new file mode 100644 index 0000000..7d7fbd8 --- /dev/null +++ b/apps/helloworld-api/HELP.md @@ -0,0 +1,24 @@ +# Read Me First +The following was discovered as part of building this project: + +* The original package name 'com.example.helloworld-api' is invalid and this project uses 'com.example.helloworldapi' instead. + +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/maven-plugin/) +* [Spring Web](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications) +* [Spring Boot Actuator](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#production-ready) +* [Spring Boot Admin (Client)](https://codecentric.github.io/spring-boot-admin/current/#getting-started) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/) +* [Building a RESTful Web Service with Spring Boot Actuator](https://spring.io/guides/gs/actuator-service/) + diff --git a/apps/helloworld-api/pom.xml b/apps/helloworld-api/pom.xml new file mode 100644 index 0000000..bfe133d --- /dev/null +++ b/apps/helloworld-api/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.5.RELEASE + + + com.example + helloworld-api + 0.0.1-SNAPSHOT + helloworld-api + Demo project for Spring Boot + + + 1.8 + 2.2.1 + Hoxton.SR3 + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-web + + + de.codecentric + spring-boot-admin-starter-client + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + de.codecentric + spring-boot-admin-dependencies + ${spring-boot-admin.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/apps/helloworld-api/src/main/java/com/example/helloworldapi/HelloWorldApiApplication.java b/apps/helloworld-api/src/main/java/com/example/helloworldapi/HelloWorldApiApplication.java new file mode 100644 index 0000000..e258069 --- /dev/null +++ b/apps/helloworld-api/src/main/java/com/example/helloworldapi/HelloWorldApiApplication.java @@ -0,0 +1,23 @@ +package com.example.helloworldapi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@EnableEurekaClient +@RestController +public class HelloWorldApiApplication { + + @RequestMapping("/") + public String home() { + return "Hello World"; + } + + public static void main(String[] args) { + SpringApplication.run(HelloWorldApiApplication.class, args); + } + +} diff --git a/apps/helloworld-api/src/main/resources/application-docker.properties b/apps/helloworld-api/src/main/resources/application-docker.properties new file mode 100644 index 0000000..550a6cf --- /dev/null +++ b/apps/helloworld-api/src/main/resources/application-docker.properties @@ -0,0 +1 @@ +spring.application.name = hello-world-api \ No newline at end of file diff --git a/apps/helloworld-api/src/main/resources/application.properties b/apps/helloworld-api/src/main/resources/application.properties new file mode 100644 index 0000000..550a6cf --- /dev/null +++ b/apps/helloworld-api/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name = hello-world-api \ No newline at end of file diff --git a/apps/helloworld-api/src/main/resources/bootstrap-docker.yml b/apps/helloworld-api/src/main/resources/bootstrap-docker.yml new file mode 100644 index 0000000..c619f10 --- /dev/null +++ b/apps/helloworld-api/src/main/resources/bootstrap-docker.yml @@ -0,0 +1,4 @@ +spring: + cloud: + config: + uri: http://config-server:8888 \ No newline at end of file diff --git a/apps/helloworld-api/src/main/resources/bootstrap.yml b/apps/helloworld-api/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..64283a6 --- /dev/null +++ b/apps/helloworld-api/src/main/resources/bootstrap.yml @@ -0,0 +1,4 @@ +spring: + cloud: + config: + uri: http://localhost:8888 \ No newline at end of file diff --git a/apps/helloworld-api/src/test/java/com/example/helloworldapi/HelloWorldApiApplicationTests.java b/apps/helloworld-api/src/test/java/com/example/helloworldapi/HelloWorldApiApplicationTests.java new file mode 100644 index 0000000..fc42416 --- /dev/null +++ b/apps/helloworld-api/src/test/java/com/example/helloworldapi/HelloWorldApiApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.helloworldapi; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class HelloWorldApiApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/base/admin/Dockerfile b/base/admin/Dockerfile new file mode 100644 index 0000000..5ee7f40 --- /dev/null +++ b/base/admin/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:8-jdk-alpine +ARG JAR_FILE=target/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/base/admin/pom.xml b/base/admin/pom.xml new file mode 100644 index 0000000..3373984 --- /dev/null +++ b/base/admin/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.5.RELEASE + + + com.example + admin + 0.0.1-SNAPSHOT + admin + Demo project for Spring Boot + + 1.8 + 2.2.1 + + + + de.codecentric + spring-boot-admin-starter-server + 2.2.2 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + compile + + + org.springframework.boot + spring-boot-starter-actuator + compile + + + + + + de.codecentric + spring-boot-admin-dependencies + ${spring-boot-admin.version} + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + Hoxton.SR3 + pom + import + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/base/admin/src/main/java/com/example/admin/AdminServerApplication.java b/base/admin/src/main/java/com/example/admin/AdminServerApplication.java new file mode 100644 index 0000000..f4b254f --- /dev/null +++ b/base/admin/src/main/java/com/example/admin/AdminServerApplication.java @@ -0,0 +1,15 @@ +package com.example.admin; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import de.codecentric.boot.admin.server.config.EnableAdminServer; + +@SpringBootApplication +@EnableAdminServer +public class AdminServerApplication { + + public static void main(String[] args) { + SpringApplication.run(AdminServerApplication.class, args); + } + +} diff --git a/base/admin/src/main/resources/application-docker.properties b/base/admin/src/main/resources/application-docker.properties new file mode 100644 index 0000000..932fafb --- /dev/null +++ b/base/admin/src/main/resources/application-docker.properties @@ -0,0 +1,14 @@ +spring.application.name = admin-server +server.port = 9090 + +# Eureka client config +eureka.client.serviceUrl.defaultZone = http://eureka:8761/eureka +# eureka.client.instance.preferIpAddress = true + +# Admin client config +spring.boot.admin.client.url=http://admin-server:9090 + +# Actuator +management.security.enabled = false +management.endpoints.web.exposure.include=* +management.endpoint.health.show-details=always \ No newline at end of file diff --git a/base/admin/src/main/resources/application.properties b/base/admin/src/main/resources/application.properties new file mode 100644 index 0000000..ce3191f --- /dev/null +++ b/base/admin/src/main/resources/application.properties @@ -0,0 +1,14 @@ +spring.application.name = admin-server +server.port = 9090 + +# Eureka client config +eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka +# eureka.client.instance.preferIpAddress = true + +# Admin client config +spring.boot.admin.client.url=http://localhost:9090 + +# Actuator +management.security.enabled = false +management.endpoints.web.exposure.include=* +management.endpoint.health.show-details=always \ No newline at end of file diff --git a/base/admin/src/main/resources/bootstrap-docker.yml b/base/admin/src/main/resources/bootstrap-docker.yml new file mode 100644 index 0000000..c619f10 --- /dev/null +++ b/base/admin/src/main/resources/bootstrap-docker.yml @@ -0,0 +1,4 @@ +spring: + cloud: + config: + uri: http://config-server:8888 \ No newline at end of file diff --git a/base/admin/src/main/resources/bootstrap.yml b/base/admin/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..64283a6 --- /dev/null +++ b/base/admin/src/main/resources/bootstrap.yml @@ -0,0 +1,4 @@ +spring: + cloud: + config: + uri: http://localhost:8888 \ No newline at end of file diff --git a/base/admin/src/test/java/com/example/admin/DemoApplicationTests.java b/base/admin/src/test/java/com/example/admin/DemoApplicationTests.java new file mode 100644 index 0000000..b323563 --- /dev/null +++ b/base/admin/src/test/java/com/example/admin/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.admin; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/base/config/Dockerfile b/base/config/Dockerfile new file mode 100644 index 0000000..5da6ba3 --- /dev/null +++ b/base/config/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:8-jdk-alpine +ARG JAR_FILE=target/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java","-jar","/app.jar","--trace"] diff --git a/base/config/pom.xml b/base/config/pom.xml new file mode 100644 index 0000000..d89ac37 --- /dev/null +++ b/base/config/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.5.RELEASE + + + com.example + config + 0.0.1-SNAPSHOT + config + Demo project for Spring Boot + + 1.8 + Hoxton.SR3 + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + compile + + + org.springframework.boot + spring-boot-starter-actuator + compile + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + Hoxton.SR3 + pom + import + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/base/config/src/main/java/com/example/config/ConfigServerApplication.java b/base/config/src/main/java/com/example/config/ConfigServerApplication.java new file mode 100644 index 0000000..2930e96 --- /dev/null +++ b/base/config/src/main/java/com/example/config/ConfigServerApplication.java @@ -0,0 +1,15 @@ +package com.example.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.server.EnableConfigServer; + +@SpringBootApplication +@EnableConfigServer +public class ConfigServerApplication { + + public static void main(String[] args) { + SpringApplication.run(ConfigServerApplication.class, args); + } + +} diff --git a/base/config/src/main/resources/application-docker.properties b/base/config/src/main/resources/application-docker.properties new file mode 100644 index 0000000..fb01803 --- /dev/null +++ b/base/config/src/main/resources/application-docker.properties @@ -0,0 +1,29 @@ + +# Config server +spring.application.name = config-server +welcome.message = Welcome to Spring cloud config server +server.port = 8888 + +# Config repository +#spring.cloud.config.server.git.uri=${HOME}/Work/Dev/test-spring-boot/config +#SPRING_PROFILES_ACTIVE=native +#spring.cloud.config.server.native.searchLocations=file:///C:/configprop/ +spring.profiles.include = native +spring.cloud.config.server.native.search-locations = classpath:config/common.yml, classpath:config/ + +# Eureka client config +eureka.client.serviceUrl.defaultZone = http://eureka:8761/eureka +# eureka.client.instance.preferIpAddress = true + +# Admin client config +spring.boot.admin.client.url=http://admin-server:9090 + +# Actuator +management.security.enabled = false +management.endpoints.web.exposure.include=* +management.endpoint.health.show-details=always + +logging: + level: + ROOT: INFO + org.springframework: TRACE \ No newline at end of file diff --git a/base/config/src/main/resources/application.properties b/base/config/src/main/resources/application.properties new file mode 100644 index 0000000..23b115d --- /dev/null +++ b/base/config/src/main/resources/application.properties @@ -0,0 +1,23 @@ + +# Config server +spring.application.name = config-server +welcome.message = Welcome to Spring cloud config server +server.port = 8888 + +# Config repository +spring.profiles.include = native +spring.cloud.config.server.native.search-locations = classpath:config/common.yml, classpath:config/ +#spring.cloud.config.server.git.uri=${HOME}/Work/Dev/test-spring-boot/config +#spring.cloud.config.server.native.searchLocations=file:///C:/configprop/ + +# Eureka client config +eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka +# eureka.client.instance.preferIpAddress = true + +# Admin client config +spring.boot.admin.client.url=http://localhost:9090 + +# Actuator +management.security.enabled = false +management.endpoints.web.exposure.include=* +management.endpoint.health.show-details=always diff --git a/base/config/src/main/resources/config/common.yml b/base/config/src/main/resources/config/common.yml new file mode 100644 index 0000000..c09c913 --- /dev/null +++ b/base/config/src/main/resources/config/common.yml @@ -0,0 +1,25 @@ +--- + +# Eureka client config +eureka: + client: + serviceUrl: + defaultZone: "http://eureka:8761/eureka" + +# Admin client config +spring: + boot: + admin: + client: + url: "http://admin-server:9090" + +# Actuator +management: + security: + enabled: false + endpoints: + web: + exposure: + include: "*" + health: + show-details: "always" diff --git a/base/config/src/main/resources/config/hello-world-api-docker.yaml b/base/config/src/main/resources/config/hello-world-api-docker.yaml new file mode 100644 index 0000000..c09c913 --- /dev/null +++ b/base/config/src/main/resources/config/hello-world-api-docker.yaml @@ -0,0 +1,25 @@ +--- + +# Eureka client config +eureka: + client: + serviceUrl: + defaultZone: "http://eureka:8761/eureka" + +# Admin client config +spring: + boot: + admin: + client: + url: "http://admin-server:9090" + +# Actuator +management: + security: + enabled: false + endpoints: + web: + exposure: + include: "*" + health: + show-details: "always" diff --git a/base/config/src/main/resources/config/hello-world-api.yaml b/base/config/src/main/resources/config/hello-world-api.yaml new file mode 100644 index 0000000..a70358a --- /dev/null +++ b/base/config/src/main/resources/config/hello-world-api.yaml @@ -0,0 +1,25 @@ +--- + +# Eureka client config +eureka: + client: + serviceUrl: + defaultZone: "http://localhost:8761/eureka" + +# Admin client config +spring: + boot: + admin: + client: + url: "http://localhost:9090" + +# Actuator +management: + security: + enabled: false + endpoints: + web: + exposure: + include: "*" + health: + show-details: "always" diff --git a/base/config/src/test/java/com/example/config/DemoApplicationTests.java b/base/config/src/test/java/com/example/config/DemoApplicationTests.java new file mode 100644 index 0000000..da7bdf4 --- /dev/null +++ b/base/config/src/test/java/com/example/config/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.config; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/base/docker-compose.yaml b/base/docker-compose.yaml new file mode 100644 index 0000000..260185c --- /dev/null +++ b/base/docker-compose.yaml @@ -0,0 +1,28 @@ +--- +version: '3.3' + +services: + + eureka: + build: + context: eureka/ + environment: + - spring_profiles_active=docker + ports: + - "8761:8761" + + admin-server: + build: + context: admin/ + environment: + - spring_profiles_active=docker + ports: + - "9090:9090" + + config-server: + build: + context: config/ + environment: + - spring_profiles_active=docker + ports: + - "8888:8888" diff --git a/base/eureka/Dockerfile b/base/eureka/Dockerfile new file mode 100644 index 0000000..5ee7f40 --- /dev/null +++ b/base/eureka/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:8-jdk-alpine +ARG JAR_FILE=target/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/base/eureka/HELP.md b/base/eureka/HELP.md new file mode 100644 index 0000000..130a575 --- /dev/null +++ b/base/eureka/HELP.md @@ -0,0 +1,15 @@ +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/maven-plugin/) +* [Spring Boot Actuator](https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#production-ready) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Service Registration and Discovery](https://spring.io/guides/gs/service-registration-and-discovery/) +* [Building a RESTful Web Service with Spring Boot Actuator](https://spring.io/guides/gs/actuator-service/) + diff --git a/base/eureka/pom.xml b/base/eureka/pom.xml new file mode 100644 index 0000000..44752c1 --- /dev/null +++ b/base/eureka/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.5.RELEASE + + + com.example + eureka + 0.0.1-SNAPSHOT + eureka + Demo project for Spring Boot + + + 1.8 + Hoxton.SR3 + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-server + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/base/eureka/src/main/java/com/example/eureka/EurekaApplication.java b/base/eureka/src/main/java/com/example/eureka/EurekaApplication.java new file mode 100644 index 0000000..61027a3 --- /dev/null +++ b/base/eureka/src/main/java/com/example/eureka/EurekaApplication.java @@ -0,0 +1,15 @@ +package com.example.eureka; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +@SpringBootApplication +@EnableEurekaServer +public class EurekaApplication { + + public static void main(String[] args) { + SpringApplication.run(EurekaApplication.class, args); + } + +} diff --git a/base/eureka/src/main/resources/application-docker.properties b/base/eureka/src/main/resources/application-docker.properties new file mode 100644 index 0000000..8fbcce8 --- /dev/null +++ b/base/eureka/src/main/resources/application-docker.properties @@ -0,0 +1,3 @@ +eureka.client.registerWithEureka = false +eureka.client.fetchRegistry = false +server.port = 8761 \ No newline at end of file diff --git a/base/eureka/src/main/resources/application.properties b/base/eureka/src/main/resources/application.properties new file mode 100644 index 0000000..8fbcce8 --- /dev/null +++ b/base/eureka/src/main/resources/application.properties @@ -0,0 +1,3 @@ +eureka.client.registerWithEureka = false +eureka.client.fetchRegistry = false +server.port = 8761 \ No newline at end of file diff --git a/base/eureka/src/test/java/com/example/eureka/EurekaApplicationTests.java b/base/eureka/src/test/java/com/example/eureka/EurekaApplicationTests.java new file mode 100644 index 0000000..e1ebc3d --- /dev/null +++ b/base/eureka/src/test/java/com/example/eureka/EurekaApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.eureka; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class EurekaApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/base/kubernetes/deployment-eureka.yaml b/base/kubernetes/deployment-eureka.yaml new file mode 100644 index 0000000..f68b82e --- /dev/null +++ b/base/kubernetes/deployment-eureka.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + app: eureka + name: eureka +spec: + replicas: 1 + selector: + matchLabels: + app: eureka + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + app: eureka + spec: + containers: + - image: 10.202.117.54:5000/demo_eureka + name: eureka + resources: {} +status: {} diff --git a/base/pom.xml b/base/pom.xml new file mode 100644 index 0000000..9fdb4c2 --- /dev/null +++ b/base/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + com.example + base + test-spring-boot + 1.0-SNAPSHOT + pom + + eureka + admin + config + + diff --git a/start.bash b/start.bash new file mode 100755 index 0000000..37a4e41 --- /dev/null +++ b/start.bash @@ -0,0 +1,20 @@ +#!/bin/bash + +SESSION_NAME=springboot + +BASEDIR="$HOME/Work/Dev/test-spring-boot" +VERSION="0.0.1-SNAPSHOT" +DEBUG="--debug" + +# Create tmux session +tmux new-session -s "${SESSION_NAME}" -d + +# Start spring infra (eureka, admin-server, config-server) +tmux new-window -t "${SESSION_NAME}" -n "eureka" -c "${BASEDIR}/base" "java -jar eureka/target/eureka-${VERSION}.jar $DEBUG" +tmux new-window -t "${SESSION_NAME}" -n "config-server" -c "${BASEDIR}/base" "java -jar config/target/config-${VERSION}.jar $DEBUG" +tmux new-window -t "${SESSION_NAME}" -n "admin-server" -c "${BASEDIR}/base" "java -jar admin/target/admin-${VERSION}.jar $DEBUG" + +sleep 30 + +# Start applications +tmux new-window -t "${SESSION_NAME}" -n "helloworld" -c "${BASEDIR}/apps" "java -jar helloworld-api/target/helloworld-api-${VERSION}.jar $DEBUG" diff --git a/stop.bash b/stop.bash new file mode 100755 index 0000000..d950d5d --- /dev/null +++ b/stop.bash @@ -0,0 +1,7 @@ +#!/bin/bash + +SESSION_NAME=springboot + +BASEDIR=$HOME/Work/Dev/test-spring-boot + +tmux kill-session -t "${SESSION_NAME}"