我正在尝试使用 dotnet-trace 和 dotnet 计数器为部署在 kubernetes(GKE) 集群上的应用程序启用性能诊断。为此,我在应用程序容器中添加了性能诊断 sidecar。诊断.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
Run Code Online (Sandbox Code Playgroud)
我在这里使用的应用程序是一个简单的 hello world 应用程序。这就是我在 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:
- …Run Code Online (Sandbox Code Playgroud)