Skip to content

Kubernetes

The container image must include the pakyas binary. Install it in your Dockerfile:

RUN curl -fsSL https://pakyas.com/install.sh | PAKYAS_INSTALL_DIR=/usr/local/bin sh

See Docker for a full example.

Create a secret for your API key:

Terminal window
kubectl create secret generic pakyas-secret --from-literal=api-key=pk_live_...

The best way to use Pakyas in K8s is to wrap your container’s command.

apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-etl
spec:
schedule: "0 0 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: etl
image: my-org/etl:latest
# Override command to wrap with Pakyas
command: ["pakyas", "monitor", "nightly-etl", "--", "/app/run_etl.sh"]
env:
- name: PAKYAS_API_KEY
valueFrom:
secretKeyRef:
name: pakyas-secret
key: api-key
restartPolicy: OnFailure

Pinging by public ID needs no secret and makes no API calls, which suits short-lived pods (each pod starts with an empty slug cache):

command: ["pakyas", "monitor", "--public-id", "550e8400-e29b-41d4-a716-446655440000", "--", "/app/run_etl.sh"]

Kubernetes restartPolicy: OnFailure will retry the pod if it crashes.

  • pakyas monitor reports the failure (with the exit code and the tail of stderr) before the pod exits with the same non-zero code.
  • This allows K8s to restart the pod, while you still get alerted that the specific run failed.
  • A “success” ping is only sent when the process exits with 0.
  • The job’s stdout and stderr pass through unchanged, so kubectl logs shows them as usual.

If you cannot modify the container’s command, you can use a sidecar or initContainer + shared volume, but simply wrapping the entrypoint is significantly easier and more reliable for CronJobs.