title | sidebarTitle | description | icon |
---|---|---|---|
Installing Subtrace on Kubernetes |
Kubernetes |
Monitor requests in your Kubernetes clusters, pods and deployments with Subtrace. |
cubes |
If you use a Kubernetes cluster and you need to monitor your app's requests in production, Subtrace is a great fit.
Start by making the following change to your Dockerfile
to install Subtrace
in your app's Docker image:
- CMD ["node", "./app.js"]
+ RUN curl -fsSLO https://subtrace.dev/download/latest/$(uname -s)/$(uname -m)/subtrace && chmod +x ./subtrace
+ CMD ["./subtrace", "run", "--", "node", "./app.js"]
Build and push the new Docker image just like you used to before changing your
Dockerfile to install Subtrace. Then update your Kubernetes pod spec to point
to the new image. Here is an example deployment.yaml
for reference:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-container
image: ghcr.io/NAMESPACE/IMAGE_NAME:latest
env:
- name: SUBTRACE_TOKEN
valueFrom:
secretKeyRef:
name: env-secrets
key: SUBTRACE_TOKEN
securityContext:
capabilities:
add: ["SYS_PTRACE"]
Finish by applying your changes to the cluster:
kubectl apply -f ./deployment.yaml
And that's it! Send a HTTP request to the Kubernetes service corresponding to this deployment and you should see it automatically appear in the Subtrace dashboard.