Last active
April 27, 2024 06:42
-
-
Save lukeplausin/f4e0477c96e766a80e15449c6a825cf6 to your computer and use it in GitHub Desktop.
Copy data from local filesystem into a pod in kubernetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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