oc-k8s/import_datas.sh
2025-03-31 09:43:43 +02:00

13 lines
467 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 dev-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