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

#68 Add Spring Cloud Load Balancing #72

Merged
merged 2 commits into from
Jan 13, 2025
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
4 changes: 2 additions & 2 deletions backend/authik/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ spring:
application:
name: authik
datasource:
url: jdbc:postgresql://authik-database:5432/${POSTGRES_DB}
url: jdbc:postgresql://authik-database-primary.dating.se.ifmo.ru:5432/${POSTGRES_DB}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
r2dbc:
url: r2dbc:postgresql://authik-database:5432/${POSTGRES_DB}
url: r2dbc:postgresql://authik-database-primary.dating.se.ifmo.ru:5432/${POSTGRES_DB}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
security:
Expand Down
4 changes: 2 additions & 2 deletions backend/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ kotlin {

dependencies {
val kotlinVersion = "2.0.10"
val jooqVersion = "3.19.15"
val jooqVersion = "3.19.17"

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")

implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.7")

implementation("org.openapitools:openapi-generator-gradle-plugin:7.9.0")
implementation("org.openapitools:openapi-generator-gradle-plugin:7.10.0")

implementation("org.jooq:jooq-codegen:$jooqVersion")
implementation("org.jooq:jooq-codegen-gradle:$jooqVersion")
Expand Down
2 changes: 1 addition & 1 deletion backend/config/crypto/ca.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ST = Saint-Petersburg
L = Saint-Petersburg
O = ITMO Dating
OU = IT
CN = ITMO Dating Root CA
CN = *.dating.se.ifmo.ru

[v3_ca]
subjectKeyIdentifier = hash
Expand Down
16 changes: 11 additions & 5 deletions backend/config/crypto/csr.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ ST = Saint-Petersburg
L = Saint-Petersburg
O = ITMO Dating
OU = IT
CN = dating.se.ifmo.ru
CN = *.dating.se.ifmo.ru

[req_ext]
subjectAltName = @alt_names

[alt_names]
DNS.1 = localhost
DNS.2 = authik
DNS.3 = matchmaker
DNS.4 = people
DNS.5 = server.dc1.consul
DNS.2 = authik-0.dating.se.ifmo.ru
DNS.3 = authik-1.dating.se.ifmo.ru
DNS.4 = authik-2.dating.se.ifmo.ru
DNS.5 = matchmaker-0.dating.se.ifmo.ru
DNS.6 = matchmaker-1.dating.se.ifmo.ru
DNS.7 = matchmaker-2.dating.se.ifmo.ru
DNS.8 = people-0.dating.se.ifmo.ru
DNS.9 = people-1.dating.se.ifmo.ru
DNS.10 = people-2.dating.se.ifmo.ru
DNS.11 = server.dc1.consul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.ifmo.se.dating.spring.api

import io.netty.handler.ssl.SslContext
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.client.reactive.ReactorClientHttpConnector
Expand All @@ -12,6 +13,7 @@ class WebClientBuilderConfig(
private val ssl: SslContext,
) {
@Bean
@LoadBalanced
fun webClientBuilder() = WebClient.builder()
.clientConnector(
ReactorClientHttpConnector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ security:
public: ${TOKEN_SIGN_KEY_PUBLIC}
logging:
level:
web: DEBUG
org.springframework.cloud.consul: DEBUG
web: INFO
26 changes: 13 additions & 13 deletions backend/gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,85 +8,85 @@ spring:
routes:

- id: get-authik-openapi-api-yml
uri: https://authik:8080
uri: lb://authik
predicates:
- Method=GET
- Path=/openapi/authik/api.yml
filters:
- RewritePath=/openapi/authik/api.yml, /openapi/api.yml

- id: get-matchmaker-openapi-api-yml
uri: https://matchmaker:8080
uri: lb://matchmaker
predicates:
- Method=GET
- Path=/openapi/matchmaker/api.yml
filters:
- RewritePath=/openapi/matchmaker/api.yml, /openapi/api.yml

- id: get-people-openapi-api-yml
uri: https://people:8080
uri: lb://people
predicates:
- Method=GET
- Path=/openapi/people/api.yml
filters:
- RewritePath=/openapi/people/api.yml, /openapi/api.yml

- id: put-authik-auth-telegram-web-app
uri: https://authik:8080
uri: lb://authik
predicates:
- Method=PUT
- Path=/api/auth/telegram/web-app

- id: get-matchmaker-suggestions
uri: https://matchmaker:8080
uri: lb://matchmaker
predicates:
- Method=GET
- Path=/api/suggestions

- id: post-matchmaker-people-attitudes-incoming
uri: https://matchmaker:8080
uri: lb://matchmaker
predicates:
- Method=POST
- Path=/api/people/*/attitudes/incoming/*

- id: delete-matchmaker-attitudes
uri: https://matchmaker:8080
uri: lb://matchmaker
predicates:
- Method=DELETE
- Path=/api/attitudes

- id: get-matchmaker-people-matches
uri: https://matchmaker:8080
uri: lb://matchmaker
predicates:
- Method=GET
- Path=/api/people/{person_id}/matches

- id: get-people-person-id
uri: https://people:8080
uri: lb://people
predicates:
- Method=GET
- Path=/api/people/*

- id: delete-people-person-id
uri: https://people:8080
uri: lb://people
predicates:
- Method=DELETE
- Path=/api/people/*

- id: patch-people-person-id
uri: https://people:8080
uri: lb://people
predicates:
- Method=PATCH
- Path=/api/people/*

- id: get-people-faculties
uri: https://people:8080
uri: lb://people
predicates:
- Method=GET
- Path=/api/faculties

- id: get-people-locations
uri: https://people:8080
uri: lb://people
predicates:
- Method=GET
- Path=/api/locations
Expand Down
7 changes: 4 additions & 3 deletions backend/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ org-springframework-boot-spring-boot = "3.4.1"
org-springframework-spring = "6.2.1"
org-springframework-cloud = "4.2.0"

io-swagger-core-v3-swagger = "2.2.25"
io-swagger-core-v3-swagger = "2.2.27"
org-openapitools-jackson-databind-nullable = "0.2.6"
org-springdoc-springdoc-openapi-starter = "2.6.0"
org-springdoc-springdoc-openapi-starter = "2.8.2"

io-jsonwebtoken = "0.12.6"

Expand All @@ -14,7 +14,7 @@ org-liquibase-liquibase-core = "4.29.2"
org-postgresql-postgresql = "42.7.4"
org-postgresql-r2dbc-postgresql = "1.0.7.RELEASE"

com-fasterxml-jackson = "2.18.1"
com-fasterxml-jackson = "2.18.2"

jakarta-validation-jakarta-validation-api = "3.1.0"
commons-codec-commons-codec = "1.17.1"
Expand All @@ -39,6 +39,7 @@ org-springframework-spring-web = { module = "org.springframework:spring-web", ve

org-springframework-cloud-spring-cloud-starter-gateway = { module = "org.springframework.cloud:spring-cloud-starter-gateway", version.ref = "org-springframework-cloud" }
org-springframework-cloud-spring-cloud-starter-consul-discovery = { module = "org.springframework.cloud:spring-cloud-starter-consul-discovery", version.ref = "org-springframework-cloud" }
org-springframework-cloud-spring-cloud-starter-loadbalancer = { module = "org.springframework.cloud:spring-cloud-starter-loadbalancer", version.ref = "org-springframework-cloud" }

org-springdoc-springdoc-openapi-starter-webflux-ui = { module = "org.springdoc:springdoc-openapi-starter-webflux-ui", version.ref = "org-springdoc-springdoc-openapi-starter" }

Expand Down
4 changes: 2 additions & 2 deletions backend/matchmaker/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ spring:
application:
name: matchmaker
datasource:
url: jdbc:postgresql://matchmaker-database:5432/${POSTGRES_DB}
url: jdbc:postgresql://matchmaker-database-primary.dating.se.ifmo.ru:5432/${POSTGRES_DB}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
r2dbc:
url: r2dbc:postgresql://matchmaker-database:5432/${POSTGRES_DB}
url: r2dbc:postgresql://matchmaker-database-primary.dating.se.ifmo.ru:5432/${POSTGRES_DB}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
6 changes: 3 additions & 3 deletions backend/people/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ spring:
application:
name: people
datasource:
url: jdbc:postgresql://people-database:5432/${POSTGRES_DB}
url: jdbc:postgresql://people-database-primary.dating.se.ifmo.ru:5432/${POSTGRES_DB}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
r2dbc:
url: r2dbc:postgresql://people-database:5432/${POSTGRES_DB}
url: r2dbc:postgresql://people-database-primary.dating.se.ifmo.ru:5432/${POSTGRES_DB}
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
service:
matchmaker:
url: https://matchmaker:8080/api
url: https://matchmaker/api
4 changes: 0 additions & 4 deletions backend/people/src/main/resources/static/openapi/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ paths:
schema:
type: string
format: date
maxLength: 32
example: 1990-01-01
- name: birthday_max
in: query
Expand All @@ -136,7 +135,6 @@ paths:
schema:
type: string
format: date
maxLength: 32
example: 2000-12-31
- name: zodiac
in: query
Expand Down Expand Up @@ -406,7 +404,6 @@ components:
type: string
description: A date when person was born
format: date
maxLength: 32
facultyId:
$ref: "#/components/schemas/FacultyId"
locationId:
Expand Down Expand Up @@ -631,7 +628,6 @@ components:
type: string
format: date-time
description: A moment when this object was updated, autogenerated
maxLength: 32
example: 2024-04-14T13:32:42Z
RegexPattern:
type: string
Expand Down
1 change: 1 addition & 0 deletions backend/starter-service-discovery/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ plugins {
dependencies {
api(libs.org.springframework.boot.spring.boot.starter.actuator)
api(libs.org.springframework.cloud.spring.cloud.starter.consul.discovery)
api(libs.org.springframework.cloud.spring.cloud.starter.loadbalancer)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spring:
discovery:
enabled: true
scheme: https
instance-id: ${spring.application.name}:${HOSTNAME}
instance-id: instance-${HOSTNAME}
heartbeat:
enabled: true
management:
Expand Down
Loading
Loading