Skip to content

Commit

Permalink
Enhance Helm Chart Flexibility: Support for Tolerations and Improved …
Browse files Browse the repository at this point in the history
…Scheduling Defaults (#123)
  • Loading branch information
electrosenpai authored Nov 22, 2024
1 parent 954f2cb commit 4ed3f24
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 93 deletions.
156 changes: 116 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,59 +75,135 @@ helm install my-lago-release . \
### Frontend Configuration

| Parameter | Description | Default |
|--------------------------------------|-----------------------------------------------------|--------------|
| `front.replicas` | Number of frontend replicas | `1` |
| `front.service.port` | Frontend service port | `80` |
| `front.resources.requests.memory` | Memory request for the frontend | `512Mi` |
| `front.resources.requests.cpu` | CPU request for the frontend | `200m` |
| `front.podAnnotations` | Annotations to add to the frontend pod | `{}` |
| `front.podLabels` | Labels to add to the frontend pod | `{}` |
|-------------------------------------|-----------------------------------------------------|--------------|
| `front.tolerations` | Pod tolerations for Frontend pods | `[]` |
| `front.nodeSelector` | Node selector for Frontend pods | `{}` |
| `front.affinity` | Affinity rules for Frontend pods | `{}` |
| `front.replicas` | Number of frontend replicas | `1` |
| `front.service.port` | Frontend service port | `80` |
| `front.resources.requests.memory` | Memory request for the frontend | `512Mi` |
| `front.resources.requests.cpu` | CPU request for the frontend | `200m` |
| `front.podAnnotations` | Annotations to add to the frontend pod | `{}` |
| `front.podLabels` | Labels to add to the frontend pod | `{}` |



### API Configuration

| Parameter | Description | Default |
|--------------------------------------|-----------------------------------------------------|--------------|
| `api.replicas` | Number of API replicas | `1` |
| `api.service.port` | API service port | `3000` |
| `api.rails.maxThreads` | Maximum number of threads for the Rails app | `10` |
| `api.rails.webConcurrency` | Web concurrency setting for Rails | `4` |
| `api.rails.env` | Rails environment | `production` |
| `api.rails.logStdout` | Enable or disable logging to stdout | `true` |
| `api.rails.logLevel` | Log level for the Rails app | `error` |
| `api.sidekiqWeb.enabled` | Enable or disable Sidekiq Web | `true` |
| `api.resources.requests.memory` | Memory request for the API | `1Gi` |
| `api.resources.requests.cpu` | CPU request for the API | `1000m` |
| `api.volumes.accessModes` | Access mode for the API's persistent storage | `ReadWriteOnce` |
| `api.volumes.storage` | Storage size for the API's persistent volume claim | `10Gi` |
| `api.podAnnotations` | Annotations to add to the API pod | `{}` |
| `api.podLabels` | Labels to add to the API pod | `{}` |
|-------------------------------------|-----------------------------------------------------|--------------|
| `api.tolerations` | Pod tolerations for API pods | `[]` |
| `api.nodeSelector` | Node selector for API pods | `{}` |
| `api.affinity` | Affinity rules for API pods | `{}` |
| `api.replicas` | Number of API replicas | `1` |
| `api.service.port` | API service port | `3000` |
| `api.rails.maxThreads` | Maximum number of threads for the Rails app | `10` |
| `api.rails.webConcurrency` | Web concurrency setting for Rails | `4` |
| `api.rails.env` | Rails environment | `production` |
| `api.rails.logStdout` | Enable or disable logging to stdout | `true` |
| `api.rails.logLevel` | Log level for the Rails app | `error` |
| `api.sidekiqWeb.enabled` | Enable or disable Sidekiq Web | `true` |
| `api.resources.requests.memory` | Memory request for the API | `1Gi` |
| `api.resources.requests.cpu` | CPU request for the API | `1000m` |
| `api.volumes.accessModes` | Access mode for the API's persistent storage | `ReadWriteOnce` |
| `api.volumes.storage` | Storage size for the API's persistent volume claim | `10Gi` |
| `api.podAnnotations` | Annotations to add to the API pod | `{}` |
| `api.podLabels` | Labels to add to the API pod | `{}` |


### Worker Configuration

| Parameter | Description | Default |
|-------------------------------------|----------------------------------------------------|-----------|
| `worker.replicas` | Number of worker replicas | `1` |
| `worker.rails.sidekiqConcurrency` | Sidekiq concurrency | `100` |
| `worker.rails.env` | Worker environment | `production` |
| `worker.resources.requests.memory` | Memory request for the worker | `1Gi` |
| `worker.resources.requests.cpu` | CPU request for the worker | `1000m` |
| `worker.tolerations` | Pod tolerations for Worker pods | `[]` |
| `worker.nodeSelector` | Node selector for Worker pods | `{}` |
| `worker.affinity` | Affinity rules for Worker pods | `{}` |
| `worker.replicas` | Number of Worker replicas | `1` |
| `worker.rails.sidekiqConcurrency` | Sidekiq concurrency for Worker | `100` |
| `worker.rails.env` | Worker environment | `production` |
| `worker.rails.logStdout` | Enable or disable logging to stdout | `true` |
| `worker.rails.logLevel` | Log level for Worker | `error` |
| `worker.resources.requests.memory` | Memory request for Worker | `1Gi` |
| `worker.resources.requests.cpu` | CPU request for Worker | `1000m` |
| `worker.livenessProbe.initialDelaySeconds` | Liveness probe initial delay | `0` |
| `worker.livenessProbe.periodSeconds` | Liveness probe period | `10` |
| `worker.livenessProbe.timeoutSeconds` | Liveness probe timeout | `1` |
| `worker.livenessProbe.failureThreshold` | Liveness probe failure threshold | `3` |


### Event Worker Configuration

| Parameter | Description | Default |
|---------------------------------|--------------------------------------------|-----------|
| `eventsWorker.tolerations` | Pod tolerations for Events Worker pods | `[]` |
| `eventsWorker.nodeSelector` | Node selector for Events Worker pods | `{}` |
| `eventsWorker.affinity` | Affinity rules for Events Worker pods | `{}` |
| `eventsWorker.replicas` | Number of Events Worker replicas | `1` |
| `eventsWorker.rails.sidekiqConcurrency` | Sidekiq concurrency for Events Worker | `100` |
| `eventsWorker.rails.env` | Events Worker environment | `production` |
| `eventsWorker.resources.requests.memory` | Memory request for Events Worker | `1Gi` |
| `eventsWorker.resources.requests.cpu` | CPU request for Events Worker | `1000m` |
| `eventsWorker.livenessProbe.initialDelaySeconds` | Liveness probe initial delay | `0` |
| `eventsWorker.livenessProbe.periodSeconds` | Liveness probe period | `10` |
| `eventsWorker.livenessProbe.timeoutSeconds` | Liveness probe timeout | `1` |
| `eventsWorker.livenessProbe.failureThreshold` | Liveness probe failure threshold | `3` |



### MinIO Configuration

| Parameter | Description | Default |
|-------------------------------------|----------------------------------------------------|-----------|
| `minio.enabled` | Enable MinIO for object storage | `true` |
| `minio.replicas` | Number of MinIO replicas | `2` |
| `minio.persistence.size` | Persistent volume size for MinIO | `10Gi` |
| `minio.ingress.enabled` | Enable ingress for MinIO | `true` |
| `minio.ingress.hosts` | Hostnames for MinIO ingress | `minio.lago.dev` |
| `minio.buckets` | List of S3 buckets to create on MinIO | `[]` |
| `minio.buckets[].name` | Name of the bucket | `my-lago-minio` |
| `minio.buckets[].policy` | Access policy for the bucket (none, readonly, writeonly, readwrite) | `none` |
| `minio.buckets[].purge` | If true, purges the bucket upon deletion | `false` |
| `minio.buckets[].versioning` | Enable versioning for the bucket | `false` |
| `minio.buckets[].objectlocking` | Enable object locking for the bucket | `false` |
| Parameter | Description | Default |
|-------------------------------------|--------------------------------------------------------------------------------|-----------------------|
| `minio.enabled` | Enable MinIO for object storage | `true` |
| `minio.replicas` | Number of MinIO replicas | `2` |
| `minio.persistence.size` | Persistent volume size for MinIO | `10Gi` |
| `minio.ingress.enabled` | Enable ingress for MinIO | `true` |
| `minio.ingress.hosts` | Hostnames for MinIO ingress | `minio.lago.dev` |
| `minio.ingress.ingressClassName` | Specify the ingress class name for MinIO ingress | `nginx` |
| `minio.ingress.path` | Path for the MinIO ingress | `/` |
| `minio.buckets` | List of S3 buckets to create on MinIO | `[]` |
| `minio.buckets[].name` | Name of the bucket (should match the release name if using `fullnameOverride`) | `my-lago-minio` |
| `minio.buckets[].policy` | Access policy for the bucket (none, readonly, writeonly, readwrite) | `none` |
| `minio.buckets[].purge` | If true, purges the bucket upon deletion | `false` |
| `minio.buckets[].versioning` | Enable versioning for the bucket | `false` |
| `minio.buckets[].objectlocking` | Enable object locking for the bucket | `false` |
| `minio.fullnameOverride` | Override the full name for MinIO resources (should match the release name) | `""` |
| `minio.nameOverride` | Override the short name for MinIO resources | `minio` |
| `minio.endpoint` | Endpoint URL for accessing MinIO | `""` |

#### MinIO Configuration Notes

When deploying MinIO with this Helm chart, it is recommended to align the `fullnameOverride` and the name of the first bucket with the release name to ensure proper resource naming and organization.

##### Example:

If you are installing the release with the name `old-lago`:

```bash
helm install old-lago ./lago-helm-charts --values value_old.yaml
```

Your values.yaml for MinIO should include:

```yaml
minio:
enabled: true
fullnameOverride: "old-lago-minio" # Matches the release name
buckets:
- name: "old-lago-minio" # Matches the fullnameOverride
policy: none
purge: false
versioning: false
objectlocking: false
endpoint: "http://minio.yourdomain.tld"
```
### Key Points
- **`fullnameOverride`**: This parameter allows you to set a custom name for MinIO resources. For better traceability, align it with the release name.
- **First Bucket Name**: The first bucket in the `buckets` list should match the `fullnameOverride` to ensure consistent bucket naming conventions.
- **Ingress Configuration**: Make sure the `hosts` in the ingress section match your MinIO endpoint URL.


## Storage Recommendation

Expand Down
33 changes: 19 additions & 14 deletions templates/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,46 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{ if .Values.postgresql.enabled }}
{{ if .Values.postgresql.enabled }}
- name: wait-for-postgresql
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- pod/{{ .Release.Name }}-postgresql-0
- --for=condition=ready
- --timeout=180s
{{ end }}
{{ if .Values.redis.enabled }}
{{ end }}
{{ if .Values.redis.enabled }}
- name: wait-for-redis
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- pod/{{ .Release.Name }}-redis-master-0
- --for=condition=ready
- --timeout=180s
{{ end }}
{{ if .Values.minio.enabled }}
{{ end }}
{{ if .Values.minio.enabled }}
- name: wait-for-minio
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- pod/{{ .Release.Name }}-minio-0
- --for=condition=ready
- --timeout=180s
{{ end }}
{{ end }}
- name: wait-for-migrations
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
Expand Down Expand Up @@ -136,15 +148,13 @@ spec:
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{ if .Values.global.license }}
{{ if .Values.global.license }}
- name: LAGO_LICENSE
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: license
{{ end }}


