Skip to content

Commit

Permalink
Adding simple microservices modules (part 5)
Browse files Browse the repository at this point in the history
  • Loading branch information
piomin committed Jul 15, 2020
1 parent 4841cf7 commit 8ad6256
Show file tree
Hide file tree
Showing 23 changed files with 575 additions and 0 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<modules>
<module>best-practices</module>
<module>simple-microservices</module>
</modules>

</project>
30 changes: 30 additions & 0 deletions simple-microservices/department-service/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: department-deployment
spec:
selector:
matchLabels:
app: department
template:
metadata:
labels:
app: department
spec:
containers:
- name: department
image: piomin/department-service
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: department-service
spec:
type: ClusterIP
selector:
app: department
ports:
- port: 8080
targetPort: 8080
100 changes: 100 additions & 0 deletions simple-microservices/department-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/>
</parent>
<groupId>pl.piomin.samples.kubernetes</groupId>
<artifactId>department-service</artifactId>
<version>1.0</version>

<properties>
<java.version>11</java.version>
<kotlin.version>1.3.72</kotlin.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jib</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
12 changes: 12 additions & 0 deletions simple-microservices/department-service/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: skaffold/v2beta5
kind: Config
metadata:
name: department-service
build:
artifacts:
- image: piomin/department-service
jib:
args:
- -Pjib
tagPolicy:
gitCommit: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package pl.piomin.samples.kubernetes.department

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class DepartmentApp

fun main(args: Array<String>) {
runApplication<DepartmentApp>(*args)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package pl.piomin.samples.kubernetes.department.controller

import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/departments")
class DepartmentController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pl.piomin.samples.kubernetes.department.domain

import javax.persistence.Entity
import javax.persistence.Id

@Entity
data class Department(@Id var id: Int, val name: String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
spring:
application:
name: department-service
datasource:
url: jdbc:postgresql://postgresql:5432/${POSTGRES_DATABASE}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
hikari:
connection-timeout: 2000
initialization-fail-timeout: 0
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
management:
endpoints.web.exposure.include: '*'
endpoint:
health:
show-details: always
30 changes: 30 additions & 0 deletions simple-microservices/employee-service/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: employee-deployment
spec:
selector:
matchLabels:
app: employee
template:
metadata:
labels:
app: employee
spec:
containers:
- name: employee
image: piomin/employee-service
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: employee-service
spec:
type: ClusterIP
selector:
app: employee
ports:
- port: 8080
targetPort: 8080
100 changes: 100 additions & 0 deletions simple-microservices/employee-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/>
</parent>
<groupId>pl.piomin.samples.kubernetes</groupId>
<artifactId>employee-service</artifactId>
<version>1.0</version>

<properties>
<java.version>11</java.version>
<kotlin.version>1.3.72</kotlin.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jib</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
12 changes: 12 additions & 0 deletions simple-microservices/employee-service/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: skaffold/v2beta5
kind: Config
metadata:
name: employee-service
build:
artifacts:
- image: piomin/employee-service
jib:
args:
- -Pjib
tagPolicy:
gitCommit: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package pl.piomin.samples.kubernetes.employee

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class EmployeeApp

fun main(args: Array<String>) {
runApplication<EmployeeApp>(*args)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package pl.piomin.samples.kubernetes.employee.controller

import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/employees")
class EmployeeController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package pl.piomin.samples.kubernetes.employee.domain

class Employee
Loading

0 comments on commit 8ad6256

Please sign in to comment.