Skip to content

Commit fc3662e

Browse files
authored
build: update Helm chart (#101)
* Edit Helm Chart - Add resources - Add a key to change the storage mode - if RWO, the prowes pods will be deployed on the same nodes * Add initResources * Fix min requests * Update mongodb and rabbitMQ * Fix secrets * Update Chart.yaml version * Fix * Add NOTES.txt * Fix NOTES.txt
1 parent 59b53a4 commit fc3662e

File tree

14 files changed

+193
-127
lines changed

14 files changed

+193
-127
lines changed

deployment/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: prowes
33
description: A proWES Helm chart for Kubernetes
44
type: application
5-
version: 0.1.0
6-
appVersion: 1.16.0
5+
version: 2.0.0
6+
appVersion: 2.0.0

deployment/README.md

Lines changed: 20 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
- [Kubernetes deployment for proWES](#kubernetes-deployment-for-wes)
44
- [Usage](#usage)
55
- [Updates](#updates)
6-
- [Using with an external MongoDB](#using-with-an-external-mongodb)
7-
- [Setting up RabbitMQ for testing on OpenShift](#setting-up-rabbitmq-for-testing-on-openshift)
86
- [Technical details](#technical-details)
97
- [MongoDB](#mongodb)
108
- [RabbitMQ](#rabbitmq)
@@ -53,95 +51,46 @@ Create a Kubernetes Secret from the `.netrc` file:
5351
kubectl create secret generic netrc --from-file .netrc
5452
```
5553

56-
After this you can deploy proWES using `kubectl`:
54+
You need to edit the `values.yaml` file to specify your `applicationDomain` and the `clusterType`
5755

58-
```bash
59-
cd deployment/common/wes
60-
ls wes-* | xargs -L1 kubectl create -f
61-
```
62-
63-
Once proWES is deployed, you can expose it with the YAML files found under
64-
`deployment/ingress`. Which file to use depends on your cluster and how ingress
65-
is configured there.
66-
67-
Creating an OpenShift Route:
56+
After this you can deploy proWES using `helm`:
6857

6958
```bash
70-
cd deployment/ingress
71-
oc create -f wes-route.yaml
59+
helm install prowes . -f values.yaml
7260
```
7361

7462
### Updates
7563

76-
If you make changes to any of the Deployments, you can update them with
77-
`kubectl`. For example, this is how you would update the Celery worker Deployment:
64+
If you want to edit any of the Deployments, you can update them with
65+
`helm` and the `values.yaml` file. Once edited, you can run this command:
7866

7967
```bash
80-
kubectl replace -f wes-celery-deployment.yaml
68+
helm upgrade prowes . -f values.yaml
8169
```
8270

83-
The OpenShift specific objects need to be updated using the `oc` tool instead.
84-
Also, if you update the Route you must use the `--force` flag. This removes and
85-
recreates the Route.
86-
8771
If you want to point to a different FTP server or change the login credentials
8872
for the current FTP server, you can update the `.netrc` secret like so:
8973

9074
```bash
9175
kubectl create secret generic netrc --from-file .netrc --dry-run -o yaml | kubectl apply -f -
9276
```
9377

94-
If you want to update the configuration, you can update the ConfigMap or use a
95-
different ConfigMap with the same name. The Deployments expect to find the
96-
`app_config.yaml` ConfigMap with the name `wes-config`. You can update the
97-
ConfigMap like so:
98-
99-
```bash
100-
kubectl replace -f wes-configmap.yaml
101-
```
102-
103-
### Using with an external MongoDB
104-
105-
In certain situations, you may want to run an external MongoDB. There is an
106-
example headless service file for this case under `deployment/mongodb`.
107-
108-
Make a copy of the example Service:
109-
110-
```bash
111-
cd deployment/mongodb
112-
cp mongodb-service-external.yaml.example mongodb-service-external.yaml
113-
```
114-
115-
Edit the `mongodb-service-external.yaml` file and under `externalName` add your
116-
external MongoDB's host name. After this, create the Service:
117-
118-
```bash
119-
kubectl create -f mongodb-service-external.yaml
120-
```
78+
## Technical details
12179

122-
It is assumed that the external MongoDB already has a database called
123-
`prowes-db` created and a user with read-write access available. Next you
124-
will need to configure the MongoDB user and password in a secret (replace
125-
`<username>` and `<password>`):
80+
### MongoDB
12681

127-
```bash
128-
kubectl create secret generic mongodb --from-literal=database-user=<username> --from-literal=database-password=<password>
129-
```
82+
The MongoDB database is deployed using:
13083

131-
Depending on your MongoDB provider, the port may differ from 27017. In this
132-
case, you will need to modify the Deployment files accordingly to use the
133-
correct port (replace `<my external mongodb port>`):
84+
- `templates/mongodb/mongodb-deployment.yaml`
13485

135-
```bash
136-
cd deployment/common
137-
find . -name *.yaml | xargs -L1 sed -i -e 's/27017/<my external mongodb port>/g'
138-
```
86+
### RabbitMQ
13987

140-
After this you can deploy proWES (see above).
88+
The message broker RabbitMQ that allows the app to communicate with the worker
89+
is deployed using:
14190

142-
## Technical details
91+
- `templates/rabbitmq/rabbitmq-deployment.yaml`
14392

144-
### ApplicaWES
93+
### WES
14594

14695
proWES consists of five deployments: a Flask server and a Celery worker. These
14796
are deployed using:
@@ -150,22 +99,14 @@ are deployed using:
15099
- `templates/prowes/celery-deployment.yaml`
151100

152101
These deployments depend on setting up a shared ReadWriteMany volume between
153-
Flask and Celery (`wes-volume.yaml`) and a shared ConfigMap
154102
(`wes-configmap.yaml`).
155103

156-
### MongoDB
157104

158-
The MongoDB database is deployed using:
159-
160-
- `templates/mongodb/mongodb-deployment.yaml`
161-
162-
### RabbitMQ
105+
## Destroy
163106

164-
The message broker RabbitMQ that allows the app to communicate with the worker
165-
is deployed using:
107+
Simply run:
166108

167-
- `templates/rabbitmq/rabbitmq-deployment.yaml`
109+
```bash
110+
helm uninstall prowes
111+
```
168112

169-
The disadvantage with this template is that it only works with OpenShift because
170-
it uses objects that are only available in OpenShift. For plain Kubernetes a
171-
different approach needs to be used.

deployment/templates/NOTES.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Elixir Cloud proWES is being deployed!
2+
3+
Once deployed:
4+
5+
1. Access the API via https://{{ .Values.prowes.appName }}.{{ .Values.applicationDomain }}/ga4gh/wes/v1/
6+
7+
To test the connection, you can run:
8+
9+
curl -X GET "https://{{ .Values.prowes.appName }}.{{ .Values.applicationDomain }}/ga4gh/wes/v1/service-info" -H "Accept: application/json"
10+
11+
2. Access the Swagger UI via https://{{ .Values.prowes.appName }}.{{ .Values.applicationDomain }}/ga4gh/wes/v1/ui

deployment/templates/flower/flower-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ spec:
1919
command: ['flower']
2020
args: ['--broker=amqp://guest:guest@rabbitmq:5672//', '--port=5555', '--basic_auth={{ .Values.flower.basicAuth }}']
2121
name: flower
22+
resources: {{- toYaml .Values.flower.resources | nindent 10 }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: mongo-init-script
5+
data:
6+
init-script.js: |
7+
db = db.getSiblingDB('runStore');
8+
dbproWES = db.getSiblingDB('{{ tpl .Values.mongodb.secret.databaseName . }}')
9+
10+
dbproWES.createUser({
11+
user: "{{ tpl .Values.mongodb.secret.databaseUser . }}",
12+
pwd: "{{ tpl .Values.mongodb.secret.databasePassword . }}",
13+
roles: [
14+
{
15+
role: "readWrite",
16+
db: "{{ tpl .Values.mongodb.secret.databaseName . }}"
17+
}
18+
]
19+
});
20+
21+
// Create the 'runs' and 'service_info' collections
22+
// Database configuration from https://github.com/elixir-cloud-aai/proWES/blob/59b53a4bdd06dd83ff41754b27d97309073ed237/pro_wes/config.yaml#L30
23+
db.createCollection('runs');
24+
db.runs.createIndex(
25+
{ run_id: 1, task_id: 1 },
26+
{ unique: true, sparse: true }
27+
);
28+
db.createCollection('service_info');
29+
db.service_info.createIndex(
30+
{ id: 1 }
31+
);
32+
33+
dbproWES.createCollection('runs');
34+
dbproWES.runs.createIndex(
35+
{ run_id: 1, task_id: 1 },
36+
{ unique: true, sparse: true }
37+
);
38+
dbproWES.createCollection('service_info');
39+
dbproWES.service_info.createIndex(
40+
{ id: 1}
41+
);

deployment/templates/mongodb/mongodb-deployment.yaml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,30 @@ spec:
1616
spec:
1717
containers:
1818
- env:
19-
- name: MONGODB_USER
19+
- name: MONGO_INITDB_ROOT_USERNAME
2020
valueFrom:
2121
secretKeyRef:
22-
key: database-user
22+
key: databaseRootUsername
2323
name: {{ .Values.mongodb.appName }}
24-
- name: MONGODB_PASSWORD
24+
- name: MONGO_INITDB_ROOT_PASSWORD
2525
valueFrom:
2626
secretKeyRef:
27-
key: database-password
27+
key: databaseRootPassword
2828
name: {{ .Values.mongodb.appName }}
29-
- name: MONGODB_ADMIN_PASSWORD
29+
- name: MONGO_INITDB_DATABASE
3030
valueFrom:
3131
secretKeyRef:
32-
key: database-admin-password
32+
key: databaseName
3333
name: {{ .Values.mongodb.appName }}
34-
- name: MONGODB_DATABASE
34+
- name: MONGO_APP_USERNAME
3535
valueFrom:
3636
secretKeyRef:
37-
key: database-name
37+
key: databaseUser
38+
name: {{ .Values.mongodb.appName }}
39+
- name: MONGO_APP_PASSWORD
40+
valueFrom:
41+
secretKeyRef:
42+
key: databasePassword
3843
name: {{ .Values.mongodb.appName }}
3944
image: {{ .Values.mongodb.image }}
4045
imagePullPolicy: IfNotPresent
@@ -57,20 +62,23 @@ spec:
5762
- '-i'
5863
- '-c'
5964
- >-
60-
mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p
61-
$MONGODB_PASSWORD --eval="quit()"
65+
mongosh --host 127.0.0.1:27017 -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin $MONGO_INITDB_DATABASE --eval="quit()"
6266
failureThreshold: 3
63-
initialDelaySeconds: 3
67+
initialDelaySeconds: 30
6468
periodSeconds: 10
6569
successThreshold: 1
66-
timeoutSeconds: 1
67-
resources:
68-
limits:
69-
memory: 512Mi
70+
timeoutSeconds: 50
71+
resources: {{- toYaml .Values.mongodb.resources | nindent 12 }}
7072
volumeMounts:
71-
- mountPath: /var/lib/mongodb/data
73+
- mountPath: /data/db
7274
name: mongodb-data
75+
- name: init-script
76+
mountPath: /docker-entrypoint-initdb.d/init-script.js
77+
subPath: init-script.js
7378
volumes:
7479
- name: mongodb-data
7580
persistentVolumeClaim:
7681
claimName: {{ .Values.mongodb.appName }}-volume
82+
- name: init-script
83+
configMap:
84+
name: mongo-init-script

deployment/templates/mongodb/mongodb-pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: {{ .Values.mongodb.appName }}-volume
55
spec:
66
accessModes:
7-
- ReadWriteMany
7+
- {{ .Values.storageAccessMode }}
88
resources:
99
requests:
1010
storage: {{ .Values.mongodb.volumeSize }}

deployment/templates/mongodb/mongodb-secret.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type: Opaque
44
metadata:
55
name: {{ .Values.mongodb.appName }}
66
data:
7-
database-admin-password: {{ .Values.mongodb.databaseAdminPassword | b64enc }}
8-
database-name: {{ .Values.mongodb.databaseName | b64enc }}
9-
database-password: {{ .Values.mongodb.databasePassword | b64enc }}
10-
database-user: {{ .Values.mongodb.databaseUser | b64enc }}
7+
{{- range $key, $val := .Values.mongodb.secret }}
8+
"{{ $key }}": "{{ tpl $val $ | b64enc }}"
9+
{{- end }}
10+

deployment/templates/prowes/celery-deployment.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spec:
1616
image: busybox
1717
command: [ 'mkdir' ]
1818
args: [ '-p', '/data/db', '/data/output', '/data/tmp' ]
19+
resources: {{- toYaml .Values.celeryWorker.initResources | nindent 10 }}
1920
volumeMounts:
2021
- mountPath: /data
2122
name: prowes-volume
@@ -34,29 +35,23 @@ spec:
3435
- name: MONGO_USERNAME
3536
valueFrom:
3637
secretKeyRef:
37-
key: database-user
38+
key: databaseUser
3839
name: {{ .Values.mongodb.appName }}
3940
- name: MONGO_PASSWORD
4041
valueFrom:
4142
secretKeyRef:
42-
key: database-password
43+
key: databasePassword
4344
name: {{ .Values.mongodb.appName }}
4445
- name: MONGO_DBNAME
4546
valueFrom:
4647
secretKeyRef:
47-
key: database-name
48+
key: databaseName
4849
name: {{ .Values.mongodb.appName }}
4950
- name: RABBIT_HOST
5051
value: {{ .Values.rabbitmq.appName }}
5152
- name: RABBIT_PORT
5253
value: "5672"
53-
resources:
54-
requests:
55-
memory: "512Mi"
56-
cpu: "300m"
57-
limits:
58-
memory: "8Gi"
59-
cpu: "1"
54+
resources: {{- toYaml .Values.celeryWorker.resources | nindent 10 }}
6055
volumeMounts:
6156
- mountPath: /data
6257
name: prowes-volume

0 commit comments

Comments
 (0)