-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathrun.sh
executable file
·69 lines (63 loc) · 1.82 KB
/
run.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -eo pipefail
IMAGE=${IMAGE:-sbaier1/car-sensor-model:latest}
MODEL_NAME=${MODEL_NAME:-model1.h5}
echo "Running model training with image ${IMAGE}, writing to ${MODEL_NAME}"
cat << EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: "sensor-model-training"
spec:
restartPolicy: Never
containers:
- name: training
image: ${IMAGE}
imagePullPolicy: Always
command: ["python3"]
args: ["cardata-v2.py", "kafka.operator.svc.cluster.local:9071", "SENSOR_DATA_S_AVRO", "0", "model-predictions", "train", "${MODEL_NAME}"]
volumeMounts:
- name: storage-secret
mountPath: /credentials
readOnly: true
volumes:
- name: storage-secret
secret:
secretName: google-application-credentials
EOF
kubectl wait --for=condition=Ready --timeout=5m po/sensor-model-training
kubectl logs -f po/sensor-model-training
kubectl delete po/sensor-model-training
echo "Creating prediction deployment"
cat << EOF | kubectl apply -f -
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tf-model
namespace: default
spec:
selector:
matchLabels:
app: tensorflow
template:
metadata:
labels:
app: tensorflow
spec:
nodeSelector:
failure-domain.beta.kubernetes.io/zone: europe-west1-b
containers:
- name: model
image: ${IMAGE}
imagePullPolicy: Always
command: ["python3"]
args: ["cardata-v2.py", "kafka.operator.svc.cluster.local:9071", "SENSOR_DATA_S_AVRO", "0", "model-predictions", "predict", "${MODEL_NAME}"]
volumeMounts:
- name: storage-secret
mountPath: /credentials
readOnly: true
volumes:
- name: storage-secret
secret:
secretName: google-application-credentials
EOF