Skip to content

Instantly share code, notes, and snippets.

@lukeplausin
Last active April 27, 2024 06:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeplausin/f4e0477c96e766a80e15449c6a825cf6 to your computer and use it in GitHub Desktop.
Save lukeplausin/f4e0477c96e766a80e15449c6a825cf6 to your computer and use it in GitHub Desktop.
Copy data from local filesystem into a pod in kubernetes
# If your pod container doesn't have bash in the path, you might need to replace `bash` with `/bin/bash/`, `/bin/sh` or `/bin/ash`.
# Simple string from the command line - puts the literal text 'AAA' into a new file /tmp/test.txt
echo 'AAA' > kubectl -n MyNamespace exec -ti $my_pod_id -c my-pod-container -- bash -c 'cat - > /tmp/test.txt'
# Copy / inject a file from the local filesystem into a new file in the pod in the remote kubernetes cluster
kubectl -n MyNamespace exec -i $my_pod_id -c my-pod-container -- bash -c 'cat - > /tmp/file.txt' </my/input/file.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment