apiVersion: batch/v1
kind: Job
metadata:
  name: sample-job
  namespace: default
spec:
  template:
    metadata:
      annotations:
        workload: job
      labels:
        app: sample
    spec:
      shareProcessNamespace: true
      restartPolicy: Never
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      containers:
      - name: sample-app
        image: sample-app
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh", "-c"]
        # send SIGTERM to otel-go-instrumentation once the sample app has generated data so the job completes.
        args: ["(/sample-app/start.sh || /sample-app/main) && kill -TERM $(pidof otel-go-instrumentation)"]
      - name: auto-instrumentation
        image: otel-go-instrumentation
        imagePullPolicy: IfNotPresent
        command: ["/otel-go-instrumentation", "-global-impl", "-log-level=debug"]
        env:
        - name: OTEL_GO_AUTO_TARGET_EXE
          value: /sample-app/main
        - name: OTEL_EXPORTER_OTLP_ENDPOINT
          value: "http://test-opentelemetry-collector:4318"
        - name: OTEL_SERVICE_NAME
          value: "sample-app"
        - name: OTEL_PROPAGATORS
          value: "tracecontext,baggage"
        - name: OTEL_GO_AUTO_INCLUDE_DB_STATEMENT
          value: "true"
        - name: OTEL_BSP_SCHEDULE_DELAY
          value: "60000"
        resources: {}
        securityContext:
          runAsUser: 0
          privileged: true
        volumeMounts:
        - mountPath: /sys/kernel/debug
          name: kernel-debug
      volumes:
      - name: kernel-debug
        hostPath:
          path: /sys/kernel/debug
