Skip to content

Commit

Permalink
feat: add dump script from sync (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna authored Sep 18, 2023
1 parent 17f7d93 commit 5c5d852
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
33 changes: 33 additions & 0 deletions scripts/dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -euxo pipefail

# Set kube context
# kubectl config use-context ,,,

# Set kube context namespace
# kubectl config set-context --current --namespace=,,,

# Set file
FILE=fixtures

# Set source env
SRC_ENV=api-prod

# Get source pod
SRC_POD=$(kubectl get po -l app.kubernetes.io/name=$SRC_ENV -o name | \
sed "s/^.\{4\}//" | \
head -n 1\
)

# Dump fixtures in source pod
kubectl exec $SRC_POD -- /bin/bash -c "\
python manage.py dumpfixture --output $FILE.json && \
tar -czvf $FILE.tar.gz $FILE.json\
"

# Copy fixtures from source pod
kubectl cp $SRC_POD:/app/$FILE.tar.gz ./$FILE.tar.gz

# Remove fixtures from pod
kubectl exec $SRC_POD -- rm $FILE.json $FILE.tar.gz
10 changes: 8 additions & 2 deletions scripts/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ if [[ $# -eq 1 ]]; then
fi

# Get source and destination pods
SRC_POD=$(kubectl get po -l app.kubernetes.io/name=$SRC_ENV -o name | head -n 1)
DST_POD=$(kubectl get po -l app.kubernetes.io/name=$DST_ENV -o name | head -n 1)
SRC_POD=$(kubectl get po -l app.kubernetes.io/name=$SRC_ENV -o name | \
sed "s/^.\{4\}//" | \
head -n 1\
)
DST_POD=$(kubectl get po -l app.kubernetes.io/name=$DST_ENV -o name | \
sed "s/^.\{4\}//" | \
head -n 1\
)

# Dump fixtures in source pod
kubectl exec $SRC_POD -- /bin/bash -c "\
Expand Down

0 comments on commit 5c5d852

Please sign in to comment.