Skip to content

Commit

Permalink
add k8s job tracing docs
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Gardner <[email protected]>
  • Loading branch information
agardnerIT committed Sep 13, 2023
1 parent ac0d996 commit 8516dad
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Want to do a similar thing with logs? Check out [logpusher](https://agardnerit.g

## Uses

- [Trace Kubernetes Jobs and CronJobs with OpenTelemetry](usage/k8sjobs.md)
- [Trace CICD Pipelines with OpenTelemetry](https://github.com/agardnerIT/tracepusher/blob/main/samples/gitlab/README.md)
- [Trace shell scripts with OpenTelemetry](https://github.com/agardnerIT/tracepusher/blob/main/samples/script.sh)
- [Trace Helm with tracepusher](usage/helm.md)
Expand Down
60 changes: 60 additions & 0 deletions docs/usage/k8sjobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Trace Kubernetes Jobs and CronJobs with tracepusher

Install the tracepusher job operator to automatically generate OpenTelemetry traces for any `Job` and `CronJobs` on the cluster.

### Prerequisites

First, make sure you have an OpenTelemetry collector running somewhere.

### 1. Install Custom Resource Definitions

Install the tracepusher CRDs:

```shell
kubectl apply -f https://raw.githubusercontent.com/agardnerIT/tracepusher/main/operator/crds.yml
```

### 2. Create One (or more) JobTracer Objects

A `JobTracer` should be created, one per namespace.

This defines the defaults for that namespace.

You can override the details on a per job basis.

For example, to trace all `Jobs` in the default namespace, download this file, modify the collector endpoint to point to your collector

```shell
wget https://raw.githubusercontent.com/agardnerIT/tracepusher/main/samples/jobtraceroperator/jobtracer.yml
# Modify spec.collectorEndpoint
kubectl apply -f jobtracer.yaml
```

### 3. Create a Job or CronJob

Now create a `Job` or `CronJob` as normal:

```
cat <<EOF | kubectl create -f -
---
apiVersion: batch/v1
kind: Job
metadata:
name: pi
namespace: default
#annotations:
# tracepusher/ignore: "true"
# tracepusher/collector: "http://example.com:4318"
spec:
template:
spec:
containers:
- name: pi
image: perl:5.34.0
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 0
EOF
```

Note the optional annotations. If set, these override the `JobTracer` settings.

0 comments on commit 8516dad

Please sign in to comment.