Skip to content

Commit e2a8481

Browse files
committed
Merge 'pauloguilhermpp/deploy_codabench_using_kubernetes' into develop
deploy codabench using kubernetes
2 parents a551b07 + a04fdae commit e2a8481

14 files changed

Lines changed: 500 additions & 1 deletion

charts/Chart.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: v2
2+
name: codabench-chart
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"
25+
26+
dependencies:
27+
- name: rabbitmq
28+
version: "14.7.0"
29+
repository: "oci://registry-1.docker.io/bitnamicharts"
30+
condition: rabbitmq.enabled
31+
- name: redis
32+
version: "19.5.4"
33+
repository: "oci://registry-1.docker.io/bitnamicharts"
34+
condition: redis.enabled
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: {{ .Values.appState.pvcName }}
5+
spec:
6+
accessModes:
7+
- ReadWriteMany
8+
resources:
9+
requests:
10+
storage: {{ .Values.appState.storage }}
11+
storageClassName: {{ .Values.appState.storageClass }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{{- range .Values.compute_worker.brokers }}
2+
{{- $isDefault := eq .name "default" }}
3+
---
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: compute-worker{{ if not $isDefault }}-{{ .name }}{{ end }}
8+
labels:
9+
app: compute-worker
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
app: compute-worker
15+
template:
16+
metadata:
17+
labels:
18+
app: compute-worker
19+
spec:
20+
serviceAccountName: compute-worker-sa
21+
containers:
22+
- name: compute-worker
23+
image: "{{ $.Values.compute_worker.image.repository }}:{{ $.Values.compute_worker.image.tag }}"
24+
imagePullPolicy: {{ $.Values.compute_worker.image.pullPolicy | default "IfNotPresent" }}
25+
command:
26+
- bash
27+
- -c
28+
- >
29+
watchmedo auto-restart -p '*.py' --recursive -- celery -A compute_worker worker -l info -Q compute-worker -n compute-worker{{ if not $isDefault }}-{{ .name }}{{ end }}@%n
30+
workingDir: /app
31+
env:
32+
- name: BROKER_URL
33+
value: "{{ if .url }}{{ .url }}{{ else }}pyamqp://{{ $.Values.env.RABBITMQ_DEFAULT_USER }}:{{ $.Values.env.RABBITMQ_DEFAULT_PASS }}@{{ $.Values.env.RABBITMQ_HOST }}:{{ $.Values.env.RABBITMQ_PORT }}//{{ end }}"
34+
- name: CODALAB_IGNORE_CLEANUP_STEP
35+
value: "1"
36+
{{- range $key, $value := $.Values.env }}
37+
- name: {{ $key }}
38+
value: "{{ $value }}"
39+
{{- end }}
40+
resources:
41+
{{- toYaml $.Values.compute_worker.resources | nindent 12 }}
42+
volumeMounts:
43+
- name: docker-socket
44+
mountPath: /var/run/docker.sock
45+
- name: codabench-storage
46+
mountPath: /codabench
47+
volumes:
48+
- name: docker-socket
49+
hostPath:
50+
path: /var/run/docker.sock
51+
type: Socket
52+
- name: codabench-storage
53+
persistentVolumeClaim:
54+
claimName: {{ $.Values.compute_worker.volumes.pvcName }}
55+
{{- end }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: compute-worker-sa
5+
namespace: {{ .Release.Namespace }}
6+
---
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
kind: Role
9+
metadata:
10+
name: compute-worker-role
11+
namespace: {{ .Release.Namespace }}
12+
rules:
13+
- apiGroups: ["batch"]
14+
resources: ["jobs"]
15+
verbs: ["create", "get", "list", "watch", "delete"]
16+
- apiGroups: [""]
17+
resources: ["pods"]
18+
verbs: ["get", "list", "watch", "delete"]
19+
- apiGroups: [""]
20+
resources: ["pods/exec", "pods/log"]
21+
verbs: ["create", "get", "list"]
22+
---
23+
apiVersion: rbac.authorization.k8s.io/v1
24+
kind: RoleBinding
25+
metadata:
26+
name: compute-worker-bind
27+
namespace: {{ .Release.Namespace }}
28+
subjects:
29+
- kind: ServiceAccount
30+
name: compute-worker-sa
31+
namespace: {{ .Release.Namespace }}
32+
roleRef:
33+
kind: Role
34+
name: compute-worker-role
35+
apiGroup: rbac.authorization.k8s.io
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: django
5+
spec:
6+
replicas: {{ .Values.django.replicas }}
7+
selector:
8+
matchLabels:
9+
app: django
10+
template:
11+
metadata:
12+
labels:
13+
app: django
14+
spec:
15+
containers:
16+
- name: django
17+
image: "{{ .Values.django.image.repository }}:{{ .Values.django.image.tag }}"
18+
imagePullPolicy: {{ .Values.django.image.pullPolicy }}
19+
command:
20+
- bash
21+
- -c
22+
- >
23+
python manage.py migrate --no-input &&
24+
python manage.py collectstatic --no-input &&
25+
cd {{ .Values.django.workingDir }} &&
26+
watchmedo auto-restart -p '*.py' --recursive --
27+
python3 ./gunicorn_run.py
28+
env:
29+
{{- range $key, $value := .Values.env }}
30+
- name: {{ $key }}
31+
value: "{{ $value }}"
32+
{{- end }}
33+
- name: DATABASE_URL
34+
value: "postgres://{{ .Values.db.username }}:{{ .Values.db.password }}@{{ .Values.db.host }}:{{ .Values.db.port }}/{{ .Values.db.name }}"
35+
volumeMounts:
36+
- name: app-state
37+
mountPath: /app/app-state
38+
volumes:
39+
- name: app-state
40+
persistentVolumeClaim:
41+
claimName: {{ .Values.appState.pvcName }}
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+
name: django
5+
spec:
6+
selector:
7+
app: django
8+
ports:
9+
- protocol: TCP
10+
port: 8000
11+
targetPort: 8000
12+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: flower
5+
labels:
6+
app: flower
7+
spec:
8+
replicas: {{ .Values.flower.replicas }}
9+
selector:
10+
matchLabels:
11+
app: flower
12+
template:
13+
metadata:
14+
labels:
15+
app: flower
16+
spec:
17+
containers:
18+
- name: flower
19+
image: "{{ .Values.flower.image.repository }}:{{ .Values.flower.image.tag }}"
20+
imagePullPolicy: {{ .Values.flower.image.pullPolicy }}
21+
ports:
22+
- containerPort: {{ .Values.flower.service.port }}
23+
env:
24+
- name: CELERY_BROKER_URL
25+
value: "pyamqp://{{ .Values.env.RABBITMQ_DEFAULT_USER }}:{{ .Values.env.RABBITMQ_DEFAULT_PASS }}@{{ .Values.env.RABBITMQ_HOST }}:{{ .Values.env.RABBITMQ_PORT }}//"
26+
- name: FLOWER_PORT
27+
value: "{{ .Values.flower.service.port }}"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: flower
5+
labels:
6+
app: flower
7+
spec:
8+
type: ClusterIP
9+
ports:
10+
- port: {{ .Values.flower.service.port }}
11+
targetPort: 5555
12+
selector:
13+
app: flower

charts/templates/ingress.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: sample-http-ingress
5+
spec:
6+
{{- toYaml .Values.ingress.spec | nindent 2 }}
7+

charts/templates/istio.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if .Values.istio.enableVirtualService}}
2+
apiVersion: networking.istio.io/v1alpha3
3+
kind: VirtualService
4+
metadata:
5+
name: codabench-vs
6+
spec:
7+
{{- toYaml .Values.istio.spec | nindent 12 }}
8+
9+
{{- else }}
10+
{{- end }}
11+

0 commit comments

Comments
 (0)