diff --git a/charts/mageai/Chart.lock b/charts/mageai/Chart.lock new file mode 100644 index 0000000..50e1b2f --- /dev/null +++ b/charts/mageai/Chart.lock @@ -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" diff --git a/charts/mageai/Chart.yaml b/charts/mageai/Chart.yaml index 488ff0a..6d93adc 100644 --- a/charts/mageai/Chart.yaml +++ b/charts/mageai/Chart.yaml @@ -49,6 +49,12 @@ maintainers: email: eng@mage.ai 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 diff --git a/charts/mageai/templates/_helpers.tpl b/charts/mageai/templates/_helpers.tpl index 4d7741e..08ffbfa 100644 --- a/charts/mageai/templates/_helpers.tpl +++ b/charts/mageai/templates/_helpers.tpl @@ -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 */}} diff --git a/charts/mageai/templates/deployment.yaml b/charts/mageai/templates/deployment.yaml index 0337420..c3442e2 100644 --- a/charts/mageai/templates/deployment.yaml +++ b/charts/mageai/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.standaloneScheduler }} apiVersion: apps/v1 kind: Deployment metadata: @@ -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"] + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: @@ -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 @@ -105,3 +127,4 @@ spec: {{- else if .Values.extraVolumes -}} {{ toYaml .Values.extraVolumes | nindent 8 }} {{- end }} +{{- end }} diff --git a/charts/mageai/templates/scheduler.yaml b/charts/mageai/templates/scheduler.yaml new file mode 100644 index 0000000..bb0982b --- /dev/null +++ b/charts/mageai/templates/scheduler.yaml @@ -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 }} diff --git a/charts/mageai/templates/webservice.yaml b/charts/mageai/templates/webservice.yaml new file mode 100644 index 0000000..29d731f --- /dev/null +++ b/charts/mageai/templates/webservice.yaml @@ -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 }} diff --git a/charts/mageai/values.yaml b/charts/mageai/values.yaml index 1061959..945032b 100644 --- a/charts/mageai/values.yaml +++ b/charts/mageai/values.yaml @@ -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 @@ -71,7 +92,7 @@ readinessProbe: # Custom liveness probe customLivenessProbe: {} -# Custom rediness probe +# Custom readiness probe customReadinessProbe: {} ingress: @@ -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.