oc-k8s/import_datas.sh
2025-04-01 10:20:55 +02:00

13 lines
471 B
Bash
Executable File

#!/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