Description
Add a k8s.exec operation to execute commands inside running containers. This is critical for functional verification testing in tasks like multi-container-pod-communication, statefulset-lifecycle, and setup-dev-cluster.
Current bash tasks use patterns like:
kubectl exec pod-name -c container -- curl -s localhost:80
kubectl exec pod-name -n namespace -- cat /data/test
kubectl exec pod-name -- nslookup kubernetes.default
kubectl exec pod-name -c logger -- ls -la /var/log/nginx/
Requirements
- Support executing arbitrary commands in a pod's container
- Support specifying target container in multi-container pods
- Support namespace specification
- Capture stdout/stderr and exit code
- Support an
expect block for inline verification of output
Example Usage
Check HTTP response:
- k8s.exec:
pod: communication-pod
namespace: multi-container-logging
container: web-server
command: ["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", "localhost:80"]
expect:
stdout:
match: "200"
Verify file contents:
- k8s.exec:
pod: db-0
namespace: statefulset-test
command: ["cat", "/data/test"]
expect:
stdout:
equals: "initial_data"
Acceptance Criteria
Description
Add a
k8s.execoperation to execute commands inside running containers. This is critical for functional verification testing in tasks like multi-container-pod-communication, statefulset-lifecycle, and setup-dev-cluster.Current bash tasks use patterns like:
kubectl exec pod-name -c container -- curl -s localhost:80kubectl exec pod-name -n namespace -- cat /data/testkubectl exec pod-name -- nslookup kubernetes.defaultkubectl exec pod-name -c logger -- ls -la /var/log/nginx/Requirements
expectblock for inline verification of outputExample Usage
Check HTTP response:
Verify file contents:
Acceptance Criteria
expect.stdoutfor output assertions (equals, match, contains)expect.exitCodefor exit code verification