Skip to main content

copypod

Utility for copying a running Kubernetes pod so you can run commands in a copy of its environment, without worrying about it the pod potentially being removed due to a deploy.

copypod can work in two different modes, depending on if the --interactive flag is provided:

  • If the flag is left out, copypod will copy the specified pod and start it. When the pod reaches the "Running" state the name of the pod will be outputted as the only output. This is intended for use in automation scenarios.
  • If a command is provided with the --interactive flag, then the pod will be copied and started as before, but when the pod is running kubectl will be called and connect to the pod where the provided command is then run interactively. When the kubectl program exits the pod will be removed. This is intended for running ad-hoc tasks and processes.

Install

copypod is available on PyPI. You can install it via pipx:

$ pipx install copypod

Usage

$ copypod --help
usage: copypod [-h] [--context CONTEXT] [-n NAMESPACE] (-l SELECTOR | -p POD) [--container CONTAINER] [-c COMMAND] [-i INTERACTIVE] [--image IMAGE]
               [--cap-add CAP_ADD] [-s SUFFIX] [-e ENV] [--limit-cpu LIMIT_CPU] [--limit-memory LIMIT_MEMORY] [--request-cpu REQUEST_CPU]
               [--request-memory REQUEST_MEMORY]

Copy a Kubernetes pod and run commands in its environment.

options:
  -h, --help            show this help message and exit
  --context CONTEXT     Kubectl context to use for configuration (default: None)
  -n, --namespace NAMESPACE
                        Namespace for where the source pod is located (default: default)
  -l, --selector SELECTOR
                        Label selector of pod to copy (default: None)
  -p, --pod POD         Name of the pod to copy (default: None)
  --container CONTAINER
                        Name of container to copy, only needed if the pod has more than one container (default: None)
  -c, --command COMMAND
                        Initial command to run in the copied pod (default: sleep infinity)
  -i, --interactive INTERACTIVE
                        Command to run in an interactive console (default: None)
  --image IMAGE         Set to alternate Docker image to use for copied pod (default: None)
  --cap-add CAP_ADD     Capabilities to add for the copied pod, can be specified multiple times (default: None)
  -s, --suffix SUFFIX   Set custom suffix for the new pod, otherwise a random suffix is generated (default: None)
  -e, --env ENV         Environment variable to set (NAME=value), can be specified multiple times (default: None)
  --limit-cpu LIMIT_CPU
                        Set CPU limit for the copied pod. '1' = one core, '500m' = half a core (default: None)
  --limit-memory LIMIT_MEMORY
                        Set memory limit for the copied pod. E.g. '256Mi', '1Gi' (default: None)
  --request-cpu REQUEST_CPU
                        Set requested CPU for the copied pod. '1' = one core, '500m' = half a core (default: None)
  --request-memory REQUEST_MEMORY
                        Set requested memory for the copied pod. E.g. '256Mi', '1Gi' (default: None)

If the `--interactive` flag is provided, the copied pod will be removed immediately after the command exits, otherwise the name of the pod will be printed.

Examples

Say you wanted to copy the pod named my-great-pod and have the copied pod run until you specifically remove it, you could run:

$ copypod -p my-great-pod
pod-copy-girwak

pod-copy-girwak is then the name of the new pod created for you, and it will by default run sleep infinity as the starting command, meaning it will keep running forever until it's deleted.

At this point you can enter the pod and run commands as you'd like, for instance start a shell inside the pod with:

$ kubectl exec -it pod-copy-girwak -- bash
root@pod-copy-girwak:/#

When you are done you can remove the copied pod again with kubectl:

$ kubectl delete pod pod-copy-girwak
pod "pod-copy-girwak" deleted

Say you instead would like to copy a pod, start a shell in the copied pod and have the pod be deleted when you exit the shell, you can do that by supplying the --interactive flag like this:

$ copypod -p my-great-pod -i bash
root@pod-copy-i41u04:/# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 10:43 ?        00:00:00 sleep infinity
root         7     0  0 10:43 ?        00:00:00 bash
root        13     7  0 10:43 ?        00:00:00 ps -ef

When you are done doing what you needed the pod for, you can exit the shell and the pod will be removed immediately.

The value for the --interactive flag is the command you'd like to start inside the pod.


Instead of having to look up the name of a pod before running copypod, you can also specify labels which match one or more pods that you'd like to copy. copypod will then pick the first pod matching the lables and copy that for you. This can be done with the --selector flag. It works the same way as for the kubectl command.

If we for example have one or more pods with the label app: my-great-service we can copy any of those pods without having to know the exact pod name by running:

$ copypod -l app=my-great-service -i bash
root@pod-copy-1gk57f:/#

Note regarding Alpine Linux

The sleep command in images based on Alpine Linux does not support "infinity" as an argument unless the "coreutils" package is installed. As a work around you can instead specify --command "sleep 1d" as an argument to copypod to change the command run in the new pod.

Metadata

Release files for copypod 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for copypod 0.7.0
File Size Uploaded Provenance Actions
copypod-0.7.0.tar.gz 10.7 kB With provenance Details for copypod-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for copypod 0.7.0
File Interpreter ABI Platform Actions
copypod-0.7.0-py3-none-any.whl Python 3 none any Details for copypod-0.7.0-py3-none-any.whl

Total release size: 25.1 kB

Release files / copypod-0.7.0.tar.gz

Download URL copypod-0.7.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2fbde5bb4fae718f81d73df5410839526fdfd517645c2d2141609e6d7b43f892
BLAKE2b-256 checksum
How to use checksums
be4c0281f5d86fd00dd582be9f0a6793c6d6314cb08c42bdb8383d34fd82ca1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Release files / copypod-0.7.0-py3-none-any.whl

Download URL copypod-0.7.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6aa4171ad7db2ccfbcbd5756d646b02cc3ad909531853af9e76625a1dbb4e81b
BLAKE2b-256 checksum
How to use checksums
c40f665e384ac4030dc3e452a9c6dc3add46daa3e0d1ca8dfcc2bbeb122db9f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Security for copypod 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for copypod-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page