From bed36a7dd2459e23326c0fef27a92d51a2c0a5c2 Mon Sep 17 00:00:00 2001 From: sido Date: Thu, 20 Sep 2018 20:42:35 +0200 Subject: [PATCH 1/2] added opencpu stack --- molgenis-opencpu/.helmignore | 21 ++++++++++ molgenis-opencpu/Chart.yaml | 8 ++++ molgenis-opencpu/README.md | 38 +++++++++++++++++ molgenis-opencpu/catalog-molgenis-opencpu.svg | 1 + molgenis-opencpu/questions.yml | 21 ++++++++++ molgenis-opencpu/templates/_helpers.tpl | 32 +++++++++++++++ molgenis-opencpu/templates/deployment.yaml | 35 ++++++++++++++++ molgenis-opencpu/templates/ingress.yaml | 36 ++++++++++++++++ molgenis-opencpu/templates/service.yaml | 20 +++++++++ molgenis-opencpu/values.yaml | 41 +++++++++++++++++++ 10 files changed, 253 insertions(+) create mode 100644 molgenis-opencpu/.helmignore create mode 100644 molgenis-opencpu/Chart.yaml create mode 100644 molgenis-opencpu/README.md create mode 100644 molgenis-opencpu/catalog-molgenis-opencpu.svg create mode 100644 molgenis-opencpu/questions.yml create mode 100644 molgenis-opencpu/templates/_helpers.tpl create mode 100644 molgenis-opencpu/templates/deployment.yaml create mode 100644 molgenis-opencpu/templates/ingress.yaml create mode 100644 molgenis-opencpu/templates/service.yaml create mode 100644 molgenis-opencpu/values.yaml diff --git a/molgenis-opencpu/.helmignore b/molgenis-opencpu/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/molgenis-opencpu/.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/molgenis-opencpu/Chart.yaml b/molgenis-opencpu/Chart.yaml new file mode 100644 index 0000000..0ffe477 --- /dev/null +++ b/molgenis-opencpu/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +appVersion: "1.0" +description: Opencpu stack for MOLGENIS +name: molgenis-opencpu +version: 0.1.1 +sources: +- https://git.webhosting.rug.nl/molgenis/molgenis-ops-docker-helm.git +icon: https://git.webhosting.rug.nl/molgenis/molgenis-ops-docker-helm/raw/master/molgenis-opencpu/catalogIcon-molgenis-opencpu.svg \ No newline at end of file diff --git a/molgenis-opencpu/README.md b/molgenis-opencpu/README.md new file mode 100644 index 0000000..e871170 --- /dev/null +++ b/molgenis-opencpu/README.md @@ -0,0 +1,38 @@ +# MOLGENIS - OpenCPU Helm Chart + +NEXUS repository for kubernetes to deploy on a kubernetes cluster with NFS-share + +## Containers + +This chart will deploy the following containers: + +- OpenCPU +- MOLGENIS-httpd (to proxy the registry and docker to one domain) + +## Provisioning +You can choose for the OpenCPU image from which repository you want to pull. Experimental builds are pushed to registry.molgenis.org and the stable builds to hub.docker.com. +You need to fill out 2 properties to determine which repository you are going to use. + +- ```opencpu.image.repository``` +- ```opencpu.image.tag``` + +You can do this in the questions in Rancher or in the ```values.yaml```. + + + +## Development +You can test in install the chart by executing: + +```helm lint .``` + +To test if your helm chart-syntax is right and: + +```helm install . --dry-run --debug``` + +To test if your hem chart works and: + +```helm install .``` + +To deploy it on the cluster. + + diff --git a/molgenis-opencpu/catalog-molgenis-opencpu.svg b/molgenis-opencpu/catalog-molgenis-opencpu.svg new file mode 100644 index 0000000..fc9ca38 --- /dev/null +++ b/molgenis-opencpu/catalog-molgenis-opencpu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/molgenis-opencpu/questions.yml b/molgenis-opencpu/questions.yml new file mode 100644 index 0000000..fba8a05 --- /dev/null +++ b/molgenis-opencpu/questions.yml @@ -0,0 +1,21 @@ + +categories: +- MOLGENIS +questions: +- variable: opencpu.image.repository + label: Registry + default: "registry.hub.docker.com" + description: "Select a registry to pull from" + type: enum + options: + - "registry.hub.docker.com" + - "registry.molgenis.org" + required: true + group: "Provisioning" +- variable: opencpu.image.tag + label: Version + default: "" + description: "Select a OpenCPU version (check the registry.molgenis.org or hub.docker.com for released tags)" + type: string + required: true + group: "Provisioning" \ No newline at end of file diff --git a/molgenis-opencpu/templates/_helpers.tpl b/molgenis-opencpu/templates/_helpers.tpl new file mode 100644 index 0000000..a410c46 --- /dev/null +++ b/molgenis-opencpu/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "opencpu.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 "opencpu.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 "opencpu.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/molgenis-opencpu/templates/deployment.yaml b/molgenis-opencpu/templates/deployment.yaml new file mode 100644 index 0000000..ddb57c7 --- /dev/null +++ b/molgenis-opencpu/templates/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + {{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} + {{- end }} + name: {{ template "opencpu.fullname" . }} + labels: + app: {{ template "opencpu.name" . }} + chart: {{ template "opencpu.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "opencpu.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "opencpu.name" . }} + release: {{ .Release.Name }} + spec: + containers: + {{- with .Values.opencpu }} + - name: {{ .name }} + image: "{{ .image.repository }}/{{ .image.name }}:{{ .image.tag }}" + imagePullPolicy: {{ .image.pullPolicy }} + ports: + - containerPort: {{ .service.port }} + {{- end }} + + diff --git a/molgenis-opencpu/templates/ingress.yaml b/molgenis-opencpu/templates/ingress.yaml new file mode 100644 index 0000000..d218231 --- /dev/null +++ b/molgenis-opencpu/templates/ingress.yaml @@ -0,0 +1,36 @@ +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: "{{ $.Release.Name }}-ingress" + labels: + app: {{ $.Values.opencpu.name }} + chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" + release: "{{ $.Release.Name }}" + heritage: "{{ $.Release.Service }}" + annotations: + {{- if .tls }} + ingress.kubernetes.io/secure-backends: "true" + {{- end }} + {{- range $key, $value := .annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + - host: {{ .name }} + http: + paths: + - path: {{ default "/" .path }} + backend: + serviceName: {{ $.Values.opencpu.service.name }} + servicePort: {{ $.Values.opencpu.service.port }} +{{- if .tls }} + tls: + - hosts: + - {{ .name }} + secretName: {{ .tlsSecret }} +{{- end }} +--- +{{- end }} +{{- end }} \ No newline at end of file diff --git a/molgenis-opencpu/templates/service.yaml b/molgenis-opencpu/templates/service.yaml new file mode 100644 index 0000000..4b1cf1e --- /dev/null +++ b/molgenis-opencpu/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.opencpu.service.name }} + labels: + app: {{ .Values.opencpu.service.name }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.opencpu.service.type }} + loadBalancerSourceRanges: + {{- range $index, $rule := .Values.opencpu.service.firewall }} + - {{ $rule }} + {{- end }} + ports: + - name: {{ .Values.opencpu.service.name }} + port: {{ .Values.opencpu.service.port }} + selector: + app: {{ template "opencpu.name" . }} + release: {{ .Release.Name }} diff --git a/molgenis-opencpu/values.yaml b/molgenis-opencpu/values.yaml new file mode 100644 index 0000000..227de88 --- /dev/null +++ b/molgenis-opencpu/values.yaml @@ -0,0 +1,41 @@ +# Default values for nexus. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +environment: production + +opencpu: + name: opencpu + strategy: + type: Recreate + restartPolicy: Always + image: + repository: registry.hub.docker.com + name: molgenis/opencpu + tag: stable + pullPolicy: Always + service: + name: opencpu + type: LoadBalancer + port: 8004 + firewall: + - 145.100.224.1/24 + +ingress: + enabled: true + annotations: { + kubernetes.io/ingress.class: "nginx", + nginx.ingress.kubernetes.io/proxy-body-size: "0" + } + path: / + hosts: + - name: opencpu.molgenis.org + tls: [] + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 1ed41d6c36367f35a8513b499b3d5cf7b045edfe Mon Sep 17 00:00:00 2001 From: sido Date: Tue, 25 Sep 2018 23:32:25 +0200 Subject: [PATCH 2/2] updated chart to enable and disable ingress on demand --- molgenis-opencpu/questions.yml | 7 +++++++ molgenis-opencpu/values.yaml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/molgenis-opencpu/questions.yml b/molgenis-opencpu/questions.yml index fba8a05..736aac5 100644 --- a/molgenis-opencpu/questions.yml +++ b/molgenis-opencpu/questions.yml @@ -2,6 +2,13 @@ categories: - MOLGENIS questions: +- variable: ingress.enabled + label: Enable ingress + default: false + description: "Enable ingress" + type: boolean + required: true + group: "Loadbalancing" - variable: opencpu.image.repository label: Registry default: "registry.hub.docker.com" diff --git a/molgenis-opencpu/values.yaml b/molgenis-opencpu/values.yaml index 227de88..c21be14 100644 --- a/molgenis-opencpu/values.yaml +++ b/molgenis-opencpu/values.yaml @@ -24,7 +24,7 @@ opencpu: - 145.100.224.1/24 ingress: - enabled: true + enabled: false annotations: { kubernetes.io/ingress.class: "nginx", nginx.ingress.kubernetes.io/proxy-body-size: "0"