Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 5, 2026

feat: add kubernetes-test package with wait-for-pods functionality

Summary

Adds a new kubernetes-test package to the dev-utils monorepo that provides Kubernetes testing utilities. The initial implementation includes a waitForPods function that polls the Kubernetes API until pods reach a ready state, with configurable timeout, polling interval, and label/field selectors.

Key features:

  • waitForPods() - Wait for pods matching selectors to become ready
  • waitForPodByName() - Convenience wrapper for waiting on a specific pod
  • waitForPodsWithLabel() - Convenience wrapper for label-based selection
  • Custom error types (WaitForPodsTimeoutError, WaitForPodsError) with progress information
  • Progress callback support for monitoring pod status during wait

Uses kubernetesjs for K8s API types and client interactions.

Updates since last revision

  • Renamed package from @interweb/kubernetes-test to kubernetes-test (removed scope per user request)
  • Updated README examples to use the new unscoped package name

Review & Testing Checklist for Human

  • Verify requirements alignment: The original request mentioned "use pgsql-test similar to how supabase-test and drizzle-orm-test do" - this package does NOT use pgsql-test. It's a standalone K8s utility. Confirm this is the intended design.
  • Review polling logic in wait-for-pods.ts: The while (true) loop with timeout check - verify edge cases are handled (e.g., what if pods never appear, what if namespace doesn't exist)
  • Test against actual Kubernetes cluster: The unit tests only verify type definitions compile correctly. The actual waitForPods functionality has not been tested against a real K8s cluster or kubectl proxy.
  • Verify kubernetesjs API structure: The listCoreV1NamespacedPod call uses { path: { namespace }, query: { labelSelector, fieldSelector } } structure - confirm this matches kubernetesjs expectations

Recommended Test Plan

  1. Run kubectl proxy locally
  2. Create a test deployment with multiple pods
  3. Call waitForPods() with appropriate selectors and verify it returns when pods are ready
  4. Test timeout behavior by setting a very short timeout

Notes

  • Build passes, unit tests pass (5 tests)
  • ESLint fails due to pre-existing repo-level config issue (ESLint 9 vs .eslintrc.json format mismatch)
  • Large pnpm-lock.yaml changes are due to adding kubernetesjs dependency

Requested by: Dan Lynch (@pyramation)
Devin session: https://app.devin.ai/sessions/fb12157dbe184b43bb018c1aa54508a0

- Add @interweb/kubernetes-test package for Kubernetes testing utilities
- Implement waitForPods, waitForPodByName, and waitForPodsWithLabel functions
- Use kubernetesjs for K8s API types and client
- Include comprehensive TypeScript types for pod status tracking
- Add error handling with WaitForPodsTimeoutError and WaitForPodsError
- Include basic test suite for type definitions
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit de1a02d into main Jan 6, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants