-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure_cloudscheduler.sh
More file actions
executable file
·109 lines (102 loc) · 2.34 KB
/
configure_cloudscheduler.sh
File metadata and controls
executable file
·109 lines (102 loc) · 2.34 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#! /bin/bash
RMQ_NAME="beehive-rabbitmq"
rmqctl() {
docker exec ${RMQ_NAME} rabbitmqctl "$@"
# kubectl exec svc/wes-rabbitmq -- rabbitmqctl "$@"
}
username="cloudscheduler"
password="$(openssl rand -hex 20)"
confperm=".*"
writeperm=".*"
readperm=".*"
echo "Generating a RabbitMQ account for cloud scheduler..."
# from waggle-edge-stack/kubernetes/update-rabbitmq-auth.sh
# https://github.com/waggle-sensor/waggle-edge-stack/blob/main/kubernetes/update-rabbitmq-auth.sh
(
while ! rmqctl authenticate_user "$username" "$password"; do
while ! (rmqctl add_user "$username" "$password" || rmqctl change_password "$username" "$password"); do
sleep 3
done
done
while ! rmqctl set_permissions "$username" "$confperm" "$writeperm" "$readperm"; do
sleep 3
done
) &> /dev/null
echo "Done"
echo "Generating k3s objects for cloud scheduler..."
cat <<EOF > cloudscheduler.yaml
apiVersion: apps/v1 # this apiVersion is relevant as of Kubernetes 1.9
kind: Deployment
metadata:
name: cloudscheduler
labels:
app: cloudscheduler
spec:
replicas: 1
selector:
matchLabels:
app: cloudscheduler
template:
metadata:
labels:
app: cloudscheduler
spec:
containers:
- name: cloudscheduler
image: waggle/scheduler:0.4.0
volumeMounts:
- mountPath: /app/data/
name: data
ports:
- containerPort: 9770
workingDir: /app/
command: ["/app/cloudscheduler"]
args:
- "-rabbitmq-uri"
- "${RMQ_NAME}"
- "-rabbitmq-username"
- "${username}"
- "-rabbitmq-password"
- "${password}"
- "-data-dir"
- "data"
- "-port"
- "9770"
volumes:
- name: data
hostPath:
path: /tmp/data
type: Directory
---
apiVersion: v1
kind: Service
metadata:
name: cloudscheduler
spec:
selector:
app: cloudscheduler
ports:
- name: api
protocol: TCP
port: 9770
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cloudscheduler-ingress
annotations:
spec:
rules:
- host: ses.localhost
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: cloudscheduler
port:
number: 9770
EOF
echo "Done."
echo "To launch cloud scheduler, kubectl apply -f cloudscheduler.yaml"