diff --git a/README.md b/README.md index 4b8c26d..5ed5b96 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ This repository is serves also as a catalogue for Rancher. We have serveral apps - [Jenkins](molgenis-jenkins/README.md) - [NEXUS](molgenis-nexus/README.md) - [HTTPD](molgenis-httpd/README.md) +- [MOLNIGES preview](molgenis-preview/README.md) ### Useful commands You can you need to know to easily develop and deploy helm-charts @@ -116,7 +117,7 @@ You can you need to know to easily develop and deploy helm-charts Check if your configuration deploys on a kubernetes cluster and check the configuration -- ```helm install .``` +- ```helm install . #release name# --namespace #remote namespace#``` Do it in the root of the project where the Chart.yaml is located It installs a release of a kubernetes stack. You also store this as an artifact in a kubernetes repository @@ -126,4 +127,13 @@ You can you need to know to easily develop and deploy helm-charts - ```helm delete #release#``` Performs a sort of mvn clean on your workspace. Very handy for zombie persistent volumes or claims. - \ No newline at end of file + +- ```install tiller on remote cluster``` + + To install tiller on a remote cluster you need an rbac-config.yml. + ```kubectl create -f rbac-config.yaml``` + + When you have defined the yaml you can add the tiller to the cluster by following the steps below. + ```helm init --service-account tiller``` + + diff --git a/molgenis-nexus/templates/services/httpd-service.yaml b/molgenis-nexus/templates/services/httpd-service.yaml index 5b3d939..7067ecb 100644 --- a/molgenis-nexus/templates/services/httpd-service.yaml +++ b/molgenis-nexus/templates/services/httpd-service.yaml @@ -5,7 +5,7 @@ metadata: labels: app: {{ .Values.httpd.name }} spec: - type: NodePort + type: {{ .Values.httpd.service.type }} ports: - name: {{ .Values.httpd.name }} port: {{ .Values.httpd.port }} diff --git a/molgenis-nexus/templates/services/nexus-service.yaml b/molgenis-nexus/templates/services/nexus-service.yaml index bc0fda7..dbb9371 100644 --- a/molgenis-nexus/templates/services/nexus-service.yaml +++ b/molgenis-nexus/templates/services/nexus-service.yaml @@ -5,7 +5,7 @@ metadata: labels: app: {{ .Values.nexus.name }} spec: - type: ClusterIP + type: {{ .Values.nexus.service.type }} ports: - name: ui port: {{ .Values.nexus.port.ui }} diff --git a/molgenis-nexus/values.yaml b/molgenis-nexus/values.yaml index 32c193c..23b2454 100644 --- a/molgenis-nexus/values.yaml +++ b/molgenis-nexus/values.yaml @@ -6,10 +6,6 @@ replicaCount: 1 environment: production -service: - type: NodePort - port: 80 - nexus: name: nexus strategy: @@ -25,6 +21,8 @@ nexus: ui: 8081 path: dockerV2: v2 + service: + type: ClusterIP httpd: name: httpd @@ -38,6 +36,8 @@ httpd: tag: lts pullPolicy: Always port: 80 + service: + type: LoadBalancer ingress: diff --git a/molgenis-preview/.helmignore b/molgenis-preview/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/molgenis-preview/.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-preview/Chart.yaml b/molgenis-preview/Chart.yaml new file mode 100644 index 0000000..071bc2d --- /dev/null +++ b/molgenis-preview/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: molgenis +version: 0.1.0 diff --git a/molgenis-preview/README.md b/molgenis-preview/README.md new file mode 100644 index 0000000..25dad2f --- /dev/null +++ b/molgenis-preview/README.md @@ -0,0 +1,11 @@ +# MOLGENIS preview +Is used for integration testing purposes. + +## Containers +This chart spins up a complete stack to run MOLGENIS. The created containers are: + +- MOLGENIS +- PostgreSQL +- Elasticsearch +- OpenCPU + diff --git a/molgenis-preview/templates/NOTES.txt b/molgenis-preview/templates/NOTES.txt new file mode 100644 index 0000000..b5a4d24 --- /dev/null +++ b/molgenis-preview/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "molgenis.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "molgenis.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "molgenis.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "molgenis.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/molgenis-preview/templates/_helpers.tpl b/molgenis-preview/templates/_helpers.tpl new file mode 100644 index 0000000..e7cf3ea --- /dev/null +++ b/molgenis-preview/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "molgenis.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 "molgenis.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 "molgenis.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/molgenis-preview/templates/deployment.yaml b/molgenis-preview/templates/deployment.yaml new file mode 100644 index 0000000..8eab288 --- /dev/null +++ b/molgenis-preview/templates/deployment.yaml @@ -0,0 +1,120 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "molgenis.fullname" . }} + labels: + app: {{ template "molgenis.name" . }} + chart: {{ template "molgenis.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "molgenis.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "molgenis.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: molgenis + {{- with .Values.molgenis }} + image: "{{ .image.repository }}:{{ .image.tag }}" + imagePullPolicy: {{ .image.pullPolicy }} + env: + - name: molgenis.home + value: /home/molgenis + - name: opencpu.uri.host + value: localhost + - name: elasticsearch.transport.addresses + value: localhost:9300 + - name: elasticsearch.cluster.name + value: {{ $.Values.elasticsearch.clusterName }} + - name: db_uri + value: "jdbc:postgresql://localhost/{{ $.Values.postgres.db }}" + - name: db_user + value: {{ $.Values.postgres.user }} + - name: db_password + value: {{ $.Values.postgres.password }} + - name: admin.password + value: {{ .adminPassword }} + - name: CATALINA_OPTS + value: "{{ .javaOpts }}" + ports: + - containerPort: 8080 +# livenessProbe: +# httpGet: +# path: / +# port: 8080 +# readinessProbe: +# httpGet: +# path: /api/v2/version +# port: 8080 + resources: +{{ toYaml .resources | indent 12 }} + {{- end }} + + - name: elasticsearch + {{- with .Values.elasticsearch }} + image: "{{ .image.repository }}:{{ .image.tag }}" + imagePullPolicy: {{ .image.pullPolicy }} + env: + - name: cluster.name + value: {{ .clusterName }} + - name: bootstrap.memory_lock + value: "true" + - name: ES_JAVA_OPTS + value: "{{ .javaOpts }}" + - name: xpack.security.enabled + value: "false" + - name: discovery.type + value: single-node + ports: + - containerPort: 9200 + - containerPort: 9300 + resources: +{{ toYaml .resources | indent 12 }} + {{- end }} + + - name: postgres + {{- with .Values.postgres }} + image: "{{ .image.repository }}:{{ .image.tag }}" + imagePullPolicy: {{ .image.pullPolicy }} + env: + - name: POSTGRES_USER + value: {{ .user }} + - name: POSTGRES_PASSWORD + value: {{ .password }} + - name: POSTGRES_DB + value: {{ .db }} + ports: + - containerPort: 5432 + resources: +{{ toYaml .resources | indent 12 }} + {{- end }} + + - name: opencpu + {{- with .Values.opencpu }} + image: "{{ .image.repository }}:{{ .image.tag }}" + imagePullPolicy: {{ .image.pullPolicy }} + ports: + - containerPort: 8004 + resources: +{{ toYaml .resources | indent 12 }} + {{- end }} + + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/molgenis-preview/templates/ingress.yaml b/molgenis-preview/templates/ingress.yaml new file mode 100644 index 0000000..6fdfb0c --- /dev/null +++ b/molgenis-preview/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "molgenis.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "molgenis.name" . }} + chart: {{ template "molgenis.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: 8080 + {{- end }} +{{- end }} diff --git a/molgenis-preview/templates/service.yaml b/molgenis-preview/templates/service.yaml new file mode 100644 index 0000000..26d1322 --- /dev/null +++ b/molgenis-preview/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "molgenis.fullname" . }} + labels: + app: {{ template "molgenis.name" . }} + chart: {{ template "molgenis.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - name: molgenis + port: {{ .Values.service.port }} + selector: + app: {{ template "molgenis.name" . }} + release: {{ .Release.Name }} diff --git a/molgenis-preview/test.yaml b/molgenis-preview/test.yaml new file mode 100644 index 0000000..ed0e0fe --- /dev/null +++ b/molgenis-preview/test.yaml @@ -0,0 +1,120 @@ +# Source: molgenis/templates/deployment.yaml +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: lanky-ragdoll-molgenis + labels: + app: molgenis + chart: molgenis-0.1.0 + release: lanky-ragdoll + heritage: Tiller +spec: + replicas: 1 + selector: + matchLabels: + app: molgenis + release: lanky-ragdoll + template: + metadata: + labels: + app: molgenis + release: lanky-ragdoll + spec: + containers: + - name: molgenis + image: "registry.molgenis.org/molgenis/molgenis-app:latest" + imagePullPolicy: Always + env: + - name: molgenis.home + value: /home/molgenis + - name: opencpu.uri.host + value: opencpu + - name: elasticsearch.transport.addresses + value: elasticsearch:9300 + - name: elasticsearch.cluster.name + value: molgenis + - name: db_uri + value: "jdbc:postgresql://postgres/molgenis" + - name: db_user + value: molgenis + - name: db_password + value: molgenis + - name: admin.password + value: admin + - name: CATALINA_OPTS + value: "-Xmx1g -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled" + ports: + - containerPort: 8080 + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: /api/v2/version + port: http + resources: + limits: + cpu: 1 + memory: 1250Mi + requests: + cpu: 200m + memory: 1Gi + + + - name: elasticsearch + image: "docker.elastic.co/elasticsearch/elasticsearch:5.5.3" + imagePullPolicy: IfNotPresent + env: + - name: cluster.name + value: molgenis + - name: bootstrap.memory_lock + value: true + - name: ES_JAVA_OPTS + value: "-Xms512m -Xmx512m" + - name: xpack.security.enabled + value: false + - name: discovery.type + value: single-node + ports: + - containerPort: 9200 + - containerPort: 9300 + limits: + cpu: 1 + memory: 1500Mi + requests: + cpu: 100m + memory: 1Gi + + + - name: postgres + image: "postgres:9.6-alpine" + imagePullPolicy: IfNotPresent + env: + - name: POSTGRES_USER + value: molgenis + - name: POSTGRES_PASSWORD + value: molgenis + - name: POSTGRES_DB + value: molgenis + ports: + - containerPort: 5432 + limits: + cpu: 1 + memory: 250Mi + requests: + cpu: 100m + memory: 250Mi + + + - name: opencpu + image: "molgenis/opencpu:latest" + imagePullPolicy: Always + ports: + - containerPort: 8004 + limits: + cpu: 1 + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi \ No newline at end of file diff --git a/molgenis-preview/values.yaml b/molgenis-preview/values.yaml new file mode 100644 index 0000000..3e0ebff --- /dev/null +++ b/molgenis-preview/values.yaml @@ -0,0 +1,82 @@ +# Default values for molgenis. + +replicaCount: 1 + +service: + type: LoadBalancer + port: 8080 + +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - test.molgenis.org + tls: [] + +molgenis: + image: + repository: registry.molgenis.org/molgenis/molgenis-app + tag: 7.0.0-SNAPSHOT + pullPolicy: Always + adminPassword: admin + javaOpts: "-Xmx1g -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled" + resources: + limits: + cpu: 1 + memory: 1250Mi + requests: + cpu: 200m + memory: 1Gi + +postgres: + image: + repository: postgres + tag: 9.6-alpine + pullPolicy: IfNotPresent + user: molgenis + password: molgenis + db: molgenis + resources: + limits: + cpu: 1 + memory: 250Mi + requests: + cpu: 100m + memory: 250Mi + +elasticsearch: + image: + repository: docker.elastic.co/elasticsearch/elasticsearch + tag: 5.5.3 + pullPolicy: IfNotPresent + javaOpts: "-Xms512m -Xmx512m" + clusterName: molgenis + resources: + limits: + cpu: 1 + memory: 1500Mi + requests: + cpu: 100m + memory: 1Gi + +opencpu: + image: + repository: molgenis/opencpu + tag: latest + pullPolicy: Always + resources: + limits: + cpu: 1 + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/rbac-config.yml b/rbac-config.yml new file mode 100644 index 0000000..c5ae63a --- /dev/null +++ b/rbac-config.yml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: tiller + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: tiller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: + - kind: ServiceAccount + name: tiller + namespace: kube-system