spring-35-36 cloud

This commit is contained in:
petrelevich
2025-06-19 10:30:27 +03:00
parent 752285b281
commit 2d6ba68002
11 changed files with 88 additions and 183 deletions
@@ -6,6 +6,7 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("org.springframework.cloud:spring-cloud-starter-config")
implementation("org.springframework.cloud:spring-cloud-starter-gateway")
implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
@@ -1,52 +1,15 @@
spring:
application:
name: api-gateway
server:
port: 7777
application:
api-routes:
- id: "service-client"
from: "client"
to: "lb://SERVICE-CLIENT"
- id: "service-order"
from: "order"
to: "lb://SERVICE-ORDER"
eureka:
client:
registerWithEureka: false
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:9999/eureka/
instance:
lease-renewal-interval-in-seconds: 30
metadataMap:
zone: zone1
management:
tracing:
sampling:
probability: 1.0
endpoint:
prometheus:
enabled: true
metrics:
enabled: true
health:
enabled: true
probes:
enabled: true
refresh:
enabled: true
endpoints:
web:
exposure:
include:
- prometheus
- health
- metrics
- refresh
enabled-by-default: false
cloud:
config:
fail-fast: true
retry:
initial-interval: 5000
max-attempts: 10
max-interval: 5000
multiplier: 1.2
config:
import: optional:configserver:http://localhost:8888
codec:
max-in-memory-size: 10MB
@@ -1,3 +1,7 @@
plugins {
id("com.google.cloud.tools.jib")
}
dependencies {
implementation(project(":kafka-log-appender"))
implementation("net.logstash.logback:logstash-logback-encoder")
@@ -10,3 +14,24 @@ dependencies {
implementation("io.micrometer:micrometer-tracing-bridge-otel") // bridges the Micrometer Observation API to OpenTelemetry.
implementation("io.opentelemetry:opentelemetry-exporter-zipkin") // reports traces to Zipkin.
}
jib {
container {
creationTime.set("USE_CURRENT_TIMESTAMP")
}
from {
image = "bellsoft/liberica-openjdk-alpine-musl:21.0.1"
}
to {
image = "localrun/config-server"
tags = setOf(project.version.toString())
}
}
tasks {
build {
dependsOn(spotlessApply)
dependsOn(jibBuildTar)
}
}
@@ -1,27 +1,16 @@
#!/bin/bash
../gradlew :service-order:build
../gradlew :config-server:build
docker load --input build/jib-image.tar
docker stop service-order-1
docker stop service-order-2
docker stop config-server
docker run --rm -d --name service-order-1 \
docker run --rm -d --name config-server \
--memory=256m \
--cpus 1 \
--network="host" \
-v $HOME/.ssh:/root/.ssh \
-e JAVA_TOOL_OPTIONS="-XX:InitialRAMPercentage=80 -XX:MaxRAMPercentage=80" \
-e SPRING_APPLICATION_INSTANCE_ID="i1" \
-e SERVER_PORT=8091 \
localrun/service-order:latest
docker run --rm -d --name service-order-2 \
--memory=256m \
--cpus 1 \
--network="host" \
-e JAVA_TOOL_OPTIONS="-XX:InitialRAMPercentage=80 -XX:MaxRAMPercentage=80" \
-e SPRING_APPLICATION_INSTANCE_ID="i2" \
-e SERVER_PORT=8092 \
localrun/service-order:latest
localrun/config-server:latest
@@ -9,9 +9,11 @@ spring:
server:
git:
uri: "git@github.com:OtusTeam/Spring.git"
search-paths: "2024-11/spring-35-36-spring-cloud/git-config"
search-paths: "2025-01/spring-35-36-spring-cloud/git-config"
ignoreLocalSshSettings: false
strictHostKeyChecking: false
defaultLabel: "master"
management:
tracing:
sampling:
@@ -6,8 +6,8 @@ services:
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node1 # Name the node that will run in this container
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
- discovery.seed_hosts=opensearch-node1 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1 # Nodes eligibile to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
@@ -26,29 +26,6 @@ services:
- 9600:9600 # Performance Analyzer
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
opensearch-node2:
image: opensearchproject/opensearch:2.18.0
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node2 # Name the node that will run in this container
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables Security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data # Creates volume called opensearch-data2 and mounts it to the container
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:2.18.0
container_name: opensearch-dashboards
@@ -63,7 +40,6 @@ services:
- opensearch-net
#logstash
logstash:
image: opensearchproject/logstash-oss-with-opensearch-output-plugin:7.16.2
container_name: logstash
@@ -105,6 +81,8 @@ services:
network_mode: "host"
environment:
DYNAMIC_CONFIG_ENABLED: 'true'
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: localhost:9092
zipkin:
container_name: zipkin
@@ -113,31 +91,8 @@ services:
expose:
- "9411"
prometheus:
image: bitnami/prometheus:3.0.1
container_name: prometheus
network_mode: "host"
expose:
- "9090"
volumes:
- type: bind
source: ./prometheus.yml
target: /etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana-enterprise:11.4.0
container_name: grafana
network_mode: "host"
expose:
- "3000"
environment:
GF_SECURITY_ADMIN_USER: "grafana"
GF_SECURITY_ADMIN_PASSWORD: "grafana"
volumes:
opensearch-data1:
opensearch-data2:
networks:
opensearch-net:
@@ -1,3 +1,7 @@
plugins {
id("com.google.cloud.tools.jib")
}
dependencies {
implementation(project(":kafka-log-appender"))
implementation("net.logstash.logback:logstash-logback-encoder")
@@ -5,9 +9,30 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation ("org.springframework.cloud:spring-cloud-config-server")
implementation("org.springframework.cloud:spring-cloud-starter-config")
implementation ("org.springframework.cloud:spring-cloud-starter-netflix-eureka-server")
implementation("io.micrometer:micrometer-tracing-bridge-otel") // bridges the Micrometer Observation API to OpenTelemetry.
implementation("io.opentelemetry:opentelemetry-exporter-zipkin") // reports traces to Zipkin.
}
jib {
container {
creationTime.set("USE_CURRENT_TIMESTAMP")
}
from {
image = "bellsoft/liberica-openjdk-alpine-musl:21.0.1"
}
to {
image = "localrun/eureka-server"
tags = setOf(project.version.toString())
}
}
tasks {
build {
dependsOn(spotlessApply)
dependsOn(jibBuildTar)
}
}
@@ -1,42 +1,17 @@
spring:
application:
name: eureka-server
server:
port: 9999
cloud:
config:
fail-fast: true
retry:
initial-interval: 5000
max-attempts: 10
max-interval: 5000
multiplier: 1.2
config:
import: optional:configserver:http://localhost:8888
codec:
max-in-memory-size: 10MB
eureka:
server:
renewal-percent-threshold: 0.5
instance:
hostname: localhost
lease-expiration-duration-in-seconds: 90
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
management:
tracing:
sampling:
probability: 1.0
endpoint:
prometheus:
enabled: true
metrics:
enabled: true
health:
enabled: true
probes:
enabled: true
refresh:
enabled: true
endpoints:
web:
exposure:
include:
- prometheus
- health
- metrics
- refresh
enabled-by-default: false
@@ -14,14 +14,3 @@ spring:
codec:
max-in-memory-size: 10MB
eureka:
client:
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:9999/eureka/
instance:
lease-renewal-interval-in-seconds: 30
metadataMap:
zone: zone1
@@ -14,14 +14,5 @@ spring:
codec:
max-in-memory-size: 10MB
eureka:
client:
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:9999/eureka/
instance:
lease-renewal-interval-in-seconds: 30
metadataMap:
zone: zone1
@@ -15,14 +15,4 @@ spring:
codec:
max-in-memory-size: 10MB
eureka:
client:
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:9999/eureka/
instance:
instance-id: service-order:${spring.application.instance_id:0}
lease-renewal-interval-in-seconds: 30
metadataMap:
zone: zone1