Skip to content

Commit

Permalink
feat: add optional redis-cluster dependency helm chart (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalevov authored Feb 6, 2024
1 parent f158ca5 commit 666ae00
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 4 deletions.
7 changes: 6 additions & 1 deletion charts/dial-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ dependencies:
tags:
- bitnami-common
version: 2.14.1
- name: redis-cluster
repository: https://charts.bitnami.com/bitnami
alias: redis
condition: redis.enabled
version: 9.1.5
description: Helm chart for dial core
home: https://epam-rail.com
icon: "https://docs.epam-rail.com/img/favicon.ico"
Expand All @@ -21,4 +26,4 @@ maintainers:
name: dial-core
sources:
- https://github.com/epam/ai-dial-helm/tree/main/charts/dial-core
version: 1.1.2
version: 1.2.0
32 changes: 31 additions & 1 deletion charts/dial-core/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dial-core

![Version: 1.1.2](https://img.shields.io/badge/Version-1.1.2-informational?style=flat-square) ![AppVersion: 1.0](https://img.shields.io/badge/AppVersion-1.0-informational?style=flat-square)
![Version: 1.2.0](https://img.shields.io/badge/Version-1.2.0-informational?style=flat-square) ![AppVersion: 1.0](https://img.shields.io/badge/AppVersion-1.0-informational?style=flat-square)

Helm chart for dial core

Expand All @@ -24,6 +24,7 @@ Kubernetes: `>=1.23.0-0`
| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | common | 2.14.1 |
| https://charts.bitnami.com/bitnami | redis(redis-cluster) | 9.1.5 |

## Installing the Chart

Expand Down Expand Up @@ -179,6 +180,15 @@ helm install my-release dial/dial-core -f values.yaml
| podSecurityContext.fsGroup | int | `1001` | Set dial-core pod's Security Context fsGroup |
| priorityClassName | string | `""` | dial-core pods' priorityClassName |
| readinessProbe | object | `{}` | ReadinessProbe on containers |
| redis.cluster.nodes | int | `3` | The number of master nodes should always be >= 3, otherwise cluster creation will fail |
| redis.cluster.replicas | int | `0` | |
| redis.cluster.update.currentNumberOfNodes | int | `3` | |
| redis.cluster.update.currentNumberOfReplicas | int | `0` | |
| redis.enabled | bool | `false` | |
| redis.redis.configmap | string | `"# Intentional gap from 6gb to 6Gi left\nmaxmemory 6gb\n# Evict using approximated LFU, only keys with an expire set\nmaxmemory-policy volatile-lfu"` | |
| redis.redis.useAOFPersistence | string | `"no"` | Whether to use AOF Persistence mode or not. We keep only RDB persistence (enabled by default) |
| redis.resources.limits.memory | string | `"6Gi"` | |
| redis.resources.requests.memory | string | `"6Gi"` | |
| replicaCount | int | `1` | Number of dial-core replicas to deploy |
| resources | object | `{}` | dial-core resource requests and limits ref: http://kubernetes.io/docs/user-guide/compute-resources/ |
| schedulerName | string | `""` | Name of the k8s scheduler (other than default) for dial-core pods ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/ |
Expand All @@ -205,3 +215,23 @@ helm install my-release dial/dial-core -f values.yaml
| tolerations | list | `[]` | Tolerations for dial-core pods assignment ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ |
| topologySpreadConstraints | list | `[]` | Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods |
| updateStrategy.type | string | `"RollingUpdate"` | StrategyType Can be set to RollingUpdate or OnDelete |

## Redis

The application uses a Redis database to store its data. By default, the Helm chart will deploy a [Redis cluster](https://github.com/bitnami/charts/tree/main/bitnami/redis-cluster) with recommended settings and auto-generated password as a dependency.\
**You may have to set the `redis.password` value with the password generated by the Helm chart during the first installation.**

For other configuration options, refer to redis-cluster Helm chart [documentation](https://github.com/bitnami/charts/tree/main/bitnami/redis-cluster#parameters).

### Use an external Redis database

However, you may want the application to connect to an external Redis database rather than a database provided by the Helm chart - for example, when using a cloud-managed service, or when running a single database server for all your applications. To do this, set the `redis.enabled` parameter to `false` and specify the credentials for the external database using the `env.aidial.redis.*` parameters. Here is an example:

```yaml
redis:
enabled: false
env:
aidial.redis.clusterServersConfig.nodeAddresses: '["redis://myexternalhost:6379"]'
secrets:
aidial.redis.clusterServersConfig.password: "mypassword"
```
20 changes: 20 additions & 0 deletions charts/dial-core/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,23 @@ helm install my-release dial/dial-core -f values.yaml
**NOTE**: You can use the default [values.yaml](values.yaml)

{{ template "chart.valuesSection" . }}

## Redis

The application uses a Redis database to store its data. By default, the Helm chart will deploy a [Redis cluster](https://github.com/bitnami/charts/tree/main/bitnami/redis-cluster) with recommended settings and auto-generated password as a dependency.\
**You may have to set the `redis.password` value with the password generated by the Helm chart during the first installation.**

For other configuration options, refer to redis-cluster Helm chart [documentation](https://github.com/bitnami/charts/tree/main/bitnami/redis-cluster#parameters).

### Use an external Redis database

However, you may want the application to connect to an external Redis database rather than a database provided by the Helm chart - for example, when using a cloud-managed service, or when running a single database server for all your applications. To do this, set the `redis.enabled` parameter to `false` and specify the credentials for the external database using the `env.aidial.redis.*` parameters. Here is an example:

```yaml
redis:
enabled: false
env:
aidial.redis.clusterServersConfig.nodeAddresses: '["redis://myexternalhost:6379"]'
secrets:
aidial.redis.clusterServersConfig.password: "mypassword"
```
18 changes: 17 additions & 1 deletion charts/dial-core/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Return name for logger resources
{{- template "common.names.fullname" . -}}-logger
{{- end -}}


{{/*
Return name for encryption secret
*/}}
Expand Down Expand Up @@ -134,3 +133,20 @@ Params:
configuration.encryption
{{- end -}}
{{- end -}}

{{/*
Return Redis configuration for dial-core for dependency chart
*/}}
{{- define "dialCore.redisSettings" -}}
{{- if .Values.redis.enabled -}}
- name: aidial.redis.clusterServersConfig.nodeAddresses
value: '[{{- printf "redis://%s:6379" (include "common.names.fullname" .Subcharts.redis) | quote -}}]'
{{- if .Values.redis.usePassword }}
- name: aidial.redis.clusterServersConfig.password
valueFrom:
secretKeyRef:
name: {{ include "redis-cluster.secretName" .Subcharts.redis }}
key: {{ include "redis-cluster.secretPasswordKey" .Subcharts.redis }}
{{- end -}}
{{- end -}}
{{- end -}}
3 changes: 2 additions & 1 deletion charts/dial-core/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ spec:
{{- if .Values.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.env }}
{{- if or .Values.env .Values.redis.enabled }}
env:
{{- include "dialCore.redisSettings" . | nindent 12 }}
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ tpl $value $ | quote }}
Expand Down
23 changes: 23 additions & 0 deletions charts/dial-core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,26 @@ logger:
# - mountPath: /etc/vector/vector.yaml
# name: logger-config
# subPath: vector.yaml

redis:
enabled: false
resources:
requests:
memory: 6Gi
limits:
memory: 6Gi
redis:
# -- Whether to use AOF Persistence mode or not. We keep only RDB persistence (enabled by default)
useAOFPersistence: "no"
configmap: |-
# Intentional gap from 6gb to 6Gi left
maxmemory 6gb
# Evict using approximated LFU, only keys with an expire set
maxmemory-policy volatile-lfu
cluster:
# -- The number of master nodes should always be >= 3, otherwise cluster creation will fail
nodes: 3
replicas: 0
update:
currentNumberOfNodes: 3
currentNumberOfReplicas: 0

0 comments on commit 666ae00

Please sign in to comment.