Skip to content

Commit

Permalink
Opentelemetry (#4215)
Browse files Browse the repository at this point in the history
### 💰 Hva skal gjøres, og hvorfor?
Tester opentelemetry og distroless image.

Dette skal ta over for appdynamics ref 
https://nav-it.slack.com/archives/C01DE3M9YBV/p1695905476412559

---------

Co-authored-by: Stig Strøm <[email protected]>
  • Loading branch information
hensol and stigebil authored Jan 15, 2024
1 parent 815ae5b commit 025af5b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
18 changes: 15 additions & 3 deletions .deploy/nais/app-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
labels:
team: teamfamilie
annotations:
nais.io/run-as-group: "65532"
nais.io/run-as-user: "65532"
nginx.ingress.kubernetes.io/proxy-next-upstream-tries: '1'
spec:
envFrom:
Expand All @@ -25,6 +27,9 @@ spec:
prometheus:
enabled: true
path: /internal/prometheus
observability:
tracing:
enabled: true
gcp: # Database
sqlInstances:
- type: POSTGRES_15 # IF This is changed, all data will be lost. Read on nais.io how to upgrade
Expand Down Expand Up @@ -132,9 +137,16 @@ spec:
env:
- name: SPRING_PROFILES_ACTIVE
value: preprod

- name: JAVA_OPTS
value: "-XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=75.0 -XX:+HeapDumpOnOutOfMemoryError"
- name: OTEL_METRICS_EXPORTER
value: prometheus
- name: OTEL_LOGS_EXPORTER
value: none
- name: OTEL_TRACES_EXPORTER
value: otlp
- name: OTEL_EXPORTER_METRICS_ENABLED
value: "false"
- name: OTEL_METRICS_EXEMPLAR_FILTER
value: ALWAYS_ON
kafka:
pool: nav-dev
strategy:
Expand Down
18 changes: 15 additions & 3 deletions .deploy/nais/app-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
labels:
team: teamfamilie
annotations:
nais.io/run-as-group: "65532"
nais.io/run-as-user: "65532"
nginx.ingress.kubernetes.io/proxy-next-upstream-tries: '1'
nginx.ingress.kubernetes.io/proxy-read-timeout: "180"
nginx.ingress.kubernetes.io/proxy-send-timeout: "180"
Expand All @@ -28,6 +30,9 @@ spec:
prometheus:
enabled: true
path: /internal/prometheus
observability:
tracing:
enabled: true
gcp: # Database
sqlInstances:
- type: POSTGRES_15 # Read nais doc and https://github.com/navikt/familie/blob/master/doc/Google%20cloud/oppgrader-database.md on how to upgrade
Expand Down Expand Up @@ -128,9 +133,16 @@ spec:
env:
- name: SPRING_PROFILES_ACTIVE
value: prod

- name: JAVA_OPTS
value: "-XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=75.0 -XX:+HeapDumpOnOutOfMemoryError"
- name: OTEL_METRICS_EXPORTER
value: prometheus
- name: OTEL_LOGS_EXPORTER
value: none
- name: OTEL_TRACES_EXPORTER
value: otlp
- name: OTEL_EXPORTER_METRICS_ENABLED
value: "false"
- name: OTEL_METRICS_EXEMPLAR_FILTER
value: ALWAYS_ON
kafka:
pool: nav-prod
strategy:
Expand Down
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM ghcr.io/navikt/baseimages/temurin:21
FROM busybox:1.36.1-uclibc as busybox
# Download opentelemetry-javaagent
# https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/
FROM scratch as javaagent
ARG JAVA_OTEL_VERSION=v1.32.0
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/$JAVA_OTEL_VERSION/opentelemetry-javaagent.jar /instrumentations/java/javaagent.jar

ENV APPD_ENABLED=true
ENV APP_NAME=familie-ba-sak
# Final image
FROM gcr.io/distroless/java21:nonroot
COPY --from=javaagent --chown=nonroot:nonroot /instrumentations/java/javaagent.jar /app/javaagent.jar
COPY --from=busybox /bin/printenv /bin/printenv
COPY --chown=nonroot:nonroot ./target/familie-ba-sak.jar /app/app.jar
WORKDIR /app

COPY ./target/familie-ba-sak.jar "app.jar"
ENV APP_NAME=familie-ba-sak
ENV TZ="Europe/Oslo"
# TLS Config works around an issue in OpenJDK... See: https://github.com/kubernetes-client/java/issues/854
ENTRYPOINT [ "java", "-javaagent:/app/javaagent.jar", "-Djdk.tls.client.protocols=TLSv1.2", "-jar", "/app/app.jar", "-XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=75.0 -XX:+HeapDumpOnOutOfMemoryError" ]

2 changes: 1 addition & 1 deletion src/test/resources/hentMiljøvariabler.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kubectl config use-context dev-gcp
PODNAVN=$(kubectl -n teamfamilie get pods --field-selector=status.phase==Running -o name | grep familie-ba-sak | grep -v "frontend" | sed "s/^.\{4\}//" | head -n 1);

PODVARIABLER="$(kubectl -n teamfamilie exec -c familie-ba-sak -it "$PODNAVN" -- env)"
PODVARIABLER="$(kubectl -n teamfamilie exec -c familie-ba-sak -it "$PODNAVN" -- printenv)"
UNLEASH_VARIABLER="$(kubectl -n teamfamilie get secret familie-ba-sak-unleash-api-token -o json | jq '.data | map_values(@base64d)')"

AZURE_APP_CLIENT_ID="$(echo "$PODVARIABLER" | grep "AZURE_APP_CLIENT_ID" | tr -d '\r' )"
Expand Down

0 comments on commit 025af5b

Please sign in to comment.