Skip to content

Instantly share code, notes, and snippets.

@rdemorais
Created November 1, 2021 16:03
Show Gist options
  • Save rdemorais/47a6de016fa454c673a4bf96be034410 to your computer and use it in GitHub Desktop.
Save rdemorais/47a6de016fa454c673a4bf96be034410 to your computer and use it in GitHub Desktop.
kubectl copy without cp
#!/usr/bin/env bash
function copy_text_to_pod() {
namespace=$1
pod_name=$2
src_filename=$3
dest_filename=$4
base64_text=`cat $src_filename | base64`
kubectl --kubeconfig=conasems-config.yml exec -n $namespace $pod_name -- bash -c "echo \"$base64_text\" | base64 -d > $dest_filename"
}
copy_text_to_pod tools postgres-6444bd9b85-v7t62 municipios.csv /tmp/municipios.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment