Skip to content

Add ExecPod functions to execute commands in Kubernetes pods#1599

Merged
james00012 merged 2 commits intomainfrom
exec-pod
Oct 15, 2025
Merged

Add ExecPod functions to execute commands in Kubernetes pods#1599
james00012 merged 2 commits intomainfrom
exec-pod

Conversation

@james00012
Copy link
Copy Markdown
Contributor

@james00012 james00012 commented Oct 4, 2025

Summary

  • Add ExecPod and ExecPodE helper functions to the k8s module
  • Enable executing commands inside running Kubernetes pods
  • Support optional container specification for multi-container pods
  • Include comprehensive tests for both single and multi-container scenarios

Fixes #1598

Implementation Details

The new functions wrap kubectl exec and provide:

  • ExecPod(t, options, podName, containerName, command...) - executes command and requires no error
  • ExecPodE(t, options, podName, containerName, command...) - executes command and returns output and error

When containerName is empty, the command executes in the default container. When specified, it targets the specific container using the -c flag.

Test Plan

  • ✅ Test execution in single-container pod (default container)
  • ✅ Test execution in multi-container pod with specific container selection
  • ✅ Verify command output is correctly captured
  • ✅ Ensure proper error handling

This adds ExecPod and ExecPodE helper functions to the k8s module that allow executing commands inside running pods, with optional container specification for multi-container pods. The implementation wraps kubectl exec and includes comprehensive tests verifying both single and multi-container scenarios.
Add brief comments describing the purpose and usage of ExecPod and ExecPodE
functions, following the style of other exported functions in the package.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@james00012
Copy link
Copy Markdown
Contributor Author

Should be good for review. Addressed your comment @denis256

@james00012 james00012 merged commit d99bb15 into main Oct 15, 2025
2 of 3 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.

Feature Request: Add convenience functions for executing commands in pods/containers

2 participants