Skip to content

Commit

Permalink
feat: add application.properties as volume mount to the petclinic pod
Browse files Browse the repository at this point in the history
  • Loading branch information
tilanis committed Jun 14, 2024
1 parent 46e550f commit 8b71558
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ TODO: add explanation of why this or not other component

## Petclinic

We're using a modified Spring Petclinic image for demo purposes. We've added a property `logging.pattern.level = trace_id=%mdc{trace_id} span_id=%mdc{span_id} trace_flags=%mdc{trace_flags} %5p` in `src/main/resources/application.properties` file to allow for adding traceid and spanid to logs, which lets Grafana link logs and traces with each other.
In order to allow Grafana link logs and traces with each other, we've added a property `logging.pattern.level = trace_id=%mdc{trace_id} span_id=%mdc{span_id} trace_flags=%mdc{trace_flags} %5p` in `src/main/resources/application.properties` file which includes traceid and spanid in logs.
54 changes: 53 additions & 1 deletion try-me/observability/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,44 @@ export default async () => {
chartRepositoryUrl: "https://prometheus-community.github.io/helm-charts"
});

let applicationProperties = `
# database init, supports mysql too
database=h2
spring.sql.init.schema-locations=classpath*:db/\${database}/schema.sql
spring.sql.init.data-locations=classpath*:db/\${database}/data.sql
# Web
spring.thymeleaf.mode=HTML
# JPA
spring.jpa.hibernate.ddl-auto=none
spring.jpa.open-in-view=true
# Internationalization
spring.messages.basename=messages/messages
# Actuator
management.endpoints.web.exposure.include=*
# Logging
logging.level.org.springframework=INFO
logging.pattern.level = trace_id=%mdc{trace_id} span_id=%mdc{span_id} trace_flags=%mdc{trace_flags} %5p
# logging.level.org.springframework.web=DEBUG
# logging.level.org.springframework.context.annotation=TRACE
# Maximum time static resources should be cached
spring.web.resources.cache.cachecontrol.max-age=12h
`;

new k8s.core.v1.ConfigMap("application-properties", {
metadata: {
name: "application-properties"
},
data: {
"application.properties": applicationProperties
}
})

new k8s.apps.v1.Deployment("petclinic", {
metadata: {
name: "petclinic",
Expand All @@ -128,11 +166,25 @@ export default async () => {
},
spec: {
containers: [{
image: "softwaremill/spring-petclinic-docker-meerkat:0.0.1",
image: "softwaremill/spring-petclinic:0.0.1",
name: "petclinic",
ports: [{
containerPort: 8080,
}],
volumeMounts: [{
mountPath: "/src/main/resources/",
name: "application-properties"
}],
}],
volumes: [{
name: "application-properties",
configMap: {
name: "application-properties",
items: [{
key: "application.properties",
path: "application.properties"
}],
}
}],
},
},
Expand Down

0 comments on commit 8b71558

Please sign in to comment.