Skip to content
Open
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
2 changes: 2 additions & 0 deletions pay-app-spring-microservices/app-invoice/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

# Consul
spring.cloud.consul.host=consul
spring.cloud.consul.port=8500
spring.cloud.consul.discovery.health-check-interval=5s
spring.cloud.consul.discovery.prefer-ip-address=true
3 changes: 3 additions & 0 deletions pay-app-spring-microservices/app-pay/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

# Consul
spring.cloud.consul.host=consul
spring.cloud.consul.port=8500
spring.cloud.consul.discovery.health-check-interval=5s
spring.cloud.consul.discovery.prefer-ip-address=true
3 changes: 3 additions & 0 deletions pay-app-spring-microservices/app-transaction/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

# Consul
spring.cloud.consul.host=consul
spring.cloud.consul.port=8500
spring.cloud.consul.discovery.health-check-interval=5s
spring.cloud.consul.discovery.prefer-ip-address=true
53 changes: 46 additions & 7 deletions pay-app-spring-microservices/appgw/gateway.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@ admin:
port: 9876
host: localhost
apiEndpoints:
appconfig:
app-config:
host: localhost
paths: ['/config','/config/*']
paths: ['/app-config','/app-config/*']
app-invoice:
host: localhost
paths: ['/app-invoice','/app-invoice/*']
app-pay:
host: localhost
paths: ['/app-pay','/app-pay/*']
app-transaction:
host: localhost
paths: ['/app-transaction','/app-transaction/*']
serviceEndpoints:
appconfig:
url: 'http://loadbalancer/config/'
app-config:
url: 'http://loadbalancer/app-config/'
app-invoice:
url: 'http://loadbalancer/app-invoice/'
app-pay:
url: 'http://loadbalancer/app-pay/'
app-transaction:
url: 'http://loadbalancer/app-transaction/'
policies:
- basic-auth
- cors
Expand All @@ -22,14 +37,38 @@ policies:
pipelines:
default:
apiEndpoints:
- appconfig
- app-config
- app-pay
- app-transaction
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
- key-auth:
- proxy:
- action:
serviceEndpoint: appconfig
serviceEndpoint: app-config
changeOrigin: true
prependPath: false
ignorePath: false
stripPath: false
- action:
serviceEndpoint: app-pay
changeOrigin: true
prependPath: false
ignorePath: false
stripPath: false
- action:
serviceEndpoint: app-transaction
changeOrigin: true
prependPath: false
ignorePath: false
stripPath: false
dmz:
apiEndpoints:
- app-invoice
policies:
- proxy:
- action:
serviceEndpoint: app-invoice
changeOrigin: true
prependPath: false
ignorePath: false
stripPath: false
3 changes: 3 additions & 0 deletions pay-app-spring-microservices/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ eg credentials create -c sebas -t key-auth -q
curl -H "Authorization: apiKey ${keyId}:${keySecret}" http://localhost:8080/config/app-pay/dev

curl -H "Authorization: apiKey 3DvE2HCfZCyfgxAjF40tOk:2U4Cojm11JaPJF6WRUcFBL" http://localhost:8080/config/app-pay/dev
curl -H "Authorization: apiKey 7AzWybVM0FaB7mTRadNUGR:5N50F0YcQ7U45JcD5C7J32" http://localhost:8080/app-config/app-pay/dev

7AzWybVM0FaB7mTRadNUGR:5N50F0YcQ7U45JcD5C7J32
48 changes: 33 additions & 15 deletions pay-app-spring-microservices/haproxy/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ frontend stats
frontend http_front
bind *:80
mode http
acl url_config path_beg /config
use_backend config_back if url_config
acl url_app-config path_beg /app-config
use_backend app-config-backend if url_app-config
acl url_app-invoice path_beg /app-invoice
use_backend app-invoice-backend if url_app-invoice
acl url_app-pay path_beg /app-pay
use_backend app-pay-backend if url_app-pay
acl url_app-transaction path_beg /app-transaction
use_backend app-transaction-backend if url_app-transaction

default_backend http_back
backend app-config-backend
mode http
balance roundrobin
http-request set-path "%[path,regsub(^/app-config/,/)]"
server app-config app-config.service.consul:8888 resolvers consul resolve-prefer ipv4 check

backend app-invoice-backend
mode http
balance roundrobin
http-request set-path "%[path,regsub(^/app-invoice/,/)]"
server app-invoice app-invoice.service.consul:8006 resolvers consul resolve-prefer ipv4 check

backend config_back
mode http
balance roundrobin
http-request set-path "%[path,regsub(^/config/,/)]"
server appconfig app-config.service.consul:8888 resolvers consul resolve-prefer ipv4 check
backend http_back
mode http
balance roundrobin
server-template mywebapp 1-10 _web._tcp.service.consul resolvers consul resolve-prefer ipv4 check
backend app-pay-backend
mode http
balance roundrobin
http-request set-path "%[path,regsub(^/app-pay/,/)]"
server app-pay app-pay.service.consul:8010 resolvers consul resolve-prefer ipv4 check

backend app-transaction-backend
mode http
balance roundrobin
http-request set-path "%[path,regsub(^/app-transaction/,/)]"
server app-transaction app-transaction.service.consul:8082 resolvers consul resolve-prefer ipv4 check

resolvers consul
nameserver consul consul:8600
accepted_payload_size 8192
hold valid 5s
nameserver consul consul:8600
accepted_payload_size 8192
hold valid 5s
4 changes: 2 additions & 2 deletions pay-app-spring-microservices/resources/postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ FROM postgres:12-alpine

env POSTGRES_PASSWORD=postgres
env POSTGRES_DB=db_invoice
COPY ./postgres.sql /docker-entrypoint-initdb.d

COPY ./1-postgres.sql /docker-entrypoint-initdb.d
COPY ./2-data.sql /docker-entrypoint-initdb.d