diff --git a/account-service/Dockerfile b/account-service/Dockerfile index 347b9e38..ab5f9d08 100644 --- a/account-service/Dockerfile +++ b/account-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk +FROM openjdk:alpine MAINTAINER Piotr Minkowski ADD target/account-service.jar account-service.jar ENTRYPOINT ["java", "-jar", "/account-service.jar"] diff --git a/account-service/pom.xml b/account-service/pom.xml index 900d657d..f66a1cd2 100644 --- a/account-service/pom.xml +++ b/account-service/pom.xml @@ -25,6 +25,10 @@ org.springframework.cloud spring-cloud-sleuth-zipkin + + org.springframework.boot + spring-boot-starter-data-mongodb + @@ -33,7 +37,6 @@ org.springframework.boot spring-boot-maven-plugin - 1.5.2.RELEASE pl.piomin.microservices.account.Application true diff --git a/account-service/src/main/java/pl/piomin/microservices/account/Application.java b/account-service/src/main/java/pl/piomin/microservices/account/Application.java index 6a032999..baa8e934 100644 --- a/account-service/src/main/java/pl/piomin/microservices/account/Application.java +++ b/account-service/src/main/java/pl/piomin/microservices/account/Application.java @@ -2,14 +2,12 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication -@EnableDiscoveryClient public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } - + } diff --git a/account-service/src/main/java/pl/piomin/microservices/account/api/Api.java b/account-service/src/main/java/pl/piomin/microservices/account/api/Api.java index c13a659f..854ec73e 100644 --- a/account-service/src/main/java/pl/piomin/microservices/account/api/Api.java +++ b/account-service/src/main/java/pl/piomin/microservices/account/api/Api.java @@ -1,50 +1,48 @@ package pl.piomin.microservices.account.api; -import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; -import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import pl.piomin.microservices.account.data.AccountRepository; import pl.piomin.microservices.account.model.Account; @RestController public class Api { - private List accounts; - + @Autowired + AccountRepository repository; + protected Logger logger = Logger.getLogger(Api.class.getName()); - - public Api() { - accounts = new ArrayList<>(); - accounts.add(new Account(1, 1, "111111")); - accounts.add(new Account(2, 2, "222222")); - accounts.add(new Account(3, 3, "333333")); - accounts.add(new Account(4, 4, "444444")); - accounts.add(new Account(5, 1, "555555")); - accounts.add(new Account(6, 2, "666666")); - accounts.add(new Account(7, 2, "777777")); - } - + @RequestMapping("/accounts/{number}") public Account findByNumber(@PathVariable("number") String number) { logger.info(String.format("Account.findByNumber(%s)", number)); - return accounts.stream().filter(it -> it.getNumber().equals(number)).findFirst().get(); + return repository.findByNumber(number); } - + @RequestMapping("/accounts/customer/{customer}") - public List findByCustomer(@PathVariable("customer") Integer customerId) { + public List findByCustomer(@PathVariable("customer") String customerId) { logger.info(String.format("Account.findByCustomer(%s)", customerId)); - return accounts.stream().filter(it -> it.getCustomerId().intValue()==customerId.intValue()).collect(Collectors.toList()); + return repository.findByCustomerId(customerId); } - + @RequestMapping("/accounts") public List findAll() { logger.info("Account.findAll()"); - return accounts; + return repository.findAll(); + } + + @RequestMapping(method = RequestMethod.POST, value = "/accounts") + public Account add(@RequestBody Account account) { + logger.info(String.format("Account.add(%s)", account)); + return repository.save(account); } - + } diff --git a/account-service/src/main/java/pl/piomin/microservices/account/data/AccountRepository.java b/account-service/src/main/java/pl/piomin/microservices/account/data/AccountRepository.java new file mode 100644 index 00000000..e92f35fe --- /dev/null +++ b/account-service/src/main/java/pl/piomin/microservices/account/data/AccountRepository.java @@ -0,0 +1,14 @@ +package pl.piomin.microservices.account.data; + +import java.util.List; + +import org.springframework.data.mongodb.repository.MongoRepository; + +import pl.piomin.microservices.account.model.Account; + +public interface AccountRepository extends MongoRepository { + + public Account findByNumber(String number); + public List findByCustomerId(String customerId); + +} diff --git a/account-service/src/main/java/pl/piomin/microservices/account/model/Account.java b/account-service/src/main/java/pl/piomin/microservices/account/model/Account.java index 089b48b1..611aa973 100644 --- a/account-service/src/main/java/pl/piomin/microservices/account/model/Account.java +++ b/account-service/src/main/java/pl/piomin/microservices/account/model/Account.java @@ -1,34 +1,39 @@ package pl.piomin.microservices.account.model; +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +@Document(collection = "account") public class Account { - private Integer id; - private Integer customerId; + @Id + private String id; + private String customerId; private String number; public Account() { } - public Account(Integer id, Integer customerId, String number) { + public Account(String id, String customerId, String number) { this.id = id; this.customerId = customerId; this.number = number; } - public Integer getId() { + public String getId() { return id; } - public void setId(Integer id) { + public void setId(String id) { this.id = id; } - public Integer getCustomerId() { + public String getCustomerId() { return customerId; } - public void setCustomerId(Integer customerId) { + public void setCustomerId(String customerId) { this.customerId = customerId; } diff --git a/account-service/src/main/resources/application.yml b/account-service/src/main/resources/application.yml index 9eda5a6f..429f6af6 100644 --- a/account-service/src/main/resources/application.yml +++ b/account-service/src/main/resources/application.yml @@ -4,6 +4,12 @@ server: spring: application: name: account-service + data: + mongodb: + host: localhost + port: 27017 + username: micro + password: micro logging: pattern: console: "%clr(%d{yyyy-MM-dd HH:mm:ss}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([${springAppName:-},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]){yellow} %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}" diff --git a/customer-service/Dockerfile b/customer-service/Dockerfile index 8bfaa51c..2b11a0cb 100644 --- a/customer-service/Dockerfile +++ b/customer-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk +FROM openjdk:alpine MAINTAINER Piotr Minkowski ADD target/customer-service.jar customer-service.jar ENTRYPOINT ["java", "-jar", "/customer-service.jar"] diff --git a/customer-service/pom.xml b/customer-service/pom.xml index 1467cf1c..1d975781 100644 --- a/customer-service/pom.xml +++ b/customer-service/pom.xml @@ -29,6 +29,10 @@ org.springframework.cloud spring-cloud-sleuth-zipkin + + org.springframework.boot + spring-boot-starter-data-mongodb + @@ -37,7 +41,6 @@ org.springframework.boot spring-boot-maven-plugin - 1.5.2.RELEASE pl.piomin.microservices.customer.Application true diff --git a/customer-service/src/main/java/pl/piomin/microservices/customer/Application.java b/customer-service/src/main/java/pl/piomin/microservices/customer/Application.java index 709fc153..265522d8 100644 --- a/customer-service/src/main/java/pl/piomin/microservices/customer/Application.java +++ b/customer-service/src/main/java/pl/piomin/microservices/customer/Application.java @@ -2,11 +2,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; @SpringBootApplication -@EnableDiscoveryClient @EnableFeignClients public class Application { diff --git a/customer-service/src/main/java/pl/piomin/microservices/customer/api/Api.java b/customer-service/src/main/java/pl/piomin/microservices/customer/api/Api.java index 8a9f0509..808f215a 100644 --- a/customer-service/src/main/java/pl/piomin/microservices/customer/api/Api.java +++ b/customer-service/src/main/java/pl/piomin/microservices/customer/api/Api.java @@ -1,18 +1,19 @@ package pl.piomin.microservices.customer.api; -import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import pl.piomin.microservices.customer.data.CustomerRepository; import pl.piomin.microservices.customer.intercomm.AccountClient; import pl.piomin.microservices.customer.model.Account; import pl.piomin.microservices.customer.model.Customer; -import pl.piomin.microservices.customer.model.CustomerType; @RestController public class Api { @@ -20,37 +21,36 @@ public class Api { @Autowired private AccountClient accountClient; - protected Logger logger = Logger.getLogger(Api.class.getName()); - - private List customers; + @Autowired + CustomerRepository repository; - public Api() { - customers = new ArrayList<>(); - customers.add(new Customer(1, "12345", "Adam Kowalski", CustomerType.INDIVIDUAL)); - customers.add(new Customer(2, "12346", "Anna Malinowska", CustomerType.INDIVIDUAL)); - customers.add(new Customer(3, "12347", "Paweł Michalski", CustomerType.INDIVIDUAL)); - customers.add(new Customer(4, "12348", "Karolina Lewandowska", CustomerType.INDIVIDUAL)); - } + protected Logger logger = Logger.getLogger(Api.class.getName()); @RequestMapping("/customers/pesel/{pesel}") public Customer findByPesel(@PathVariable("pesel") String pesel) { logger.info(String.format("Customer.findByPesel(%s)", pesel)); - return customers.stream().filter(it -> it.getPesel().equals(pesel)).findFirst().get(); + return repository.findByPesel(pesel); } @RequestMapping("/customers") public List findAll() { logger.info("Customer.findAll()"); - return customers; + return repository.findAll(); } @RequestMapping("/customers/{id}") - public Customer findById(@PathVariable("id") Integer id) { + public Customer findById(@PathVariable("id") String id) { logger.info(String.format("Customer.findById(%s)", id)); - Customer customer = customers.stream().filter(it -> it.getId().intValue()==id.intValue()).findFirst().get(); + Customer customer = repository.findById(id); List accounts = accountClient.getAccounts(id); customer.setAccounts(accounts); return customer; } + @RequestMapping(method = RequestMethod.POST, value = "/customers") + public Customer add(@RequestBody Customer customer) { + logger.info(String.format("Customer.add(%s)", customer)); + return repository.save(customer); + } + } diff --git a/customer-service/src/main/java/pl/piomin/microservices/customer/data/CustomerRepository.java b/customer-service/src/main/java/pl/piomin/microservices/customer/data/CustomerRepository.java new file mode 100644 index 00000000..cf96dabb --- /dev/null +++ b/customer-service/src/main/java/pl/piomin/microservices/customer/data/CustomerRepository.java @@ -0,0 +1,12 @@ +package pl.piomin.microservices.customer.data; + +import org.springframework.data.mongodb.repository.MongoRepository; + +import pl.piomin.microservices.customer.model.Customer; + +public interface CustomerRepository extends MongoRepository { + + public Customer findByPesel(String pesel); + public Customer findById(String id); + +} diff --git a/customer-service/src/main/java/pl/piomin/microservices/customer/intercomm/AccountClient.java b/customer-service/src/main/java/pl/piomin/microservices/customer/intercomm/AccountClient.java index 1eeadd43..2d493a29 100644 --- a/customer-service/src/main/java/pl/piomin/microservices/customer/intercomm/AccountClient.java +++ b/customer-service/src/main/java/pl/piomin/microservices/customer/intercomm/AccountClient.java @@ -9,10 +9,10 @@ import pl.piomin.microservices.customer.model.Account; -@FeignClient("account-service") +@FeignClient(name = "account-service", url = "http://account-service:2222") public interface AccountClient { - @RequestMapping(method = RequestMethod.GET, value = "/accounts/customer/{customerId}") - List getAccounts(@PathVariable("customerId") Integer customerId); - + @RequestMapping(method = RequestMethod.GET, value = "/accounts/customer/{customerId}") + List getAccounts(@PathVariable("customerId") String customerId); + } diff --git a/customer-service/src/main/java/pl/piomin/microservices/customer/model/Account.java b/customer-service/src/main/java/pl/piomin/microservices/customer/model/Account.java index 51f3d79e..e6b4c8eb 100644 --- a/customer-service/src/main/java/pl/piomin/microservices/customer/model/Account.java +++ b/customer-service/src/main/java/pl/piomin/microservices/customer/model/Account.java @@ -2,24 +2,24 @@ public class Account { - private Integer id; + private String id; private String number; public Account() { } - public Account(Integer id, String number) { + public Account(String id, String number) { super(); this.id = id; this.number = number; } - public Integer getId() { + public String getId() { return id; } - public void setId(Integer id) { + public void setId(String id) { this.id = id; } diff --git a/customer-service/src/main/java/pl/piomin/microservices/customer/model/Customer.java b/customer-service/src/main/java/pl/piomin/microservices/customer/model/Customer.java index f532061c..a5d727b5 100644 --- a/customer-service/src/main/java/pl/piomin/microservices/customer/model/Customer.java +++ b/customer-service/src/main/java/pl/piomin/microservices/customer/model/Customer.java @@ -2,9 +2,14 @@ import java.util.List; +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +@Document(collection = "customer") public class Customer { - private Integer id; + @Id + private String id; private String pesel; private String name; private CustomerType type; @@ -14,18 +19,18 @@ public Customer() { } - public Customer(Integer id, String pesel, String name, CustomerType type) { + public Customer(String id, String pesel, String name, CustomerType type) { this.id = id; this.pesel = pesel; this.name = name; this.type = type; } - public Integer getId() { + public String getId() { return id; } - public void setId(Integer id) { + public void setId(String id) { this.id = id; } diff --git a/customer-service/src/main/resources/application.yml b/customer-service/src/main/resources/application.yml index d1942280..3a96e342 100644 --- a/customer-service/src/main/resources/application.yml +++ b/customer-service/src/main/resources/application.yml @@ -1,14 +1,22 @@ server: port: ${PORT:3333} -eureka: - client: - serviceUrl: - defaultZone: ${DISCOVERY_URL:http://discovery:8761}/eureka/ - instance: - leaseRenewalIntervalInSeconds: 1 - leaseExpirationDurationInSeconds: 2 +spring: + data: + mongodb: + host: localhost + port: 27017 + username: micro + password: micro + +#eureka: +# client: +# serviceUrl: +# defaultZone: ${DISCOVERY_URL:http://discovery:8761}/eureka/ +# instance: +# leaseRenewalIntervalInSeconds: 1 +# leaseExpirationDurationInSeconds: 2 ribbon: eureka: - enabled: true \ No newline at end of file + enabled: false \ No newline at end of file diff --git a/discovery-service/.gitignore b/discovery-service/.gitignore deleted file mode 100644 index 8bd3a058..00000000 --- a/discovery-service/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -/.settings/ -/.classpath -/.project diff --git a/discovery-service/Dockerfile b/discovery-service/Dockerfile deleted file mode 100644 index 81ab1c85..00000000 --- a/discovery-service/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM openjdk -MAINTAINER Piotr Minkowski -ADD target/discovery-service.jar discovery-service.jar -ENTRYPOINT ["java", "-jar", "/discovery-service.jar"] -EXPOSE 8761 \ No newline at end of file diff --git a/discovery-service/Jenkinsfile b/discovery-service/Jenkinsfile deleted file mode 100644 index dce63e0a..00000000 --- a/discovery-service/Jenkinsfile +++ /dev/null @@ -1,34 +0,0 @@ -node { - - withMaven(maven:'maven') { - - stage('Checkout') { - git url: 'https://github.com/piomin/sample-spring-microservices.git', credentialsId: 'github-piomin', branch: 'master' - } - - stage('Build') { - sh 'mvn clean install' - - def pom = readMavenPom file:'pom.xml' - print pom.version - env.version = pom.version - } - - stage('Image') { - dir ('discovery-service') { - def app = docker.build "localhost:5000/discovery-service:${env.version}" - app.push() - } - } - - stage ('Run') { - docker.image("localhost:5000/discovery-service:${env.version}").run('-p 8761:8761 -h discovery --name discovery') - } - - stage ('Final') { - build job: 'account-service-pipeline', wait: false - } - - } - -} \ No newline at end of file diff --git a/discovery-service/pom.xml b/discovery-service/pom.xml deleted file mode 100644 index b06150f2..00000000 --- a/discovery-service/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - 4.0.0 - - pl.piomin - sample-spring-microservices - 1.0-SNAPSHOT - - discovery-service - - - - org.springframework.cloud - spring-cloud-starter-eureka-server - - - - - discovery-service - - - org.springframework.boot - spring-boot-maven-plugin - 1.5.2.RELEASE - - pl.piomin.microservices.eureka.Application - true - - - - - repackage - - - - - - - - \ No newline at end of file diff --git a/discovery-service/src/main/java/pl/piomin/microservices/eureka/Application.java b/discovery-service/src/main/java/pl/piomin/microservices/eureka/Application.java deleted file mode 100644 index 941cfd07..00000000 --- a/discovery-service/src/main/java/pl/piomin/microservices/eureka/Application.java +++ /dev/null @@ -1,15 +0,0 @@ -package pl.piomin.microservices.eureka; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; - -@SpringBootApplication -@EnableEurekaServer -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/discovery-service/src/main/resources/application.yml b/discovery-service/src/main/resources/application.yml deleted file mode 100644 index c6219304..00000000 --- a/discovery-service/src/main/resources/application.yml +++ /dev/null @@ -1,11 +0,0 @@ -server: - port: ${PORT:8761} - -eureka: - instance: - hostname: localhost - client: - registerWithEureka: false - fetchRegistry: false - server: - enableSelfPreservation: false \ No newline at end of file diff --git a/gateway-service/.gitignore b/gateway-service/.gitignore deleted file mode 100644 index 8bd3a058..00000000 --- a/gateway-service/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -/.settings/ -/.classpath -/.project diff --git a/gateway-service/Dockerfile b/gateway-service/Dockerfile deleted file mode 100644 index 88a57daf..00000000 --- a/gateway-service/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM openjdk -MAINTAINER Piotr Minkowski -ADD target/gateway-service.jar gateway-service.jar -ENTRYPOINT ["java", "-jar", "/gateway-service.jar"] -EXPOSE 8765 \ No newline at end of file diff --git a/gateway-service/Jenkinsfile b/gateway-service/Jenkinsfile deleted file mode 100644 index ffa1ca2e..00000000 --- a/gateway-service/Jenkinsfile +++ /dev/null @@ -1,31 +0,0 @@ -node { - - withMaven(maven:'maven') { - - stage('Checkout') { - git url: 'https://github.com/piomin/sample-spring-microservices.git', credentialsId: 'github-piomin', branch: 'master' - } - - stage('Build') { - sh 'mvn clean install' - - def pom = readMavenPom file:'pom.xml' - print pom.version - env.version = pom.version - } - - stage('Image') { - dir ('gateway-service') { - def app = docker.build "localhost:5000/gateway-service:${env.version}" - app.push() - } - } - - stage ('Run') { - docker.image("localhost:5000/gateway-service:${env.version}").run('-p 3333:3333 -h gateway --name gateway --link discovery --link account --link customer') - } - - - } - -} \ No newline at end of file diff --git a/gateway-service/pom.xml b/gateway-service/pom.xml deleted file mode 100644 index d24d644e..00000000 --- a/gateway-service/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - 4.0.0 - - pl.piomin - sample-spring-microservices - 1.0-SNAPSHOT - - gateway-service - - - - org.springframework.cloud - spring-cloud-starter-eureka - - - org.springframework.boot - spring-boot-starter - - - org.springframework - spring-web - - - org.springframework.cloud - spring-cloud-starter-zuul - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.cloud - spring-cloud-starter-sleuth - - - org.springframework.cloud - spring-cloud-sleuth-zipkin - - - - - gateway-service - - - org.springframework.boot - spring-boot-maven-plugin - 1.5.2.RELEASE - - pl.piomin.microservices.edge.Application - true - - - - - repackage - - - - - - - - \ No newline at end of file diff --git a/gateway-service/src/main/java/pl/piomin/microservices/edge/Application.java b/gateway-service/src/main/java/pl/piomin/microservices/edge/Application.java deleted file mode 100644 index 999cd2bc..00000000 --- a/gateway-service/src/main/java/pl/piomin/microservices/edge/Application.java +++ /dev/null @@ -1,24 +0,0 @@ -package pl.piomin.microservices.edge; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.netflix.zuul.EnableZuulProxy; -import org.springframework.cloud.sleuth.sampler.AlwaysSampler; -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.RestController; - -@SpringBootApplication -@EnableZuulProxy -@RestController -public class Application { - - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).web(true).run(args); - } - - @Bean - public AlwaysSampler defaultSampler() { - return new AlwaysSampler(); - } - -} diff --git a/gateway-service/src/main/resources/application.yml b/gateway-service/src/main/resources/application.yml deleted file mode 100644 index 063a5132..00000000 --- a/gateway-service/src/main/resources/application.yml +++ /dev/null @@ -1,38 +0,0 @@ -info: - component: Edge Server - -endpoints: - restart: - enabled: true - shutdown: - enabled: true - health: - sensitive: false - -zuul: - prefix: /api - routes: - account: - path: /account/** - serviceId: account-service - customer: - path: /customer/** - serviceId: customer-service - -ribbon: - eureka: - enabled: true - -eureka: - client: - serviceUrl: - defaultZone: http://discovery:8761/eureka/ - registerWithEureka: false - -server: - port: 8765 - -logging: - level: - ROOT: INFO - org.springframework.web: DEBUG \ No newline at end of file diff --git a/gateway-service/src/main/resources/bootstrap.yml b/gateway-service/src/main/resources/bootstrap.yml deleted file mode 100644 index d248a713..00000000 --- a/gateway-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,3 +0,0 @@ -spring: - application: - name: gateway-server \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 00000000..66192c96 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +## Microservices with Kubernetes and Docker [![Twitter](https://img.shields.io/twitter/follow/piotr_minkowski.svg?style=social&logo=twitter&label=Follow%20Me)](https://twitter.com/piotr_minkowski) + +Detailed description can be found here: [Microservices with Kubernetes and Docker](https://piotrminkowski.wordpress.com/2017/03/31/microservices-with-kubernetes-and-docker) diff --git a/src/main/script/deployment-account.yml b/src/main/script/deployment-account.yml new file mode 100644 index 00000000..47f11c62 --- /dev/null +++ b/src/main/script/deployment-account.yml @@ -0,0 +1,24 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: account-service + labels: + run: account-service +spec: + replicas: 1 + template: + metadata: + labels: + run: account-service + spec: + containers: + - name: account-service + image: piomin/account-service + ports: + - containerPort: 2222 + protocol: TCP + - name: mongo + image: library/mongo + ports: + - containerPort: 27017 + protocol: TCP \ No newline at end of file diff --git a/src/main/script/deployment-customer.yml b/src/main/script/deployment-customer.yml new file mode 100644 index 00000000..6f086ac4 --- /dev/null +++ b/src/main/script/deployment-customer.yml @@ -0,0 +1,24 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: customer-service + labels: + run: customer-service +spec: + replicas: 1 + template: + metadata: + labels: + run: customer-service + spec: + containers: + - name: customer-service + image: piomin/customer-service:1.1 + ports: + - containerPort: 3333 + protocol: TCP + - name: mongo + image: library/mongo + ports: + - containerPort: 27017 + protocol: TCP \ No newline at end of file diff --git a/src/main/script/ingress.yml b/src/main/script/ingress.yml new file mode 100644 index 00000000..1a2ce303 --- /dev/null +++ b/src/main/script/ingress.yml @@ -0,0 +1,20 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: gateway-ingress +spec: + backend: + serviceName: default-http-backend + servicePort: 80 + rules: + - host: micro.all + http: + paths: + - path: /account + backend: + serviceName: account-service + servicePort: 2222 + - path: /customer + backend: + serviceName: customer-service + servicePort: 3333 \ No newline at end of file diff --git a/src/main/script/service-account.yml b/src/main/script/service-account.yml new file mode 100644 index 00000000..50312cf2 --- /dev/null +++ b/src/main/script/service-account.yml @@ -0,0 +1,17 @@ +kind: Service +apiVersion: v1 +metadata: + name: account-service +spec: + selector: + run: account-service + ports: + - name: port1 + protocol: TCP + port: 2222 + targetPort: 2222 + - name: port2 + protocol: TCP + port: 27017 + targetPort: 27017 + type: NodePort \ No newline at end of file diff --git a/src/main/script/service-customer.yml b/src/main/script/service-customer.yml new file mode 100644 index 00000000..16459c14 --- /dev/null +++ b/src/main/script/service-customer.yml @@ -0,0 +1,17 @@ +kind: Service +apiVersion: v1 +metadata: + name: customer-service +spec: + selector: + run: customer-service + ports: + - name: port1 + protocol: TCP + port: 3333 + targetPort: 3333 + - name: port2 + protocol: TCP + port: 27017 + targetPort: 27017 + type: NodePort \ No newline at end of file diff --git a/zipkin-service/.gitignore b/zipkin-service/.gitignore deleted file mode 100644 index 8bd3a058..00000000 --- a/zipkin-service/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -/.settings/ -/.classpath -/.project diff --git a/zipkin-service/pom.xml b/zipkin-service/pom.xml deleted file mode 100644 index 7f0e8d76..00000000 --- a/zipkin-service/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - 4.0.0 - - pl.piomin - sample-spring-microservices - 1.0-SNAPSHOT - - zipkin-service - - - - io.zipkin.java - zipkin-server - 1.16.2 - - - io.zipkin.java - zipkin - 1.16.2 - - - io.zipkin.java - zipkin-autoconfigure-ui - 1.16.2 - - - - \ No newline at end of file diff --git a/zipkin-service/src/main/java/pl/piomin/microservices/zipkin/Application.java b/zipkin-service/src/main/java/pl/piomin/microservices/zipkin/Application.java deleted file mode 100644 index 31a96a40..00000000 --- a/zipkin-service/src/main/java/pl/piomin/microservices/zipkin/Application.java +++ /dev/null @@ -1,16 +0,0 @@ -package pl.piomin.microservices.zipkin; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import zipkin.server.EnableZipkinServer; - -@SpringBootApplication -@EnableZipkinServer -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/zipkin-service/src/main/resources/application.yml b/zipkin-service/src/main/resources/application.yml deleted file mode 100644 index 9197b732..00000000 --- a/zipkin-service/src/main/resources/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: ${PORT:9411}