diff --git a/helm/tube/.helmignore b/helm/tube/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/helm/tube/.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/tube/Chart.lock b/helm/tube/Chart.lock new file mode 100644 index 00000000..61db5789 --- /dev/null +++ b/helm/tube/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 11.2.6 +digest: sha256:8d81dea9e85adbdff90d46721aa22b33c4cf66282432d20bbfb7335b77a73eef +generated: "2022-05-23T15:48:59.956941-05:00" diff --git a/helm/tube/Chart.yaml b/helm/tube/Chart.yaml new file mode 100644 index 00000000..40b6d366 --- /dev/null +++ b/helm/tube/Chart.yaml @@ -0,0 +1,29 @@ +apiVersion: v2 +name: tube +description: A Helm chart for Kubernetes + +# 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. +appVersion: 2022.05 + +dependencies: + - name: "postgresql" + repository: https://charts.bitnami.com/bitnami + version: 11.2.6 + condition: postgres.enabled diff --git a/helm/tube/charts/postgresql-11.2.6.tgz b/helm/tube/charts/postgresql-11.2.6.tgz new file mode 100644 index 00000000..66d9495c Binary files /dev/null and b/helm/tube/charts/postgresql-11.2.6.tgz differ diff --git a/helm/tube/templates/NOTES.txt b/helm/tube/templates/NOTES.txt new file mode 100644 index 00000000..304ff546 --- /dev/null +++ b/helm/tube/templates/NOTES.txt @@ -0,0 +1 @@ +{{ .Chart.Name }} has been deployed successfully. \ No newline at end of file diff --git a/helm/tube/templates/_helpers.tpl b/helm/tube/templates/_helpers.tpl new file mode 100644 index 00000000..7342f3fe --- /dev/null +++ b/helm/tube/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "tube.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 "tube.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 "tube.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "tube.labels" -}} +helm.sh/chart: {{ include "tube.chart" . }} +{{ include "tube.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "tube.selectorLabels" -}} +app.kubernetes.io/name: {{ include "tube.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "tube.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "tube.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/tube/templates/deployment.yaml b/helm/tube/templates/deployment.yaml new file mode 100644 index 00000000..1cab7e66 --- /dev/null +++ b/helm/tube/templates/deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tube-deployment + labels: + {{- include "tube.labels" . | nindent 4 }} +spec: + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + selector: + matchLabels: + {{- include "tube.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "tube.labels" . | nindent 8 }} + spec: + volumes: + {{- toYaml .Values.volumes | nindent 8 }} + containers: + - name: tube + image: "quay.io/cdis/tube:2021.12" + imagePullPolicy: Always + ports: + - containerPort: 80 + resources: + {{- toYaml .Values.resources | nindent 12 }} + command: ["/bin/bash"] + args: + - "-c" + - | + python run_config.py + while true; do sleep 5; done + env: + {{- toYaml .Values.env | nindent 12 }} + volumeMounts: + {{- toYaml .Values.volumeMounts | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm/tube/templates/etl-mapping.yaml b/helm/tube/templates/etl-mapping.yaml new file mode 100644 index 00000000..ea939a3c --- /dev/null +++ b/helm/tube/templates/etl-mapping.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: etl-mapping +data: + etlMapping.yaml: {{ .Values.etl_mapping | default "None" }} diff --git a/helm/tube/templates/ingress.yaml b/helm/tube/templates/ingress.yaml new file mode 100644 index 00000000..cbeb0851 --- /dev/null +++ b/helm/tube/templates/ingress.yaml @@ -0,0 +1,40 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "tube.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "tube.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/helm/tube/templates/tests/test-connection.yaml b/helm/tube/templates/tests/test-connection.yaml new file mode 100644 index 00000000..3cee67a5 --- /dev/null +++ b/helm/tube/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "tube.fullname" . }}-test-connection" + labels: + {{- include "tube.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "tube.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm/tube/test.yml b/helm/tube/test.yml new file mode 100644 index 00000000..2850f7a0 --- /dev/null +++ b/helm/tube/test.yml @@ -0,0 +1,90 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tube-deployment + labels: + helm.sh/chart: tube-0.1.0 + app.kubernetes.io/name: tube + app.kubernetes.io/instance: tube + app.kubernetes.io/version: "2021.12" + app.kubernetes.io/managed-by: Helm +spec: + selector: + matchLabels: + app.kubernetes.io/name: tube + app.kubernetes.io/instance: tube + template: + metadata: + labels: + app.kubernetes.io/name: tube + app.kubernetes.io/instance: tube + spec: + automountServiceAccountToken: false + volumes: + - name: creds-volume + secret: + secretName: "peregrine-creds" + - name: etl-mapping + configMap: + name: etl-mapping + - name: fence-yaml + configMap: + name: fence + containers: + - name: tube + imagePullPolicy: Always + GEN3_TUBE_IMAGE + ports: + - containerPort: 80 + env: + - name: DICTIONARY_URL + valueFrom: + configMapKeyRef: + name: manifest-global + key: dictionary_url + - name: HADOOP_URL + value: hdfs://spark-service:9000 + - name: ES_URL + value: esproxy-service + - name: HADOOP_HOST + value: spark-service + - name: HADOOP_CLIENT_OPTS + value: -Xmx1g + - name: SPARK_EXECUTOR_MEMORY + value: 4g + - name: SPARK_DRIVER_MEMORY + value: 6g + volumeMounts: + - name: "creds-volume" + readOnly: true + mountPath: "/gen3/tube/creds.json" + subPath: creds.json + - name: "etl-mapping" + readOnly: true + mountPath: "/gen3/tube/etlMapping.yaml" + subPath: "etlMapping.yaml" + - name: "fence-yaml" + mountPath: "/gen3/tube/user.yaml" + subPath: user.yaml + resources: + limits: + cpu: 1 + memory: 12Gi + command: ["/bin/bash" ] + args: + - "-c" + - | + python run_config.py + while true; do sleep 5; done + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - tube + topologyKey: "kubernetes.io/hostname" \ No newline at end of file diff --git a/helm/tube/tube.yaml b/helm/tube/tube.yaml new file mode 100644 index 00000000..f640187e --- /dev/null +++ b/helm/tube/tube.yaml @@ -0,0 +1,103 @@ +--- +# Source: tube/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tube + labels: + helm.sh/chart: tube-0.1.0 + app.kubernetes.io/name: tube + app.kubernetes.io/instance: tube + app.kubernetes.io/version: "2022.05" + app.kubernetes.io/managed-by: Helm +spec: + selector: + # Only select pods based on the 'app' label + matchLabels: + app.kubernetes.io/name: tube + app.kubernetes.io/instance: tube + template: + metadata: + labels: + helm.sh/chart: tube-0.1.0 + app.kubernetes.io/name: tube + app.kubernetes.io/instance: tube + app.kubernetes.io/version: "2022.05" + app.kubernetes.io/managed-by: Helm + revisionHistoryLimit: 2 + template: + metadata: + labels: + app: tube + netnolimit: "yes" + spec: + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - tube + topologyKey: "kubernetes.io/hostname" + automountServiceAccountToken: false + volumes: + - name: creds-volume + secret: + secretName: "peregrine-creds" + - name: etl-mapping + configMap: + name: etl-mapping + - name: fence-yaml + configMap: + name: fence + containers: + - name: tube + imagePullPolicy: Always + image: "quay.io/cdis/tube:2021.12" + ports: + - containerPort: 80 + env: + - name: DICTIONARY_URL + valueFrom: + configMapKeyRef: + name: manifest-global + key: dictionary_url + - name: HADOOP_URL + value: hdfs://spark-service:9000 + - name: ES_URL + value: esproxy-service + - name: HADOOP_HOST + value: spark-service + - name: HADOOP_CLIENT_OPTS + value: -Xmx1g + - name: SPARK_EXECUTOR_MEMORY + value: 4g + - name: SPARK_DRIVER_MEMORY + value: 6g + volumeMounts: + - name: "creds-volume" + readOnly: true + mountPath: "/gen3/tube/creds.json" + subPath: creds.json + - name: "etl-mapping" + readOnly: true + mountPath: "/gen3/tube/etlMapping.yaml" + subPath: "etlMapping.yaml" + - name: "fence-yaml" + mountPath: "/gen3/tube/user.yaml" + subPath: user.yaml + resources: + limits: + cpu: 1 + memory: 12Gi + command: ["/bin/bash" ] + args: + - "-c" + - | + python run_config.py + while true; do sleep 5; done + \ No newline at end of file diff --git a/helm/tube/values.yaml b/helm/tube/values.yaml new file mode 100644 index 00000000..2169d8bc --- /dev/null +++ b/helm/tube/values.yaml @@ -0,0 +1,152 @@ +# +# Gloabl values +# + +global: + postgresql: + auth: + postgresPassword: "password!123" # pragma: allowlist secret + database: "peregrine" + + +# Default values for tube. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: quay.io/cdis/tube + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + annotations: { + nginx.ingress.kubernetes.io/rewrite-target: /$2, + kubernetes.io/ingress.class: "nginx" + } + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: ingress.local + paths: + - path: "/user(/|$)(.*)" + pathType: Prefix + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: + limits: + cpu: 1.0 + memory: 12Gi + + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + +nodeSelector: {} + +tolerations: [] + +labels: + app: tube + release: production + # for network policy selectors + authprovider: "yes" + # uses explicit proxy and AWS APIs + netnolimit: "yes" + public: "yes" + userhelper: "yes" + tags.datadoghq.com/service: "tube" + tags.datadoghq.com/env: qaplanetv1 + tags.datadoghq.com/version: 2021.12 +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app + operator: In + values: + - tube + topologyKey: "kubernetes.io/hostname" + +env: + - name: DICTIONARY_URL + valueFrom: + configMapKeyRef: + name: manifest-global + key: dictionary_url + - name: HADOOP_URL + value: hdfs://spark-service:9000 + - name: ES_URL + value: esproxy-service + - name: HADOOP_HOST + value: spark-service + - name: HADOOP_CLIENT_OPTS + value: -Xmx1g + - name: SPARK_EXECUTOR_MEMORY + value: 4g + - name: SPARK_DRIVER_MEMORY + value: 6g + + +volumes: + - name: creds-volume + secret: + secretName: "peregrine-creds" + - name: etl-mapping + configMap: + name: etl-mapping + - name: fence-yaml + configMap: + name: fence + +volumeMounts: + - name: "creds-volume" + readOnly: true + mountPath: "/gen3/tube/creds.json" + subPath: creds.json + - name: "etl-mapping" + readOnly: true + mountPath: "/gen3/tube/etlMapping.yaml" + subPath: "etlMapping.yaml" + - name: "fence-yaml" + mountPath: "/gen3/tube/user.yaml" + subPath: user.yaml + +selectorLabels: + app: tube + release: production + + +# Whether or not to deploy a local postgres pod +postgres: + enabled: false + +etl_mapping: