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 @@ -18,6 +18,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
21 changes: 21 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,18 @@ spec:
serviceAccountName: {{ include "mageai.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
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.url }}
- name: REDIS_URL
value: {{ .Values.redis.url }}
{{- 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
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand Down Expand Up @@ -80,6 +93,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.url}}
- name: REDIS_URL
value: {{.Values.redis.url}}
{{- end }}
volumeMounts:
{{- if .Values.volumes }}
- name: mage-fs
Expand All @@ -105,3 +125,4 @@ spec:
{{- else if .Values.extraVolumes -}}
{{ toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}
128 changes: 128 additions & 0 deletions charts/mageai/templates/scheduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{{- 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 }}
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.url }}
- name: REDIS_URL
value: {{ .Values.redis.url }}
{{- 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"]
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:
sriniarul marked this conversation as resolved.
Show resolved Hide resolved
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.url}}
- name: REDIS_URL
value: {{ .Values.redis.url }}
{{- 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 }}
128 changes: 128 additions & 0 deletions charts/mageai/templates/webservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{{- 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 }}
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.url }}
- name: REDIS_URL
value: {{ .Values.redis.url }}
{{- 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"]
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.url}}
- name: REDIS_URL
value: {{ .Values.redis.url }}
{{- 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 }}
Loading