-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcassandra-creator.yml
49 lines (48 loc) · 1.5 KB
/
cassandra-creator.yml
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
apiVersion: v1
kind: ConfigMap
metadata:
name: initialization-script
namespace: sdtd
data:
script.sh: |
#!/bin/sh
CONTINUE=1
until [ $CONTINUE -eq 0 ]
do
sleep 5;
2>>/dev/null >>/dev/tcp/cassandra/9042;
CONTINUE=$(echo $?)
echo "Waiting for cassandra...";
done
echo "Creating keyspace and table..."
cqlsh cassandra -u $CASSANDRA_USER -p $CASSANDRA_PASSWORD -e "CREATE KEYSPACE IF NOT EXISTS Stream_DB WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'};"
cqlsh cassandra -u $CASSANDRA_USER -p $CASSANDRA_PASSWORD -e "CREATE TABLE IF NOT EXISTS Stream_DB.frames (frame_id int, face_id int, x int, y int, w int, h int, main_emotion int, timestampFrame text, url text, PRIMARY KEY (url, frame_id, face_id)) WITH CLUSTERING ORDER BY (frame_id DESC, face_id ASC);"
---
apiVersion: batch/v1
kind: Job
metadata:
name: cassandra-creator
namespace: sdtd
spec:
template:
spec:
restartPolicy: Never
containers:
- name: cassandra-creator
image: cassandra:4
command: ["/bin/bash", "/scripts/script.sh"]
env:
- name: CASSANDRA_USER
value: cassandra
- name: CASSANDRA_PASSWORD
value: cassandra
volumeMounts:
- name: scripts
mountPath: "/scripts"
volumes:
- name: scripts
configMap:
name: initialization-script
items:
- key: "script.sh"
path: "script.sh"