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 shSee Docker for a full example.
Secrets
Section titled “Secrets”Create a secret for your API key:
kubectl create secret generic pakyas-secret --from-literal=api-key=pk_live_...CronJob Manifest
Section titled “CronJob Manifest”The best way to use Pakyas in K8s is to wrap your container’s command.
apiVersion: batch/v1kind: CronJobmetadata: name: nightly-etlspec: 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: OnFailureWithout an API key
Section titled “Without an API key”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"]Why wrap the command?
Section titled “Why wrap the command?”Kubernetes restartPolicy: OnFailure will retry the pod if it crashes.
pakyas monitorreports 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 logsshows them as usual.
Sidecar Pattern (Optional)
Section titled “Sidecar Pattern (Optional)”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.