-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdo-sql.sh
More file actions
26 lines (22 loc) · 826 Bytes
/
do-sql.sh
File metadata and controls
26 lines (22 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if [ -z "$CONTEXT" ]; then
CONTEXT=eu-central # Why eu-central? Meh, whatever.
fi
CDSQL='cockroach sql --url "postgres://root@localhost:26257/defaultdb?sslmode=verify-full&sslrootcert=/cockroach/cockroach-certs/ca.crt&sslcert=/cockroach/cockroach-certs/client.root.crt&sslkey=/cockroach/cockroach-certs/client.root.key"'
if [ -n "$SCRIPT" ]; then
remote="/tmp/script-$$.sql"
kubectl cp \
--context $CONTEXT \
-n cockroachdb -c cockroachdb\
"$SCRIPT" cockroachdb-0:$remote
kubectl exec \
--context $CONTEXT \
-it cockroachdb-0 -c cockroachdb \
--namespace cockroachdb \
-- bash -c "$CDSQL < $remote"
else
kubectl exec \
--context $CONTEXT \
-it cockroachdb-0 -c cockroachdb \
--namespace cockroachdb \
-- bash -c "$CDSQL"
fi