Skip to content

Commit fab2b58

Browse files
authored
feat(service): horizontal scaling (#3178)
1 parent b6919e2 commit fab2b58

File tree

15 files changed

+225
-136
lines changed

15 files changed

+225
-136
lines changed

chartpress.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ charts:
1515
buildArgs:
1616
CLEAN_INSTALL: "1"
1717
BUILD_CORE_SERVICE: "1"
18+

helm-chart/renku-core/templates/configmap.yaml

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,9 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: {{ include "renku-core.fullname" . }}-nginx
4+
name: {{ include "renku-core.fullname" . }}-metadata-versions
55
data:
6-
nginx-server-blocks.conf: |
7-
{{- range $version := .Values.versions }}
8-
upstream {{ $version.name }} {
9-
server {{ include "renku-core.fullname" $ }}-{{ $version.name }};
10-
keepalive 32;
11-
keepalive_timeout 60s;
12-
}
13-
{{ end }}
14-
15-
server {
16-
listen 8080;
17-
18-
server_name {{ include "renku-core.fullname" . }};
19-
20-
sendfile on;
21-
tcp_nopush on;
22-
client_max_body_size 0; # Required for uploading large files
23-
24-
location /renku/version {
25-
root /;
26-
add_header Content-Type application/json;
27-
try_files /usr/share/nginx/html/version.json =404;
28-
}
29-
30-
{{- range $version := .Values.versions }}
31-
location /renku/{{ $version.prefix }} {
32-
rewrite /renku/{{ $version.prefix }}/(.*) /renku/$1 break;
33-
proxy_set_header Host $host;
34-
proxy_pass http://{{ $version.name }};
35-
proxy_send_timeout {{ $.Values.requestTimeout }}s;
36-
proxy_read_timeout {{ $.Values.requestTimeout }}s;
37-
proxy_http_version 1.1;
38-
proxy_set_header "Connection" "";
39-
}
40-
{{- end }}
41-
42-
location /renku {
43-
proxy_set_header Host $host;
44-
proxy_pass http://{{ .Values.versions.latest.name }};
45-
proxy_send_timeout {{ $.Values.requestTimeout }}s;
46-
proxy_read_timeout {{ $.Values.requestTimeout }}s;
47-
proxy_http_version 1.1;
48-
proxy_set_header "Connection" "";
49-
}
50-
}
51-
version.json: |
6+
metadata-versions.json: |
527
{
538
"name": "renku-core",
549
"versions": [

helm-chart/renku-core/templates/deployment-nginx.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

helm-chart/renku-core/templates/deployment.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ metadata:
1717
spec:
1818
replicas: {{ $.Values.replicaCount }}
1919
strategy:
20-
type: Recreate
20+
type: RollingUpdate
21+
rollingUpdate:
22+
maxUnavailable: 0
23+
maxSurge: 1
2124
selector:
2225
matchLabels:
2326
app.kubernetes.io/name: {{ include "renku-core.name" $ }}
@@ -44,6 +47,9 @@ spec:
4447
volumes:
4548
- name: shared-volume
4649
emptyDir: {}
50+
- name: metadata-versions
51+
configMap:
52+
name: {{ include "renku-core.fullname" $ }}-metadata-versions
4753
{{- include "certificates.volumes" $ | nindent 8 }}
4854
initContainers:
4955
{{- include "certificates.initContainer" $ | nindent 8 }}
@@ -139,10 +145,14 @@ spec:
139145
value: {{ $.Values.global.renku.domain }}
140146
- name: RENKU_PROJECT_DEFAULT_CLI_VERSION
141147
value: {{ $.Values.global.renku.cli_version | default "" | quote }}
148+
- name: METADATA_VERSIONS_LIST
149+
value: /svc/config/metadata-versions/metadata-versions.json
142150
{{- include "certificates.env.python" $ | nindent 12 }}
143151
volumeMounts:
144152
- name: shared-volume
145153
mountPath: {{ $.Values.cacheDirectory }}
154+
- name: metadata-versions
155+
mountPath: /svc/config/metadata-versions
146156
{{- include "certificates.volumeMounts.system" $ | nindent 12 }}
147157
ports:
148158
- name: http
@@ -157,7 +167,7 @@ spec:
157167
path: /health
158168
port: http
159169
resources:
160-
{{- toYaml $.Values.resources | nindent 12 }}
170+
{{- toYaml $.Values.resources.core | nindent 12 }}
161171
- name: {{ $.Chart.Name }}-datasets-workers
162172
image: "{{ $version.image.repository }}:{{ $version.image.tag }}"
163173
imagePullPolicy: {{ $version.image.pullPolicy }}
@@ -213,6 +223,8 @@ spec:
213223
- name: shared-volume
214224
mountPath: {{ $.Values.cacheDirectory }}
215225
{{- include "certificates.volumeMounts.system" $ | nindent 12 }}
226+
resources:
227+
{{- toYaml $.Values.resources.datasetsWorkers | nindent 12 }}
216228

217229
- name: {{ $.Chart.Name }}-management-workers
218230
image: "{{ $version.image.repository }}:{{ $version.image.tag }}"
@@ -267,6 +279,8 @@ spec:
267279
- name: shared-volume
268280
mountPath: {{ $.Values.cacheDirectory }}
269281
{{- include "certificates.volumeMounts.system" $ | nindent 12 }}
282+
resources:
283+
{{- toYaml $.Values.resources.managementWorkers | nindent 12 }}
270284

271285
- name: {{ $.Chart.Name }}-scheduler
272286
image: "{{ $version.image.repository }}:{{ $version.image.tag }}"
@@ -307,6 +321,8 @@ spec:
307321
{{- include "certificates.env.python" $ | nindent 12 }}
308322
volumeMounts:
309323
{{- include "certificates.volumeMounts.system" $ | nindent 12 }}
324+
resources:
325+
{{- toYaml $.Values.resources.scheduler | nindent 12 }}
310326
{{- with $.Values.nodeSelector }}
311327
nodeSelector:
312328
{{- toYaml . | nindent 8 }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- range $version := .Values.versions }}
2+
---
3+
{{- if $.Capabilities.APIVersions.Has "autoscaling/v2" }}
4+
apiVersion: autoscaling/v2
5+
{{- else if $.Capabilities.APIVersions.Has "autoscaling/v2beta2" }}
6+
apiVersion: autoscaling/v2beta2
7+
{{- else if $.Capabilities.APIVersions.Has "autoscaling/v2beta1" }}
8+
apiVersion: autoscaling/v2beta1
9+
{{- else }}
10+
{{- fail "ERROR: You must have at least autoscaling/v2beta1 to use HorizontalPodAutoscaler" }}
11+
{{- end }}
12+
kind: HorizontalPodAutoscaler
13+
metadata:
14+
name: {{ include "renku-core.fullname" $ }}-{{ $version.name }}
15+
spec:
16+
scaleTargetRef:
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
name: {{ include "renku-core.fullname" $ }}-{{ $version.name }}
20+
minReplicas: {{ $.Values.horizontalPodAutoscaling.minReplicas }}
21+
maxReplicas: {{ $.Values.horizontalPodAutoscaling.maxReplicas }}
22+
metrics:
23+
- type: Resource
24+
resource:
25+
name: memory
26+
target:
27+
type: Utilization
28+
averageUtilization: {{ $.Values.horizontalPodAutoscaling.averageMemoryUtilization }}
29+
{{ end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- range $version := .Values.versions }}
2+
---
3+
apiVersion: policy/v1
4+
kind: PodDisruptionBudget
5+
metadata:
6+
name: {{ include "renku-core.fullname" $ }}-{{ $version.name }}
7+
spec:
8+
minAvailable: 1
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/deploymentVersion: {{ $version.name }}
12+
{{ end }}

helm-chart/renku-core/templates/service-nginx.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

helm-chart/renku-core/values.schema.json

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,6 @@
101101
},
102102
"type": "object"
103103
},
104-
"ingress": {
105-
"description": "Kubernetes ingress definition",
106-
"properties": {
107-
"enabled": {
108-
"description": "whether to enable the ingress or not",
109-
"type": "boolean"
110-
}
111-
},
112-
"type": "object"
113-
},
114104
"metrics": {
115105
"description": "Definition of Redis Queue metrics",
116106
"properties": {
@@ -141,8 +131,30 @@
141131
"type": "object"
142132
},
143133
"nodeSelector": {
144-
"description": "Node selector for deployment",
145-
"type": "object"
134+
"description": "Node selector for deployment",
135+
"type": "object"
136+
},
137+
"horizontalPodAutoscaling": {
138+
"description": "Setup for scaling the core service",
139+
"type": "object",
140+
"properties": {
141+
"minReplicas": {
142+
"description": "Flag to turn on/off Sentry",
143+
"type": "integer",
144+
"minimum": 1
145+
},
146+
"maxReplicas": {
147+
"description": "URI of the sentry Data Source Name",
148+
"type": "integer",
149+
"minimum": 1
150+
},
151+
"averageMemoryUtilization": {
152+
"description": "Name of the sentry environment to post to",
153+
"type": "integer",
154+
"exclusiveMinimum": 0,
155+
"exclusiveMaximum": 100
156+
}
157+
}
146158
},
147159
"tolerations": {
148160
"description": "Tolerations for deployment",
@@ -237,7 +249,6 @@
237249
"gitLFSSkipSmudge",
238250
"jwtTokenSecret",
239251
"service",
240-
"ingress",
241252
"metrics",
242253
"sentry",
243254
"versions"

helm-chart/renku-core/values.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Default values for renku-core.
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
4-
replicaCount: 1
4+
replicaCount: 2
55
global:
66
## Specify a secret that containes the certificate
77
## if you would like to use a custom CA. The key for the secret
@@ -56,25 +56,18 @@ fullnameOverride: ""
5656
service:
5757
type: ClusterIP
5858
port: 80
59-
ingress:
60-
enabled: false
6159
metrics:
6260
enabled: false
6361
image:
6462
repository: renku/rqmetrics
6563
tag: 0.0.2
6664
pullPolicy: IfNotPresent
67-
resources: {}
68-
# We usually recommend not to specify default resources and to leave this as a conscious
69-
# choice for the user. This also increases chances charts run on environments with little
70-
# resources, such as Minikube. If you do want to specify resources, uncomment the following
71-
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
72-
# limits:
73-
# cpu: 100m
74-
# memory: 128Mi
75-
# requests:
76-
# cpu: 100m
77-
# memory: 128Mi
65+
resources:
66+
core: {}
67+
rqmetrics: {}
68+
datasetsWorkers: {}
69+
managementWorkers: {}
70+
scheduler: {}
7871

7972
# nodeSelector: {}
8073

@@ -114,3 +107,8 @@ podSecurityContext:
114107
fsGroup: 100
115108
securityContext:
116109
allowPrivilegeEscalation: false
110+
111+
horizontalPodAutoscaling:
112+
minReplicas: 2
113+
maxReplicas: 10
114+
averageMemoryUtilization: 50

renku/ui/service/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2020 - Swiss Data Science Center (SDSC)
2+
# Copyright 2022 - Swiss Data Science Center (SDSC)
33
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
44
# Eidgenössische Technische Hochschule Zürich (ETHZ).
55
#
@@ -78,3 +78,6 @@
7878
# Sentry configuration
7979
SENTRY_ENABLED = os.getenv("SENTRY_ENABLED", "false").lower() == "true"
8080
SENTRY_SAMPLERATE = float(os.getenv("SENTRY_SAMPLE_RATE", 0.2))
81+
82+
# List of all available metadata versions
83+
METADATA_VERSIONS_LIST = os.getenv("METADATA_VERSIONS_LIST", "/svc/config/metadata-versions/metadata-versions.json")

0 commit comments

Comments
 (0)