diff --git a/charts/hail-search/.helmignore b/charts/hail-search/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/hail-search/.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/charts/hail-search/Chart.yaml b/charts/hail-search/Chart.yaml new file mode 100644 index 00000000..3912015c --- /dev/null +++ b/charts/hail-search/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: hail-search +description: A Helm chart for deploying the hail backend of Seqr, an open source software platform for rare disease genomics +sources: + - https://github.com/broadinstitute/seqr + - https://github.com/broadinstitute/seqr-helm + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "ee4afa08ee1190ac05ef06543adcb1833f5e2e8e" diff --git a/charts/hail-search/templates/_helpers.tpl b/charts/hail-search/templates/_helpers.tpl new file mode 100644 index 00000000..cea805d1 --- /dev/null +++ b/charts/hail-search/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "hail-search.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 "hail-search.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 "hail-search.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "hail-search.labels" -}} +helm.sh/chart: {{ include "hail-search.chart" . }} +{{ include "hail-search.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "hail-search.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hail-search.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/hail-search/templates/deployment.yaml b/charts/hail-search/templates/deployment.yaml new file mode 100644 index 00000000..ac706146 --- /dev/null +++ b/charts/hail-search/templates/deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hail-search.fullname" . }} + labels: + {{- include "hail-search.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "hail-search.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/datasetVersions: {{ print $.Values.datasetVersions | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hail-search.selectorLabels" . | nindent 8 }} + spec: + volumes: + - name: datasets + emptyDir: + # Default sizeLimit is 1/2 the total RAM of the Node. + medium: "Memory" + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 6 }} + {{- end }} + containers: + - name: {{ include "hail-search.fullname" . }}-pod + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "hail-search.fullname" . }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + initialDelaySeconds: 10 + periodSeconds: 30 + failureThreshold: 5 + httpGet: + path: /status + port: http + readinessProbe: + initialDelaySeconds: 10 + periodSeconds: 30 + failureThreshold: 5 + httpGet: + path: /status + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: {{ .Values.environment.DATASETS_DIR }} + name: datasets + restartPolicy: Always + dnsPolicy: ClusterFirst + {{- with .Values.initContainers}} + initContainers: + {{- tpl . $ | trim | nindent 8}} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- tpl . $ | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/hail-search/templates/environment.yaml b/charts/hail-search/templates/environment.yaml new file mode 100644 index 00000000..946f5d81 --- /dev/null +++ b/charts/hail-search/templates/environment.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "hail-search.fullname" . }} + labels: + {{- include "hail-search.labels" . | nindent 4 }} +data: + {{- with .Values.environment }} + {{- toYaml . | nindent 2 }} + {{- end }} diff --git a/charts/hail-search/templates/service.yaml b/charts/hail-search/templates/service.yaml new file mode 100644 index 00000000..26316591 --- /dev/null +++ b/charts/hail-search/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hail-search.fullname" . }} + labels: + {{- include "hail-search.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "hail-search.selectorLabels" . | nindent 4 }} diff --git a/charts/hail-search/values.yaml b/charts/hail-search/values.yaml new file mode 100644 index 00000000..3b70586b --- /dev/null +++ b/charts/hail-search/values.yaml @@ -0,0 +1,70 @@ +# Default values for hail-search. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 4 + +image: + repository: gcr.io/seqr-project/seqr-hail-search + pullPolicy: Always + # -- The docker image tag to pull from the repository + # tag: "gcloud-dev" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +service: + type: ClusterIP + port: 5000 + +resources: + {} + +# default environment variables +environment: + DATASETS_DIR: '/datasets' + +initContainers: |- + {{- range $path, $version := .Values.global.hail_search.datasetVersions -}} + {{ if $version }} + - name: sync-datasets-{{ $path }} + image: gcr.io/google.com/cloudsdktool/google-cloud-cli:latest + command: ['gsutil', '-m', 'rsync', '-r', '{{ $.Values.global.hail_search.sourceDatasetsDir }}/{{ $path }}/runs/{{ $version }}', '{{ $.Values.environment.DATASETS_DIR }}/{{ $path }}'] + volumeMounts: + - mountPath: {{ $.Values.environment.DATASETS_DIR }} + name: datasets + {{ end }} + {{ end }} + +# Prefer to be scheduled away from other hail-search pods and seqr application pods +affinity: |- + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1.0 + podAffinityTerm: + labelSelector: + matchLabels: + {{- include "hail-search.selectorLabels" . | nindent 12 }} + topologyKey: "kubernetes.io/hostname" + - weight: 1.0 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: "name" + operator: In + values: + - seqr + topologyKey: "kubernetes.io/hostname" + +nodeSelector: + {} + +global: + hail_search: + sourceDatasetsDir: '' + datasetVersions: + GRCh37/SNV_INDEL: '' + GRCh38/SNV_INDEL: '' diff --git a/charts/seqr/templates/check-for-new-samples-from-pipeline.yaml b/charts/seqr/templates/check-for-new-samples-from-pipeline.yaml new file mode 100644 index 00000000..f8646e9a --- /dev/null +++ b/charts/seqr/templates/check-for-new-samples-from-pipeline.yaml @@ -0,0 +1,44 @@ +{{- range $path, $version := .Values.global.hail_search.datasetVersions -}} +{{ if $version }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "seqr.fullname" $ }}-check-new-samples-job + labels: + {{- include "seqr.labels" $ | nindent 4 }} + annotations: + "helm.sh/hook": post-install, post-upgrade + "helm.sh/hook-weight": "-1" + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded + {{- with $.Values.podAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + template: + metadata: + labels: + {{- include "seqr.labels" $ | nindent 8 }} + spec: + {{- with $.Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + restartPolicy: Never + {{- with $.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 6 }} + {{- end }} + containers: + - name: {{ include "seqr.fullname" $ }}-check-new-samples-job-pod + image: {{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }} + imagePullPolicy: {{ $.Values.image.pullPolicy }} + {{- with $.Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + command: ["python", "manage.py", "check_for_new_samples_from_pipeline", "{{ $path }}", "{{ $version }}"] + {{- with $.Values.deployment_sidecars }} + {{- tpl . $ | nindent 6 }} + {{- end }} +{{ end }} +{{ end }} diff --git a/charts/seqr/values.yaml b/charts/seqr/values.yaml index 2f2a9bf7..359a8d0f 100644 --- a/charts/seqr/values.yaml +++ b/charts/seqr/values.yaml @@ -181,3 +181,10 @@ run_seqr_database_migration: false redis: # -- enables or disables redis deployment using this chart enabled: false + +global: + hail_search: + sourceDatasetsDir: '' + datasetVersions: + GRCh37/SNV_INDEL: '' + GRCh38/SNV_INDEL: ''