diff --git a/helm/cam/.gitignore b/helm/cam/.gitignore new file mode 100644 index 0000000..bacdc8e --- /dev/null +++ b/helm/cam/.gitignore @@ -0,0 +1,3 @@ +**/requirements.lock +**/requirements.yaml.bak +**/*.tgz diff --git a/helm/cam/.helmignore b/helm/cam/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/cam/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/cam/Chart.yaml b/helm/cam/Chart.yaml new file mode 100644 index 0000000..4c584ad --- /dev/null +++ b/helm/cam/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: cam +description: "CAM: The Comparative Argument Machine" +type: application +home: https://demo.webis.de/cam/ +sources: +- https://github.com/webis-de/cam +icon: https://assets.webis.de/img/webis-logo-gray.svg +maintainers: # (optional) +- name: Jan Heinrich Reimer + email: jan.reimer@student.uni-halle.de +- name: Alexander Bondarenko + email: alexander.bondarenko@informatik.uni-halle.de + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: 0.1.0 + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.0 diff --git a/helm/cam/README.md b/helm/cam/README.md new file mode 100644 index 0000000..e7b47d0 --- /dev/null +++ b/helm/cam/README.md @@ -0,0 +1,3 @@ +# CAM: The Comparative Argument Machine + +Helm chart for installing CAM on a Kubernetes cluster. diff --git a/helm/cam/templates/NOTES.txt b/helm/cam/templates/NOTES.txt new file mode 100644 index 0000000..526d77c --- /dev/null +++ b/helm/cam/templates/NOTES.txt @@ -0,0 +1,4 @@ +# TODO: Add instructions on how to get service IP addresses. + +# You may overwrite the `{{ .Release.Name }}-elasticsearch-login` secret: +kubectl create secret generic {{ .Release.Name }}-elasticsearch-login --from-literal=username=USERNAME --from-literal=password=PASSWORD \ No newline at end of file diff --git a/helm/cam/templates/backend-config-map.yml b/helm/cam/templates/backend-config-map.yml new file mode 100644 index 0000000..0af217c --- /dev/null +++ b/helm/cam/templates/backend-config-map.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-backend-config-map +data: + config.json: | + { + "use_heuristics": {{ .Values.backend.useHeuristics }}, + "elasticsearch": { + "url": "https://{{ .Values.elasticsearch.host }}:{{ .Values.elasticsearch.port }}", + "index_arguments": "{{ .Values.elasticsearch.indices.arguments }}" + "index_suggestions": "{{ .Values.elasticsearch.indices.suggestions }}" + } + } diff --git a/helm/cam/templates/backend-deployment.yml b/helm/cam/templates/backend-deployment.yml new file mode 100644 index 0000000..b580b80 --- /dev/null +++ b/helm/cam/templates/backend-deployment.yml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: {{ .Release.Name }}-backend + name: {{ .Release.Name }}-backend +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-backend + replicas: {{ .Values.backend.replicas }} + template: + metadata: + labels: + app: {{ .Release.Name }}-backend + spec: + containers: + - name: {{ .Release.Name }}-backend + image: {{ .Values.backend.image }} + resources: + requests: + memory: 15Gi + env: + - name: ES_USERNAME + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-elasticsearch-login + key: username + - name: ES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-elasticsearch-login + key: password + volumeMounts: + - name: {{ .Release.Name }}-backend-models + mountPath: /app/data/glove.840B.300d.txt + subPath: glove.840B.300d.txt + readOnly: true + - name: {{ .Release.Name }}-backend-models + mountPath: /app/data/infersent.allnli.pickle + subPath: infersent.allnli.pickle + readOnly: true + - name: {{ .Release.Name }}-backend-config + mountPath: /app/config.json + subPath: config.json + restartPolicy: Always + volumes: + - name: {{ .Release.Name }}-backend-models + hostPath: + path: {{ .Values.backend.modelsPath }} + type: Directory + - name: {{ .Release.Name }}-backend-config + configMap: + name: {{ .Release.Name }}-backend-config-map diff --git a/helm/cam/templates/backend-service.yml b/helm/cam/templates/backend-service.yml new file mode 100644 index 0000000..b42a236 --- /dev/null +++ b/helm/cam/templates/backend-service.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-backend +spec: + type: NodePort + selector: + app: {{ .Release.Name }}-backend + ports: + - nodePort: {{ .Values.backend.port }} + port: 5000 + targetPort: 5000 diff --git a/helm/cam/templates/elasticsearch-login.yaml b/helm/cam/templates/elasticsearch-login.yaml new file mode 100644 index 0000000..19222ea --- /dev/null +++ b/helm/cam/templates/elasticsearch-login.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-elasticsearch-login +type: Opaque +data: + username: {{ b64enc .Values.elasticsearch.username }} + password: {{ b64enc .Values.elasticsearch.password }} \ No newline at end of file diff --git a/helm/cam/templates/frontend-config-map.yml b/helm/cam/templates/frontend-config-map.yml new file mode 100644 index 0000000..5bcd3b7 --- /dev/null +++ b/helm/cam/templates/frontend-config-map.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-frontend-config-map +data: + environment.ts: | + export const environment = { + production: true, + apiUrl: '{{ .Values.backend.url }}cam', + suggestionsElasticsearchUrl: '{{ .Values.backend.url }}suggestions' + }; diff --git a/helm/cam/templates/frontend-deployment.yml b/helm/cam/templates/frontend-deployment.yml new file mode 100644 index 0000000..acc094b --- /dev/null +++ b/helm/cam/templates/frontend-deployment.yml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + service: {{ .Release.Name }}-frontend + name: {{ .Release.Name }}-frontend +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-frontend + replicas: {{ .Values.frontend.replicas }} + template: + metadata: + labels: + app: {{ .Release.Name }}-frontend + spec: + containers: + - name: {{ .Release.Name }}-frontend + image: {{ .Values.frontend.image }} + volumeMounts: + - name: {{ .Release.Name }}-frontend-config + mountPath: /usr/src/app/src/environments/environment.ts + subPath: environment.ts + restartPolicy: Always + volumes: + - name: {{ .Release.Name }}-frontend-config + configMap: + name: {{ .Release.Name }}-frontend-config-map \ No newline at end of file diff --git a/helm/cam/templates/frontend-service.yml b/helm/cam/templates/frontend-service.yml new file mode 100644 index 0000000..5d9243b --- /dev/null +++ b/helm/cam/templates/frontend-service.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-frontend +spec: + type: NodePort + selector: + app: {{ .Release.Name }}-frontend + ports: + - nodePort: {{ .Values.frontend.port }} + port: 4200 + targetPort: 4200 diff --git a/helm/cam/todo.md b/helm/cam/todo.md new file mode 100644 index 0000000..8bd6efa --- /dev/null +++ b/helm/cam/todo.md @@ -0,0 +1,8 @@ +# ToDo's for Kubernetes/Helm deployment + +- [x] Fix Docker images locally. + - [x] Frontend + - [x] Backend +- [x] Publish Docker images (e.g. to the [GitHub Package registry](https://github.com/features/packages) or [Docker Hub](https://hub.docker.com)). +- [ ] Improve Kubernetes configurability +- [ ] Setup [GitHub Actions](https://github.com/features/actions) for automatic deployments. \ No newline at end of file diff --git a/helm/cam/values.yaml b/helm/cam/values.yaml new file mode 100644 index 0000000..aae1543 --- /dev/null +++ b/helm/cam/values.yaml @@ -0,0 +1,27 @@ +# Default values for CAM. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +frontend: +# url: https://demo.webis.de/cam/ + port: 30294 + image: webis/cam-frontend:0.1.3 + replicas: 3 + +backend: + url: https://demo.webis.de/cam-api/ + port: 30293 + image: webis/cam-backend:0.1.3 + replicas: 3 + # Paths of models on each host's file system. + modelsPath: /mnt/ceph/storage/data-in-progress/cam/models/ + useHeuristics: true + +elasticsearch: + host: betaweb001.bw.webis.de + port: 30920 + username: "" # Override username with `--set elasticsearch.username=EXAMPLE` Helm option. + password: "" # Override username with `--set elasticsearch.password=EXAMPLE` Helm option. + indices: + arguments: depcc + suggestions: suggestions-index diff --git a/helm/deploy.sh b/helm/deploy.sh new file mode 100644 index 0000000..8decbc6 --- /dev/null +++ b/helm/deploy.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Print Helm template. +helm template cam cam --set elasticsearch.username=reader --set elasticsearch.password=reader + +# Install Helm chart. +helm install cam cam --set elasticsearch.username=reader --set elasticsearch.password=reader