I am trying to enable performance diagnostics for an application deployed on a kubernetes(GKE) cluster using dotnet-trace and dotnet counters. For doing this I am adding a performance diagnostic sidecar with my application container. diagnostics.Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS tools
RUN dotnet tool install --tool-path /tools dotnet-trace
RUN dotnet tool install --tool-path /tools dotnet-counters
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS runtime
COPY --from=tools /tools /tools
ENV PATH="/tools:${PATH}"
ENV COMPlus_EnableDiagnostics="0"
WORKDIR /tools
The app that I am using here is a simple hello world app. This is how I am deploying these containers on GKE: deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-dotnet-diagnostics
spec:
replicas: 1
selector:
matchLabels:
app: demo-diagnostics
template:
metadata:
labels:
app: demo-diagnostics
spec:
shareProcessNamespace: true
containers:
- name: demo-app
image: gcr.io/qp-fda-mystudies-2020-07/dotnetapp:latest
ports:
- containerPort: 8080
volumeMounts:
- name: dotnet-diagnostics
mountPath: /tmp
- name: demo-diagnostics
image: gcr.io/qp-fda-mystudies-2020-07/diagnostics:latest
stdin: true
tty: true
command: ["/bin/sh","-c"]
args: ["dotnet-trace collect -p 1; dotnet-counters monitor -p 1"]
volumeMounts:
- name: dotnet-diagnostics
mountPath: /tmp
volumes:
- name: dotnet-diagnostics
emptyDir: {}
The problem I am facing here is the diagnostics container keeps on running into crashloopbackoff. The error I am getting here is: Failed to start the counter session: Microsoft.Diagnostics.NETCore.Client.ServerNotAvailableException: Process 1 not running compatible .NET runtime. I have been following these articles and threads: https://github.com/dotnet/diagnostics/issues/810 and https://im5tu.io/article/2020/01/diagnostics-in-.net-core-3-using-dotnet-counters-with-docker/ The goal is to run these diagnostics processes in the background and to push the information captured using these tools to stackdriver. I don't know what I am missing here, since I am relatively new to dotnet. Please help.