diff --git a/helm-charts-datalab/doccano/.helmignore b/helm-charts-datalab/doccano/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/helm-charts-datalab/doccano/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/helm-charts-datalab/doccano/Chart.yaml b/helm-charts-datalab/doccano/Chart.yaml new file mode 100644 index 0000000..4aefdcf --- /dev/null +++ b/helm-charts-datalab/doccano/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: doccano +appVersion: 1.8.0 +version: 2.0.7 +description: A Helm chart for doccano, Open source text annotation tool for machine learning practitioner. +home: https://doccano.herokuapp.com/ +icon: https://raw.githubusercontent.com/doccano/doccano/master/docs/images/logo/doccano.png +sources: + - https://github.com/doccano/doccano +maintainers: + - name: armandleopold + email: armand.leopold@curie.fr +kubeVersion: ">= 1.14.0-0" +dependencies: + - name: postgresql + condition: postgresql.installAsDependency + repository: https://charts.bitnami.com/bitnami + version: 11.8.1 +keywords: + - annotation + - ml + - text + - machine-learning +annotations: + artifacthub.io/images: | + - name: doccano + image: doccano/doccano:1.8.0 diff --git a/helm-charts-datalab/doccano/LICENSE b/helm-charts-datalab/doccano/LICENSE new file mode 100644 index 0000000..66b4051 --- /dev/null +++ b/helm-charts-datalab/doccano/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Institut Curie + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/helm-charts-datalab/doccano/README.md b/helm-charts-datalab/doccano/README.md new file mode 100644 index 0000000..48c9e06 --- /dev/null +++ b/helm-charts-datalab/doccano/README.md @@ -0,0 +1,61 @@ +# Doccano + +Doccano is an open source text annotation tool for humans. It provides annotation features for text classification, sequence labeling and sequence to sequence tasks. So, you can create labeled data for sentiment analysis, named entity recognition, text summarization and so on. Just create a project, upload data and start annotating. You can build a dataset in hours. + +To get more informations : + +* [Github Source Code](https://github.com/doccano/doccano) +* [Dockerhub Docker Image](https://hub.docker.com/r/doccano/doccano) + +## Installing the Chart + +Before you can install the chart you will need to add the `curiedfcharts` repo to [Helm](https://helm.sh/). + +```shell +helm repo add curiedfcharts https://curie-data-factory.github.io/helm-charts +helm repo update +``` + +After you've installed the repo you can install the chart. + +```shell +helm upgrade --install --namespace default --values ./my-values.yaml my-release curiedfcharts/doccano +``` + +## Configuration + +The following table lists the configurable parameters of the chart and their default values. + +| Parameter | Description | Default | +|----------------------------------|----------------------------------------------------------------------|---------------------------------------------------------------------| +| `image.replicaCount` | Number of replicas to create | `1` | +| `image.repository` | Image repository. | `doccano/doccano` | +| `image.tag` | Image Tag. | `1.2.2` | +| `image.pullPolicy` | Image pull policy. | `IfNotPresent` | +| `image.name` | Image name | `doccano` | +| `image.deployRegistry` | If the image is stored in a private registry | `false` | +| `image.imagePullSecrets` | Docker registry credentials Secret name | `registrysecret` | +| `image.dataSecret` | Secret storing docker image registry credentials | `{"auths":{"registry.compagny.com":{"password":"","username":""}}}` | +| `env.ADMIN_EMAIL` | Doccano Admin Email | `admin@company.com` | +| `env.ADMIN_USERNAME` | Doccano Admin Username | `admin` | +| `deploySecret` | Wether or not to deploy the secret containing Doccano ADMIN_PASSWORD | `true` | +| `ADMIN_PASSWORD` | Doccano Admin Password | `password` | +| `service.type` | Service Type | `ClusterIP` | +| `service.targetPort` | Service Port | `8000` | +| `service.protocol` | Service Protocol | `TCP` | +| `ingress.enabled` | Expose application with ingress | `true` | +| `ingress.hostnames` | Urls of exposed application | `['doccano.company.com']` | +| `ingress.path` | Path through ingress | `/` | +| `ingress.tls` | Array of TLS Hosts | `[]` | +| `ingress.tls[hosts]` | Host name | `['doccano.company.com']` | +| `ingress.tls[hosts[secretName]]` | Secret for the current host name | `doccano` | +| `persistence.enabled` | Enable persisting data on PVC | `false` | +| `persistence.existingClaim` | Does PVC already exist ? | `false` | +| `persistence.size` | PVC Size | `10Gi` | +| `persistence.storageClass` | PVC storage class | `nil` | +| `persistence.accessMode` | PVC Access Mode | `ReadWriteOnce` | +| `persistence.replicas` | PVC storage class replicas (if possible) | `1` | +| `persistence.volumeName` | Directory name | `data` | +| `persistence.mountPath` | Directory mount path | `/data` | +| `postgresql.installAsDependency` | Install Postgres as a subchart (disable to use an external instance) | `true` | +| `postgresql.host` | Host of the external Postgres instance (if not using internal one) | `nil` | diff --git a/helm-charts-datalab/doccano/templates/_helpers.tpl b/helm-charts-datalab/doccano/templates/_helpers.tpl new file mode 100644 index 0000000..74278f9 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "doccano.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "doccano.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "doccano.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "doccano.labels" -}} +app.kubernetes.io/name: {{ include "doccano.name" . }} +helm.sh/chart: {{ include "doccano.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Create postgres host. +*/}} +{{- define "doccano.postgres_host" -}} +{{- if .Values.postgresql.installAsDependency -}} +{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 -}} +{{- else -}} +{{- .Values.postgresql.host -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/helm-charts-datalab/doccano/templates/configmap.yaml b/helm-charts-datalab/doccano/templates/configmap.yaml new file mode 100644 index 0000000..b8db500 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/configmap.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-conf + namespace: {{ .Release.Namespace }} +data: + bootstrap.sh: |- + #!/bin/bash + cd /doccano + export PATH=$PATH:/home/doccano/.local/bin + # install dependency + python -m pip install doccano=={{ .Values.image.tag }} + python -m pip install 'doccano[postgresql]=={{ .Values.image.tag }}' + # Initialize database. + doccano init + # Create a super user. + doccano createuser --username admin --password {{ .Values.ADMIN_PASSWORD }} + + # Start Task Thread + doccano task & + + # Start web server. + doccano webserver --port 8000 diff --git a/helm-charts-datalab/doccano/templates/deployment.yaml b/helm-charts-datalab/doccano/templates/deployment.yaml new file mode 100644 index 0000000..cd5eec9 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/deployment.yaml @@ -0,0 +1,87 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: "{{ .Release.Name }}-{{ .Values.image.name }}" + labels: + app: "{{ .Release.Name }}-{{ .Values.image.name }}" + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +{{ include "doccano.labels" . | indent 4 }} +spec: + strategy: + type: Recreate + replicas: {{ .Values.image.replicaCount }} + selector: + matchLabels: + app: "{{ .Release.Name }}-{{ .Values.image.name }}" + release: {{ .Release.Name }} + template: + metadata: + labels: + app: "{{ .Release.Name }}-{{ .Values.image.name }}" + release: {{ .Release.Name }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} + spec: + containers: + - args: + - /bin/bash + - /config/bootstrap.sh + env: + - name: ADMIN_EMAIL + value: {{ .Values.env.ADMIN_EMAIL }} + - name: ADMIN_USERNAME + value: {{ .Values.env.ADMIN_USERNAME }} + - name: ADMIN_PASSWORD + valueFrom: + secretKeyRef: + key: ADMIN_PASSWORD + name: doccano-password + optional: false + - name: DATABASE_URL + value: "postgres://{{ .Values.postgresql.global.postgresql.auth.username }}:{{ .Values.postgresql.global.postgresql.auth.password }}@{{ include "doccano.postgres_host" . }}:5432/{{ .Values.postgresql.global.postgresql.auth.database }}?sslmode=disable" + {{- if .Values.extraEnv }} + {{- with .Values.extraEnv }} +{{ toYaml . | indent 8 }} + {{- end }} + {{- end }} + name: {{ .Values.image.name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.targetPort }} + name: {{ .Values.service.targetPort }}{{ .Values.service.protocol | lower }} + protocol: {{ .Values.service.protocol }} + volumeMounts: + - mountPath: {{ .Values.persistence.mountPath }} + name: {{ .Values.persistence.volumeName }} + - mountPath: /config + name: bootstrap + initContainers: + - args: + - chown + - "1000:1000" + - {{ .Values.persistence.mountPath }} + image: busybox + imagePullPolicy: IfNotPresent + name: chmod + volumeMounts: + - mountPath: {{ .Values.persistence.mountPath }} + name: {{ .Values.persistence.volumeName }} + volumes: + - configMap: + defaultMode: 0777 + items: + - key: bootstrap.sh + path: ./bootstrap.sh + name: {{ .Release.Name }}-conf + optional: false + name: bootstrap + - name: {{ .Values.persistence.volumeName }} + persistentVolumeClaim: + claimName: "{{ .Release.Name }}-{{ .Values.persistence.volumeName }}" + {{- if .Values.image.deployRegistry }} + imagePullSecrets: + - name: "{{ .Values.image.name }}-{{ .Values.image.imagePullSecrets }}" + {{- end }} diff --git a/helm-charts-datalab/doccano/templates/ingress.yaml b/helm-charts-datalab/doccano/templates/ingress.yaml new file mode 100644 index 0000000..1a49152 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/ingress.yaml @@ -0,0 +1,37 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := print .Release.Name "-" .Values.image.name }} +{{- $servicePort := print .Values.service.targetPort .Values.service.protocol | lower -}} + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Values.image.name }} + labels: + app: {{ .Values.image.name }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +{{- if .Values.ingress.annotations }} + annotations: +{{ toYaml .Values.ingress.annotations | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} +{{- end }} + rules: +{{- $path := .Values.ingress.path -}} +{{- range .Values.ingress.hostnames }} + - host: "{{ . }}" + http: + paths: + - path: {{ $path }} + pathType: Prefix + backend: + service: + name: {{ $serviceName }} + port: + name: {{ $servicePort }} +{{- end }} +{{- end -}} diff --git a/helm-charts-datalab/doccano/templates/password.yaml b/helm-charts-datalab/doccano/templates/password.yaml new file mode 100644 index 0000000..9c3beb9 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/password.yaml @@ -0,0 +1,10 @@ +{{- if .Values.deploySecret -}} +apiVersion: v1 +kind: Secret +type: Opaque +data: + ADMIN_PASSWORD: {{ .Values.ADMIN_PASSWORD | b64enc }} +metadata: + name: doccano-password + namespace: {{ .Release.Namespace }} +{{- end -}} diff --git a/helm-charts-datalab/doccano/templates/registry.yaml b/helm-charts-datalab/doccano/templates/registry.yaml new file mode 100644 index 0000000..76b1b19 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/registry.yaml @@ -0,0 +1,10 @@ +{{- if .Values.image.deployRegistry -}} +apiVersion: v1 +kind: Secret +type: kubernetes.io/dockerconfigjson +metadata: + name: "{{ .Values.image.name }}-{{ .Values.image.imagePullSecrets }}" + namespace: {{ .Release.Namespace }} +data: + .dockerconfigjson: {{ .Values.image.dataSecret | b64enc }} +{{- end -}} diff --git a/helm-charts-datalab/doccano/templates/service.yaml b/helm-charts-datalab/doccano/templates/service.yaml new file mode 100644 index 0000000..fb1ac96 --- /dev/null +++ b/helm-charts-datalab/doccano/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: "{{ .Release.Name }}-{{ .Values.image.name }}" +spec: + type: {{ .Values.service.type }} + ports: + - name: {{ .Values.service.targetPort }}{{ .Values.service.protocol | lower }} + port: {{ .Values.service.targetPort }} + protocol: {{ .Values.service.protocol }} + targetPort: {{ .Values.service.targetPort }} + selector: + app: "{{ .Release.Name }}-{{ .Values.image.name }}" + release: {{ .Release.Name }} diff --git a/helm-charts-datalab/doccano/templates/volume.yaml b/helm-charts-datalab/doccano/templates/volume.yaml new file mode 100644 index 0000000..bcabd1a --- /dev/null +++ b/helm-charts-datalab/doccano/templates/volume.yaml @@ -0,0 +1,30 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: "{{ .Release.Name }}-{{ .Values.persistence.volumeName }}" + namespace: {{ .Release.Namespace }} +{{- with .Values.persistence.annotations }} + annotations: + helm.sh/resource-policy: "keep" +{{ toYaml . | indent 4 }} +{{- end }} + labels: + app: "{{ .Release.Name }}" + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/helm-charts-datalab/doccano/values.yaml b/helm-charts-datalab/doccano/values.yaml new file mode 100644 index 0000000..de88695 --- /dev/null +++ b/helm-charts-datalab/doccano/values.yaml @@ -0,0 +1,57 @@ +image: + replicaCount: 1 + repository: doccano/doccano + tag: "1.8.0" + pullPolicy: IfNotPresent + name: doccano + deployRegistry: false + imagePullSecrets: registrysecret + dataSecret: |- + {"auths":{"registry.localhost":{"password":"","username":""}}} + +env: + ADMIN_EMAIL: admin@localhost + ADMIN_USERNAME: admin + +deploySecret: true +ADMIN_PASSWORD: password + +service: + type: ClusterIP + targetPort: 8000 + protocol: TCP + +ingress: + enabled: true + path: / + hostnames: + - doccano.localhost + tls: + + hosts: + - host: test.lab.groupe-genes.fr + paths: + - path: / + pathType: ImplementationSpecific + +persistence: + enabled: true + existingClaim: false + size: 10Gi + accessMode: "ReadWriteOnce" + volumeName: "data" + mountPath: /data + + annotations: + helm.sh/resource-policy: keep + +postgresql: + installAsDependency: true + image: + tag: 11.14.0-debian-10-r28 + global: + postgresql: + auth: + database: doccano + username: doccano + password: 58sdf9hgd1gs8sdfzerJHFdf