From b5c3e9341f566e4721f390a4f3ba6964821f935d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de>
Date: Mon, 3 May 2021 18:35:27 +0200
Subject: [PATCH] Add random scheduler to Helm chart

---
 .../cluster-role-binding.yaml                 | 14 +++++++++
 .../random-scheduler/deployment.yaml          | 30 +++++++++++++++++++
 .../random-scheduler/service-account.yaml     | 10 +++++++
 execution/helm/values.yaml                    |  7 +++++
 4 files changed, 61 insertions(+)
 create mode 100644 execution/helm/templates/theodolite/random-scheduler/cluster-role-binding.yaml
 create mode 100644 execution/helm/templates/theodolite/random-scheduler/deployment.yaml
 create mode 100644 execution/helm/templates/theodolite/random-scheduler/service-account.yaml

diff --git a/execution/helm/templates/theodolite/random-scheduler/cluster-role-binding.yaml b/execution/helm/templates/theodolite/random-scheduler/cluster-role-binding.yaml
new file mode 100644
index 000000000..658f75c8c
--- /dev/null
+++ b/execution/helm/templates/theodolite/random-scheduler/cluster-role-binding.yaml
@@ -0,0 +1,14 @@
+{{- if .Values.randomScheduler.rbac.create -}}
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  name: {{ include "theodolite.fullname" . }}-random-scheduler
+subjects:
+- kind: ServiceAccount
+  name: {{ include "theodolite.fullname" . }}-random-scheduler
+  namespace: kube-system
+roleRef:
+  kind: ClusterRole
+  apiGroup: rbac.authorization.k8s.io
+  name: system:kube-scheduler
+{{- end }}
diff --git a/execution/helm/templates/theodolite/random-scheduler/deployment.yaml b/execution/helm/templates/theodolite/random-scheduler/deployment.yaml
new file mode 100644
index 000000000..a1ea535d5
--- /dev/null
+++ b/execution/helm/templates/theodolite/random-scheduler/deployment.yaml
@@ -0,0 +1,30 @@
+{{- if .Values.randomScheduler.enabled -}}
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ include "theodolite.fullname" . }}-random-scheduler
+  labels:
+    app: {{ include "theodolite.fullname" . }}
+    component: random-scheduler
+  namespace: kube-system
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: {{ include "theodolite.fullname" . }}
+      component: random-scheduler
+  template:
+    metadata:
+      labels:
+        app: {{ include "theodolite.fullname" . }}
+        component: random-scheduler
+    spec:
+      serviceAccount: {{ include "theodolite.fullname" . }}-random-scheduler
+      containers:
+        - name: random-scheduler
+          image: ghcr.io/cau-se/theodolite-random-scheduler:latest
+          #imagePullPolicy: Always
+          env:
+            - name: TARGET_NAMESPACE
+              value: {{ .Release.Namespace }}
+{{- end }}
diff --git a/execution/helm/templates/theodolite/random-scheduler/service-account.yaml b/execution/helm/templates/theodolite/random-scheduler/service-account.yaml
new file mode 100644
index 000000000..babfff17b
--- /dev/null
+++ b/execution/helm/templates/theodolite/random-scheduler/service-account.yaml
@@ -0,0 +1,10 @@
+{{- if .Values.randomScheduler.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  namespace: kube-system
+  name: {{ include "theodolite.fullname" . }}-random-scheduler 
+  labels:
+    app: {{ include "theodolite.fullname" . }}
+    component: random-scheduler
+{{- end }}
diff --git a/execution/helm/values.yaml b/execution/helm/values.yaml
index 67dab74c3..4e95e735e 100644
--- a/execution/helm/values.yaml
+++ b/execution/helm/values.yaml
@@ -248,3 +248,10 @@ serviceAccount:
 
 rbac:
   create: true
+
+randomScheduler:
+  enabled: true
+  rbac:
+    create: true
+  serviceAccount:
+    create: true
-- 
GitLab