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

Add spring-petclinic app as a demo #34

Merged
merged 8 commits into from
Jun 17, 2024
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: 4 additions & 0 deletions docs/Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ TODO: add explanation of why this or not other component
- [Grafana Mimir](https://grafana.com/oss/mimir/)
- [Grafana Tempo](https://grafana.com/oss/tempo/)
- [Prometheus](https://prometheus.io/)

## Petclinic

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.
102 changes: 101 additions & 1 deletion try-me/observability/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,107 @@ export default async () => {
chartValuesPath: "./charts_values/kube_state_metrics_values.yaml",
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",
labels: {
app: "petclinic",
},
},
spec: {
replicas: 1,
selector: {
matchLabels: {
app: "petclinic",
},
},
template: {
metadata: {
labels: {
app: "petclinic",
},
},
spec: {
containers: [{
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"
}],
}
}],
},
},
},
});

new k8s.core.v1.Service("petclinic", {
metadata: {
name: "petclinic",
},
spec: {
ports: [{
port: 8080,
protocol: "TCP",
targetPort: 8080,
}],
selector: {
app: "petclinic",
},
}});

// TODO: further installed chart processing if required

// return Pulumi outputs
Expand Down