From 2f17d1a79d7d841059edf7f841f0799496a7a554 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes da Costa Date: Thu, 28 Nov 2024 10:07:27 -0300 Subject: [PATCH] upgrade chart to support multiple replicas --- chart/Chart.yaml | 4 ++-- chart/templates/ai-deployment.yaml | 2 +- chart/templates/api-deployment.yaml | 2 +- chart/templates/web-deployment.yaml | 2 +- chart/values.yaml | 12 ++++++++---- docs/deployment/kubernetes.mdx | 29 ++++++++++++++++++++++++----- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/chart/Chart.yaml b/chart/Chart.yaml index eef55627..6582e9b5 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: briefer description: The helm chart for Briefer's open-source version. type: application -version: 0.1.3 -appVersion: '0.1.3' +version: 0.1.4 +appVersion: '0.1.4' diff --git a/chart/templates/ai-deployment.yaml b/chart/templates/ai-deployment.yaml index c168c6c8..24780bde 100644 --- a/chart/templates/ai-deployment.yaml +++ b/chart/templates/ai-deployment.yaml @@ -8,7 +8,7 @@ metadata: app.kubernetes.io/name: briefer app.kubernetes.io/component: ai spec: - replicas: 1 + replicas: {{ .Values.ai.replicaCount | default 1 }} selector: matchLabels: app.kubernetes.io/name: briefer diff --git a/chart/templates/api-deployment.yaml b/chart/templates/api-deployment.yaml index 1ca7cc40..56bb48cf 100644 --- a/chart/templates/api-deployment.yaml +++ b/chart/templates/api-deployment.yaml @@ -7,7 +7,7 @@ metadata: app.kubernetes.io/name: briefer app.kubernetes.io/component: api spec: - replicas: 1 + replicas: {{ .Values.api.replicaCount | default 1 }} selector: matchLabels: app.kubernetes.io/name: briefer diff --git a/chart/templates/web-deployment.yaml b/chart/templates/web-deployment.yaml index f9188931..1f54b4c2 100644 --- a/chart/templates/web-deployment.yaml +++ b/chart/templates/web-deployment.yaml @@ -7,7 +7,7 @@ metadata: app.kubernetes.io/name: briefer app.kubernetes.io/component: web spec: - replicas: 1 + replicas: {{ .Values.web.replicaCount | default 1 }} selector: matchLabels: app.kubernetes.io/name: briefer diff --git a/chart/values.yaml b/chart/values.yaml index 08ff5a00..b3e9ae13 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -3,11 +3,12 @@ enableLocalPostgres: true ai: enabled: true + replicaCount: 1 image: repository: docker.io name: briefercloud/briefer-ai - tag: v0.0.42 + tag: v0.0.65 pullPolicy: Always resources: @@ -42,10 +43,11 @@ ai: # effect: 'NoSchedule' web: + replicaCount: 1 image: repository: docker.io name: briefercloud/briefer-web - tag: v0.0.42 + tag: v0.0.65 pullPolicy: Always # optional @@ -74,10 +76,12 @@ web: # effect: 'NoSchedule' api: + replicaCount: 1 + image: repository: docker.io name: briefercloud/briefer-api - tag: v0.0.42 + tag: v0.0.65 pullPolicy: Always resources: @@ -148,7 +152,7 @@ jupyter: image: repository: docker.io name: briefercloud/briefer-jupyter - tag: v0.0.42 + tag: v0.0.65 pullPolicy: Always # tolerations: diff --git a/docs/deployment/kubernetes.mdx b/docs/deployment/kubernetes.mdx index dfa34819..88779f72 100644 --- a/docs/deployment/kubernetes.mdx +++ b/docs/deployment/kubernetes.mdx @@ -52,11 +52,11 @@ Using Briefer's Helm chart is the easiest way of setting up Briefer on your Kube Feel free to change the namespace if you want to. If you're using an existing namespace, please remove the `--create-namespace` flag. 4. After installing Briefer's Helm chart, you can confirm that the manifests have been applied by listing all the pods in the chart's target namespace (usually `kubectl get pods -n briefer`). - If you're running a Postgres instance within your cluster, it might be that - the API will be ready before the Postgres instance is up. In that case, - you'll see that the API pod will keep restarting for a few minutes. That's - _normal_. It happens because the API needs to connect to the database to - start, so it'll just keep trying to start until Postgres is ready. + If you're running a Postgres instance within your cluster, it might be that + the API will be ready before the Postgres instance is up. In that case, + you'll see that the API pod will keep restarting for a few minutes. That's + _normal_. It happens because the API needs to connect to the database to + start, so it'll just keep trying to start until Postgres is ready. 5. Create the necessary `Ingress` resources so that you can access Briefer's API and Web containers. Make sure to use the same URLs you've configured in step 2. @@ -105,6 +105,25 @@ api: postgresPassword: password ``` +### Using more than one replica for Briefers' services + +If you want to use more than one replica for Briefer's services, you must set the `replicas` for each service in your `values.yaml` file. + +After doing that, make sure to enable sticky sessions in your `Ingress` resources. Without sticky sessions (also known as Session Affinity), Briefer will not work correctly when using multiple replicas. + +If you're using NGINX as your Ingress controller, you can enable sticky sessions by adding the annotations below to your `Ingress` resources, for example. + +```yaml +nginx.ingress.kubernetes.io/affinity: 'cookie' +nginx.ingress.kubernetes.io/session-cookie-name: 'http-cookie' +nginx.ingress.kubernetes.io/session-cookie-expires: '172800' +nginx.ingress.kubernetes.io/session-cookie-max-age: '172800' +``` + + +It's not necessary to use sticky sessions if you're using only one replica. + + ### Configuring pod sizes We recommend that you explicitly configure the size of your `jupyter` pod so that it has enough memory and vCPUs to run your analyses.