Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis support #22

Merged
merged 13 commits into from
Nov 7, 2023
Merged
6 changes: 6 additions & 0 deletions charts/mageai/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 18.1.1
digest: sha256:79d2d6d43f93313876bfd130ef9b5908377fde03b01819759daff0a82c7afdc7
generated: "2023-10-01T14:08:47.871298+05:30"
6 changes: 6 additions & 0 deletions charts/mageai/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ maintainers:
email: [email protected]

name: mageai
dependencies:
- name: redis
version: 18.1.1
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled


sources:
- https://github.com/mage-ai/helm-charts/tree/master/charts/mageai
Expand Down
10 changes: 10 additions & 0 deletions charts/mageai/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ app.kubernetes.io/name: {{ include "mageai.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
Scheduler Selector labels
*/}}
{{- define "mageai.schedulerSelectorLabels" -}}
app.kubernetes.io/name: {{ .Values.scheduler.name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{/*
Create the name of the service account to use
*/}}
Expand Down
23 changes: 23 additions & 0 deletions charts/mageai/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.standaloneScheduler }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -25,6 +26,20 @@ spec:
serviceAccountName: {{ include "mageai.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if or .Values.redis.enabled .Values.redis.customRedisURL }}
initContainers:
- name: wait-for-redis
image: alpine
env:
{{- if .Values.redis.enabled }}
- name: REDIS_URL
value: redis://{{.Release.Name}}-redis-headless:6379/0
{{- else if .Values.redis.customRedisURL }}
- name: REDIS_URL
value: {{ .Values.redis.customRedisURL }}
{{- end }}
command: ["sh", "-c", "until nc -z -v $(echo $REDIS_URL | cut -d'/' -f3 | cut -d':' -f1) $(echo $REDIS_URL | cut -d'/' -f3 | cut -d':' -f2); do sleep 1; done"]
sriniarul marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand Down Expand Up @@ -80,6 +95,13 @@ spec:
{{- else if .Values.extraEnvs }}
{{- toYaml .Values.extraEnvs | nindent 12 }}
{{- end }}
{{- if .Values.redis.enabled }}
- name: REDIS_URL
value: redis://{{ .Release.Name }}-redis-headless:6379/0
{{- else if .Values.redis.customRedisURL }}
- name: REDIS_URL
value: {{ .Values.redis.customRedisURL }}
{{- end }}
volumeMounts:
{{- if .Values.volumes }}
- name: mage-fs
Expand All @@ -105,3 +127,4 @@ spec:
{{- else if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}
102 changes: 102 additions & 0 deletions charts/mageai/templates/scheduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{{- if .Values.standaloneScheduler }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.scheduler.name }}
labels:
{{- include "mageai.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.scheduler.replicaCount }}
selector:
matchLabels:
{{- include "mageai.schedulerSelectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mageai.schedulerSelectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mageai.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if or .Values.redis.enabled .Values.redis.customRedisURL }}
initContainers:
- name: wait-for-redis
image: alpine
env:
{{- if .Values.redis.enabled }}
- name: REDIS_URL
value: redis://{{ .Release.Name }}-redis-headless:6379/0
{{- else if .Values.redis.customRedisURL }}
- name: REDIS_URL
value: {{ .Values.redis.customRedisURL }}
{{- end }}
command: ["sh", "-c", "until nc -z -v $(echo $REDIS_URL | cut -d'/' -f3 | cut -d':' -f1) $(echo $REDIS_URL | cut -d'/' -f3 | cut -d':' -f2); do sleep 1; done"]
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
{{- if .Values.config }}
- configMapRef:
name: {{ include "mageai.fullname" . }}-env
{{- end }}
{{- if or (.Values.existingSecret) (.Values.secrets) }}
- secretRef:
name: {{ include "mageai.secretName" . }}
{{- end }}
env:
{{- if .Values.env }}
{{- toYaml .Values.env | nindent 12 }}
{{- else if .Values.extraEnvs }}
{{- toYaml .Values.extraEnvs | nindent 12 }}
{{- end }}
{{- if .Values.redis.enabled }}
- name: REDIS_URL
value: redis://{{ .Release.Name }}-redis-headless:6379/0
{{- else if .Values.redis.customRedisURL }}
- name: REDIS_URL
value: {{ .Values.redis.customRedisURL }}
{{- end }}
volumeMounts:
{{- if .Values.volumes }}
- name: mage-fs
mountPath: /home/src
{{- else if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.volumes }}
{{- toYaml .Values.volumes | nindent 8 }}
{{- else if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}
130 changes: 130 additions & 0 deletions charts/mageai/templates/webservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{{- if .Values.standaloneScheduler }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.webServer.name }}
labels:
{{- include "mageai.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.webServer.replicaCount }}
selector:
matchLabels:
{{- include "mageai.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mageai.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "mageai.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if or .Values.redis.enabled .Values.redis.customRedisURL }}
initContainers:
- name: wait-for-redis
image: alpine
env:
{{- if .Values.redis.enabled }}
- name: REDIS_URL
value: redis://{{ .Release.Name }}-redis-headless:6379/0
{{- else if .Values.redis.customRedisURL }}
- name: REDIS_URL
value: {{ .Values.redis.customRedisURL }}
{{- end }}
command: ["sh", "-c", "until nc -z -v $(echo $REDIS_URL | cut -d'/' -f3 | cut -d':' -f1) $(echo $REDIS_URL | cut -d'/' -f3 | cut -d':' -f2); do sleep 1; done"]
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.customLivenessProbe }}
livenessProbe: {{- toYaml .Values.customLivenessProbe | nindent 12 }}
{{- else if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.path }}
port: {{ .Values.livenessProbe.port }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
terminationGracePeriodSeconds: {{ .Values.livenessProbe.terminationGracePeriodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.customReadinessProbe }}
readinessProbe: {{- toYaml .Values.customReadinessProbe | nindent 12 }}
{{- else if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.path }}
port: {{ .Values.readinessProbe.port }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
terminationGracePeriodSeconds: {{ .Values.readinessProbe.terminationGracePeriodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
{{- if .Values.config }}
- configMapRef:
name: {{ include "mageai.fullname" . }}-env
{{- end }}
{{- if or (.Values.existingSecret) (.Values.secrets) }}
- secretRef:
name: {{ include "mageai.secretName" . }}
{{- end }}
env:
{{- if .Values.env }}
{{- toYaml .Values.env | nindent 12 }}
{{- else if .Values.extraEnvs }}
{{- toYaml .Values.extraEnvs | nindent 12 }}
{{- end }}
{{- if .Values.redis.enabled }}
- name: REDIS_URL
value: redis://{{.Release.Name}}-redis-headless:6379/0
{{- else if .Values.redis.customRedisURL }}
- name: REDIS_URL
value: {{ .Values.redis.customRedisURL }}
{{- end }}
volumeMounts:
{{- if .Values.volumes }}
- name: mage-fs
mountPath: /home/src
{{- else if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.volumes }}
{{- toYaml .Values.volumes | nindent 8 }}
{{- else if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}
25 changes: 23 additions & 2 deletions charts/mageai/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
# Declare variables to be passed into your templates.

replicaCount: 1
standaloneScheduler: true

# Effective if standaloneScheduler is true
scheduler:
replicaCount: 1
name: mageai-scheduler


# Effective if standaloneScheduler is true
webServer:
replicaCount: 1
name: mageai-webserver

# Enable redis if you want more replica
redis:
enabled: false
architecture: standalone
auth:
enabled: false
# Your custom redis url (make sure redis.enabled is set to false)
customRedisURL: ""

image:
repository: mageai/mageai
Expand Down Expand Up @@ -71,7 +92,7 @@ readinessProbe:
# Custom liveness probe
customLivenessProbe: {}

# Custom rediness probe
# Custom readiness probe
customReadinessProbe: {}

ingress:
Expand Down Expand Up @@ -120,7 +141,7 @@ extraVolumes:
# config: Default configuration for mageai as environment variables. These get injected directly in the container.
config: {}

# existingSecret: Spcifies an existing secret to be used as environment variables. These get injected directly in the container.
# existingSecret: Specifies an existing secret to be used as environment variables. These get injected directly in the container.
existingSecret: ""

# secrets: Default secrets for mageai as environment variables. These get injected directly in the container.
Expand Down