Skip to content

Commit 703aaaf

Browse files
committed
added docker configuration for sandbox
1 parent 682b1fe commit 703aaaf

8 files changed

Lines changed: 165 additions & 0 deletions

File tree

buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/DockerStackConfiguration.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ fun Project.createStackDeployTask(profile: String) {
105105
FRONTEND_TAG=${defaultVersionOrProperty("frontend.dockerTag")}
106106
GATEWAY_TAG=${defaultVersionOrProperty("gateway.dockerTag")}
107107
ORCHESTRATOR_TAG=${defaultVersionOrProperty("orchestrator.dockerTag")}
108+
SANDBOX_TAG=${defaultVersionOrProperty("sandbox.dockerTag")}
108109
PREPROCESSOR_TAG=${defaultVersionOrProperty("preprocessor.dockerTag")}
109110
PROFILE=$profile
110111
""".trimIndent()

docker-compose.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ services:
3333
labels:
3434
- "prometheus-job=save-orchestrator"
3535
logging: *loki-logging-jvm
36+
sandbox:
37+
image: ghcr.io/saveourtool/save-sandbox:${SANDBOX_TAG}
38+
user: root # to access host's docker socket
39+
environment:
40+
- "SPRING_PROFILES_ACTIVE=${PROFILE}"
41+
ports:
42+
- "5400:5400"
43+
volumes:
44+
- "/var/run/docker.sock:/var/run/docker.sock"
45+
- /home/saveu/executionLogs:/home/cnb/executionLogs/
46+
- /home/saveu/configs/sandbox:/home/cnb/config
47+
- save-tmp-resources:/tmp
48+
extra_hosts:
49+
- "host.docker.internal:host-gateway"
50+
deploy:
51+
labels:
52+
- "prometheus-job=save-sandbox"
53+
logging: *loki-logging-jvm
3654
backend:
3755
image: ghcr.io/saveourtool/save-backend:${BACKEND_TAG}
3856
environment:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ .Values.sandbox.name }}-config
5+
data:
6+
application.properties: |
7+
sandbox.backendUrl=http://backend/internal
8+
9+
sandbox.kubernetes.apiServerUrl=http://kubernetes.default.svc
10+
sandbox.kubernetes.serviceAccount=${POD_SERVICE_ACCOUNT}
11+
sandbox.kubernetes.namespace=${POD_NAMESPACE}
12+
13+
server.shutdown=graceful
14+
management.endpoints.web.exposure.include=*
15+
sandbox.agent-settings.orchestrator-url=http://{{ .Values.sandbox.name }}
16+
sandbox.agent-settings.backend-url=http://{{ .Values.sandbox.name }}
17+
sandbox.agent-settings.debug=true
18+
19+
sandbox.test-resources.tmp-path=/tmp/save/resources
20+
21+
logging.level.com.saveourtool.save.orchestrator.kubernetes=DEBUG
22+
23+
{{ if .Values.sandbox.applicationProperties }}
24+
{{- .Values.sandbox.applicationProperties | nindent 4 }}
25+
{{ end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: sandbox
5+
labels:
6+
{{- include "common.labels" (merge (dict "service" .Values.sandbox) .) | nindent 4 }}
7+
spec:
8+
selector:
9+
matchLabels:
10+
io.kompose.service: sandbox
11+
replicas: 1
12+
template:
13+
metadata:
14+
labels:
15+
{{- include "pod.common.labels" (merge (dict "service" .Values.sandbox ) .) | nindent 8 }}
16+
annotations:
17+
{{- include "pod.common.annotations" (dict "service" .Values.backend ) | nindent 8 }}
18+
spec:
19+
serviceAccountName: sandbox-sa
20+
restartPolicy: Always
21+
{{- if .Values.sandbox.nodeName }}
22+
nodeName: {{ .Values.sandbox.nodeName }}
23+
{{- end }}
24+
{{- include "cnb.securityContext" . | nindent 6 }}
25+
containers:
26+
- name: sandbox
27+
{{- include "spring-boot.common" (merge (dict "service" .Values.sandbox) .) | nindent 10 }}
28+
env:
29+
{{- include "spring-boot.common.env" (merge (dict "service" .Values.sandbox) .) | nindent 12 }}
30+
- name: HOST_IP
31+
valueFrom:
32+
fieldRef:
33+
fieldPath: status.hostIP
34+
- name: JAVA_TOOL_OPTIONS
35+
value: -XX:ReservedCodeCacheSize=48M
36+
- name: POD_NAMESPACE
37+
valueFrom:
38+
fieldRef:
39+
fieldPath: metadata.namespace
40+
- name: POD_SERVICE_ACCOUNT
41+
valueFrom:
42+
fieldRef:
43+
fieldPath: spec.serviceAccountName
44+
- name: NODE_NAME
45+
valueFrom:
46+
fieldRef:
47+
fieldPath: spec.nodeName
48+
volumeMounts:
49+
- {{ include "spring-boot.config-volume-mount" . | indent 14 | trim }}
50+
- name: execution-logs-storage
51+
mountPath: /home/cnb/executionLogs/
52+
{{- include "spring-boot.management" .Values.sandbox | nindent 10 }}
53+
resources:
54+
limits:
55+
memory: 800M
56+
requests:
57+
memory: 600M
58+
volumes:
59+
- {{ include "spring-boot.config-volume" (dict "service" .Values.sandbox) | indent 10 | trim }}
60+
- name: execution-logs-storage
61+
# FixMe: Do we still need logs storage? All logs should be stored in Loki.
62+
emptyDir: {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: sandbox-sa
5+
6+
---
7+
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
kind: Role
10+
metadata:
11+
name: jobs-executor
12+
rules:
13+
- apiGroups: [batch]
14+
resources: [jobs]
15+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
16+
- apiGroups: [""] # "" indicates the core API group
17+
resources: [pods]
18+
verbs: [list, get, delete, create]
19+
20+
---
21+
22+
apiVersion: rbac.authorization.k8s.io/v1
23+
kind: RoleBinding
24+
metadata:
25+
name: sandbox-jobs-binding
26+
subjects:
27+
- kind: ServiceAccount
28+
name: sandbox-sa
29+
roleRef:
30+
apiGroup: rbac.authorization.k8s.io
31+
kind: Role
32+
name: jobs-executor
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
{{- include "service.common.metadata" (dict "service" .Values.sandbox) | nindent 2 }}
5+
spec:
6+
{{ if .Values.sandbox.clusterIP }}
7+
clusterIP: {{ .Values.sandbox.clusterIP }}
8+
{{ end }}
9+
ports:
10+
{{- include "service.common.ports" (dict "service" .Values.sandbox) | nindent 4 }}
11+
selector:
12+
{{- include "service.common.selectors" (dict "service" .Values.sandbox) | nindent 4 }}

save-cloud-charts/save-cloud/values-minikube.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ orchestrator:
1616
orchestrator.docker.host=tcp://localhost:2376
1717
logging.level.com.saveourtool=DEBUG
1818
orchestrator.kubernetes.useGvisor=false
19+
sandbox:
20+
profile: dev,kubernetes,minikube
21+
dockerHost: tcp://${HOST_IP}:2376
22+
applicationProperties: |
23+
sandbox.docker.host=tcp://localhost:2376
24+
logging.level.com.saveourtool=DEBUG
25+
sandbox.kubernetes.useGvisor=false
1926
mysql:
2027
external: false
2128
ip: nil

save-cloud-charts/save-cloud/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ orchestrator:
2525
# Fixed ClusterIP can be assigned to make it easier to query orchestrator from services outside Kubernetes
2626
clusterIP: null
2727
dockerHost: tcp://${HOST_IP}:2375
28+
sandbox:
29+
name: sandbox
30+
imageName: save-sandbox
31+
containerPort: 5400
32+
# Fixed ClusterIP can be assigned to make it easier to query orchestrator from services outside Kubernetes
33+
clusterIP: null
34+
dockerHost: tcp://${HOST_IP}:2375
35+
dbPasswordFile: /home/cnb/secrets/db_secrets
2836
preprocessor:
2937
name: preprocessor
3038
imageName: save-preprocessor

0 commit comments

Comments
 (0)