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

✨ Added helm library chart #167

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions charts/maykin-utils-lib/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions charts/maykin-utils-lib/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: maykin-utils-lib
description: A Library Helm chart containing code shared between Maykin helm charts

type: library
version: 0.1.0

9 changes: 9 additions & 0 deletions charts/maykin-utils-lib/templates/_celery-configmap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- define "maykinhelmlib.celeryEnvConfigmap" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "project.fullname" . }}-worker-{{ .Values.worker.label | default "celery" }}
data:
CELERY_WORKER_QUEUE: {{ .Values.worker.queueName | default "" }}
CELERY_WORKER_NAME: {{ .Values.worker.name | default "" }}
{{- end -}}
31 changes: 31 additions & 0 deletions charts/maykin-utils-lib/templates/_celery-liveness-configmap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- define "maykinhelmlib.celeryLivenessConfigmap" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "project.fullname" . }}-celery-liveness
data:
liveness-probe.sh: |
#!/bin/bash

# Exit immediately if a non-zero exit code is returned
set -e

QUEUE_NAME=${CELERY_WORKER_QUEUE:-celery}

# Check if CELERY_WORKER_NAME is set
if [ -z "$CELERY_WORKER_NAME" ]; then
# If not set
WORKER_NAME="${QUEUE_NAME}@${HOSTNAME}"
else
# If set and contains the '@' symbol
if [[ "$CELERY_WORKER_NAME" != *"@"* ]]; then
# If not, update CELERY_WORKER_NAME to celery@${CELERY_WORKER_NAME}
WORKER_NAME="celery@${CELERY_WORKER_NAME}"
else
WORKER_NAME="${CELERY_WORKER_NAME}"
fi
fi

# Use CELERY_WORKER_NAME to set the --destination flag
celery --workdir src --app {{ include "application.name" . }}.celery inspect --destination "$WORKER_NAME" active
{{- end -}}
25 changes: 25 additions & 0 deletions charts/maykin-utils-lib/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- define "application.name" -}}
{{- default .Values.pythonAppName }}
{{- end }}

{{- define "project.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "project.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
Loading