{{ if or .Values.global.s3.enabled .Values.minio.enabled }}
- name: LAGO_USE_AWS_S3
value: "true"
Expand All @@ -160,7 +170,6 @@ spec:
{{ .Values.global.s3.endpoint | quote }}
{{ end }}
{{ end }}

{{ if or .Values.global.s3.accessKeyId .Values.minio.enabled .Values.global.existingSecret }}
- name: LAGO_AWS_S3_ACCESS_KEY_ID
valueFrom:
Expand All @@ -176,7 +185,6 @@ spec:
awsS3AccessKeyId
{{ end }}
{{ end }}

{{ if or .Values.global.s3.secretAccessKey .Values.minio.enabled .Values.global.existingSecret }}
- name: LAGO_AWS_S3_SECRET_ACCESS_KEY
valueFrom:
Expand All @@ -192,8 +200,6 @@ spec:
awsS3SecretAccessKey
{{ end }}
{{ end }}


- name: LAGO_AWS_S3_BUCKET
value: {{ if .Values.minio.enabled }}
{{ (index .Values.minio.buckets 0).name | quote }}
Expand All @@ -207,7 +213,6 @@ spec:
{{ default "us-east-1" .Values.minio.region | quote }}
{{ end }}
{{ end }}

{{ if .Values.global.smtp.enabled }}
- name: LAGO_FROM_EMAIL
value: {{ .Values.global.smtp.fromEmail }}
Expand Down
26 changes: 19 additions & 7 deletions templates/clock-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.clock.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.clock.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.clock.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{ if .Values.redis.enabled }}
- name: wait-for-redis
Expand Down Expand Up @@ -51,12 +63,6 @@ spec:
key: redisUrl
- name: RAILS_LOG_TO_STDOUT
value: {{ .Values.clock.rails.logStdout | quote }}
{{- with .Values.clock.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
- name: LAGO_RSA_PRIVATE_KEY
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -84,6 +90,12 @@ spec:
key: encryptionPrimaryKey
- name: LAGO_LOG_LEVEL
value: {{ .Values.clock.rails.logLevel | quote }}
{{- with .Values.clock.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{ if .Values.global.newRelic.enabled }}
- name: NEW_RELIC_KEY
valueFrom:
Expand All @@ -95,7 +107,7 @@ spec:
name: {{ .Release.Name }}-clock
{{- with .Values.clock.resources }}
resources:
{{- toYaml . | nindent 12}}
{{- toYaml . | nindent 12 }}
{{- end }}
restartPolicy: Always
serviceAccountName: {{ .Values.global.serviceAccountName | default (printf "%s-serviceaccount" .Release.Name) }}
Loading

0 comments on commit 4ed3f24

Please sign in to comment.