#!/bin/bash FILES=$(ls $1 | grep .json) BRANCH=${2:-dev} export KUBECONFIG=$(realpath ./deployed_config) POD_NAME=$(kubectl get pods --all-namespaces -o=name | grep $BRANCH-mongodb-*) for file in "${FILES[@]}"; do echo "ADD file $file in collection ${file/.json/} : ${POD_NAME/pod\//}" kubectl cp $file ${POD_NAME/pod\//}:/tmp/$file kubectl exec ${POD_NAME/pod\//}: -- mongoimport --db DC_myDC --collection ${file/.json/} --file /tmp/$file --jsonArray done