From 273a7222d7d39d90cb5d837fb06cfe0e9def0713 Mon Sep 17 00:00:00 2001 From: alex289 Date: Thu, 3 Oct 2024 22:03:22 +0200 Subject: [PATCH] feat: Add Kubernetes config and ef otlp --- .../CleanArchitecture.Api.csproj | 1 + CleanArchitecture.Api/Program.cs | 1 + docker-compose.yml | 5 +- k8s-deployments/clean-architecture.yml | 8 +++- k8s-deployments/seq.yml | 47 +++++++++++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 k8s-deployments/seq.yml diff --git a/CleanArchitecture.Api/CleanArchitecture.Api.csproj b/CleanArchitecture.Api/CleanArchitecture.Api.csproj index 513f026..2a68bea 100644 --- a/CleanArchitecture.Api/CleanArchitecture.Api.csproj +++ b/CleanArchitecture.Api/CleanArchitecture.Api.csproj @@ -27,6 +27,7 @@ + diff --git a/CleanArchitecture.Api/Program.cs b/CleanArchitecture.Api/Program.cs index 3fbec2b..6546b3f 100644 --- a/CleanArchitecture.Api/Program.cs +++ b/CleanArchitecture.Api/Program.cs @@ -91,6 +91,7 @@ builder.Services .WithTracing(tracing => { tracing + .AddEntityFrameworkCoreInstrumentation() .AddHttpClientInstrumentation() .AddAspNetCoreInstrumentation() .AddSource(MassTransit.Logging.DiagnosticHeaders.DefaultListenerName); diff --git a/docker-compose.yml b/docker-compose.yml index c05ebab..d861584 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,8 @@ services: depends_on: db: condition: service_started + seq: + condition: service_started redis: condition: service_started rabbitmq: @@ -22,8 +24,9 @@ services: - Kestrel__Endpoints__Grpc__Url=http://+:8080 - Kestrel__Endpoints__Grpc__Protocols=Http2 - ConnectionStrings__DefaultConnection=Server=db;Database=clean-architecture;Trusted_Connection=False;MultipleActiveResultSets=true;TrustServerCertificate=True;User Id=SA;Password=Password123!# - - OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5341/ingest/otlp/v1/traces + - OTEL_EXPORTER_OTLP_ENDPOINT=http://seq:5341/ingest/otlp/v1/traces - OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf + - Serilog__WriteTo__1__Args__serverUrl=http://seq:5341 healthcheck: test: ["CMD", "curl", "--fail", "http://localhost/healthz"] interval: 30s diff --git a/k8s-deployments/clean-architecture.yml b/k8s-deployments/clean-architecture.yml index 92a8910..14179bd 100644 --- a/k8s-deployments/clean-architecture.yml +++ b/k8s-deployments/clean-architecture.yml @@ -42,4 +42,10 @@ spec: - name: Kestrel__Endpoints__Grpc__Protocols value: Http2 - name: ConnectionStrings__DefaultConnection - value: Server=sql-server;Database=clean-architecture;Trusted_Connection=False;MultipleActiveResultSets=true;TrustServerCertificate=True;User Id=SA;Password=Password123!# \ No newline at end of file + value: Server=sql-server;Database=clean-architecture;Trusted_Connection=False;MultipleActiveResultSets=true;TrustServerCertificate=True;User Id=SA;Password=Password123!# + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://seq:5341/ingest/otlp/v1/traces + - name: OTEL_EXPORTER_OTLP_PROTOCOL + value: http/protobuf + - name: Serilog__WriteTo__1__Args__serverUrl + value: http://seq:5341 \ No newline at end of file diff --git a/k8s-deployments/seq.yml b/k8s-deployments/seq.yml new file mode 100644 index 0000000..c442a51 --- /dev/null +++ b/k8s-deployments/seq.yml @@ -0,0 +1,47 @@ +apiVersion: v1 +kind: Service +metadata: + name: seq +spec: + selector: + app: seq + ports: + - name: seq + protocol: TCP + port: 5341 + targetPort: 5341 + - name: seq-frontend + protocol: TCP + port: 8081 + targetPort: 80 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: seq-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: seq + template: + metadata: + labels: + app: seq + spec: + containers: + - name: seq + image: datalust/seq:latest + env: + - name: ACCEPT_EULA + value: "y" + ports: + - containerPort: 5341 + - containerPort: 80 + volumeMounts: + - name: seq-data + mountPath: /data + volumes: + - name: seq-data + emptyDir: {} \ No newline at end of file