npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@builder.io/kube-cron-jobs

v0.1.0

Published

Kubernetes CronJobs for resources management and cleanup

Readme

Kubernetes CronJobs for Resources Management

This package contains Kubernetes CronJobs for managing different resources, including creating snapshots and cleaning up project resources (PVCs, pods, ingresses...) automatically.

PVC Snapshot Cleaner

The pvc-snapshot-cleaner CronJob runs periodically to process PVCs in Terminating state, create snapshots, and remove finalizers.

How It Works

  1. Discovers PVCs: Lists all PVCs with:

    • Label: fusion-managed: true
    • Finalizer: snapshot.fusion.io/protect
    • deletionTimestamp set (PVC is being deleted)
  2. Creates Snapshots: Calls Cloud Run /projects/kube/webhook/snapshot endpoint with retry logic

  3. Removes Finalizers: After successful snapshot, calls /projects/kube/webhook/remove-finalizer endpoint

  4. Retry Logic: Implements exponential backoff with state persisted in PVC annotations:

    • Attempt 1: Immediate
    • Attempt 2: 30 seconds delay
    • Attempt 3: 1 minute delay
    • Attempt 4: 2 minutes delay
    • Attempt 5: 5 minutes delay
    • Attempt 6 (final): 5 minutes delay

    Retry state is persisted in PVC annotations, so it survives CronJob restarts.

Building the Docker Image

Images are automatically built and pushed by GitHub Actions workflows. For manual builds:

# From the ai-services root directory
docker build -f Dockerfile.pvc-snapshot-cleaner -t us-central1-docker.pkg.dev/PROJECT_ID/kube/pvc-snapshot-cleaner:latest .

# Push to Artifact Registry
docker push us-central1-docker.pkg.dev/PROJECT_ID/kube/pvc-snapshot-cleaner:latest

Environment Variables

  • CLOUD_RUN_SERVICE_URL - URL of the Cloud Run service (e.g., https://your-service.run.app)
  • KUBERNETES_WEBHOOK_TOKEN - Token for authenticating with Cloud Run endpoints

Kubernetes Configuration

The CronJob is configured via Terraform in terraform/kubernetes/main.tf. Key settings:

  • Schedule: Every minute (*/1 * * * *) - Kubernetes CronJob minimum interval
  • Concurrency: Allow parallel executions
  • Timeout: 10 minutes per job
  • Service Account: snapshot-service-account (with required RBAC permissions)

Local Development

# Set environment variables
export CLOUD_RUN_SERVICE_URL="https://your-service.run.app"
export KUBERNETES_WEBHOOK_TOKEN="your-token"

# Run directly with tsx
npx tsx packages/kube-cron-jobs/src/pvc-snapshot-cleaner.ts

PVC Soft Deletion

The pvc-soft-deletion CronJob runs periodically to mark old PVCs (older than 5 days) for deletion by setting deletionTimestamp, putting them in Terminating state. The actual deletion happens after finalizers are removed (typically by the snapshot cleaner).

Local Development

# Set environment variables (optional - defaults to 5 days)
export PVC_AGE_THRESHOLD_DAYS="5"

# Run directly with tsx
npx tsx packages/kube-cron-jobs/src/pvc-soft-deletion.ts