Skip to content

Commit

Permalink
feat: standalone chart for emeis
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Feb 2, 2024
1 parent 9e9b73d commit 05b5ea4
Show file tree
Hide file tree
Showing 16 changed files with 648 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: '3.x'

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
uses: helm/chart-testing-action@v2.6.1

- name: Run chart-testing (list-changed)
id: list-changed
Expand Down
23 changes: 23 additions & 0 deletions charts/emeis/.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/
6 changes: 6 additions & 0 deletions charts/emeis/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 14.0.0
digest: sha256:e011d7c1e6309e637473231af15527ba4031c95c94776cccd4aa47198ca8a9dd
generated: "2024-02-02T15:46:23.679737598+01:00"
21 changes: 21 additions & 0 deletions charts/emeis/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: emeis
description: Run emeis on Kubernetes
type: application
version: 0.1.0
appVersion: 1.3.4
keywords:
- caluma
home: https://caluma.io/
icon: https://avatars0.githubusercontent.com/u/42172011?s=200&v=4
sources:
- https://github.com/projectcaluma/emeis
- https://github.com/projectcaluma/charts
maintainers:
- name: Caluma
email: [email protected]
dependencies:
- name: postgresql
version: ~14.0.0
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
85 changes: 85 additions & 0 deletions charts/emeis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# emeis

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.3.4](https://img.shields.io/badge/AppVersion-1.3.4-informational?style=flat-square)

Run emeis on Kubernetes

**Homepage:** <https://caluma.io/>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Caluma | <[email protected]> | |

## Source Code

* <https://github.com/projectcaluma/emeis>
* <https://github.com/projectcaluma/charts>

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | postgresql | ~14.0.0 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| emeis.additionalEnvironmentVariables | list | `[]` | |
| emeis.allowAnonymousWrite | string | `"true"` | |
| emeis.allowedHosts | string | `"*"` | |
| emeis.env | string | `"production"` | |
| emeis.languages[0] | string | `"de"` | |
| emeis.languages[1] | string | `"en"` | |
| emeis.permissionClasses | string | `""` | |
| emeis.postgresql.database | string | `""` | Gets used when postgresql.enabled = false |
| emeis.postgresql.existingHost | string | `""` | Gets used when postgresql.enabled = false |
| emeis.postgresql.username | string | `""` | Gets used when postgresql.enabled = false |
| emeis.secretKey | string | `""` | |
| emeis.visibilityClasses | string | `""` | |
| existingSecret | string | `""` | Name of an existing secret that contains a SECRET_KEY and DATABASE_PASSWORD |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/projectcaluma/emeis"` | |
| image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/emeis/api"` | |
| ingress.hosts[0].paths[0].pathType | string | `"Prefix"` | |
| ingress.hosts[0].paths[1].path | string | `"/emeis(/|$)(.*)"` | |
| ingress.hosts[0].paths[1].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podLabels | object | `{}` | |
| podSecurityContext | object | `{}` | |
| postgresql.auth.database | string | `"emeis"` | |
| postgresql.auth.username | string | `"emeis"` | |
| postgresql.enabled | bool | `true` | Disable the included PostgreSQL deployment for production |
| postgresql.primary.initdb.scripts."create_extension_hstore.sh" | string | - | Load HSTORE extension |
| replicaCount | int | `1` | How many emeis Pods to deploy |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| service.port | int | `8000` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| tolerations | list | `[]` | |
| volumeMounts | list | `[]` | Additional volumeMounts on the output Deployment definition. |
| volumes | list | `[]` | Additional volumes on the output Deployment definition. |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
22 changes: 22 additions & 0 deletions charts/emeis/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "emeis.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "emeis.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "emeis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "emeis.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
101 changes: 101 additions & 0 deletions charts/emeis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "emeis.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 "emeis.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 }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "emeis.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "emeis.labels" -}}
helm.sh/chart: {{ include "emeis.chart" . }}
{{ include "emeis.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "emeis.selectorLabels" -}}
app.kubernetes.io/name: {{ include "emeis.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "emeis.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "emeis.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Define the contents for the emeis ConfigMap
*/}}
{{- define "emeis.configMap" -}}
ENV: {{ .Values.emeis.env | quote }}
ALLOWED_HOSTS: {{ .Values.emeis.allowedHosts | quote }}
ALLOW_ANONYMOUS_WRITE: {{ .Values.emeis.allowAnonymousWrite | quote }}
LANGUAGES: {{ join "," .Values.emeis.languages | quote}}
VISIBILITY_CLASSES: {{ .Values.emeis.visibilityClasses | quote }}
PERMISSION_CLASSES: {{ .Values.emeis.permissionClasses | quote }}
{{- if and .Values.postgresql.enabled .Values.emeis.postgresql.existingHost }}
{{ fail "postgresql.enabled and emeis.postgresql.existingHost are mutually exclusive, please pick one" }}
{{- end }}
{{- if .Values.postgresql.enabled }}
DATABASE_HOST: {{ template "emeis.fullname" . }}-postgresql
{{- else if .Values.emeis.postgresql.existingHost }}
DATABASE_HOST: {{ .Values.emeis.postgresql.existingHost | quote }}
{{- else }}
{{ fail "neither postgresql.enabled or emeis.postgresql.existingHost are set, please pick one" }}
{{- end }}
{{- if .Values.postgresql.enabled }}
DATABASE_NAME: "{{ .Values.postgresql.auth.database }}"
{{- else }}
DATABASE_NAME: "{{ .Values.emeis.postgresql.database }}"
{{- end }}
{{- if .Values.postgresql.enabled }}
DATABASE_USER: "{{ .Values.postgresql.auth.username }}"
{{- else }}
DATABASE_USER: "{{ .Values.emeis.postgresql.username }}"
{{- end }}
{{- end }}

{{/*
Define the contents for the emeis Secret
*/}}
{{- define "emeis.secret" -}}
SECRET_KEY: {{ .Values.emeis.secretKey | b64enc | quote }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/emeis/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "emeis.fullname" . }}
labels:
{{- include "emeis.labels" . | nindent 4 }}
data:
{{- include "emeis.configMap" . | nindent 2 }}
104 changes: 104 additions & 0 deletions charts/emeis/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "emeis.fullname" . }}
labels:
{{- include "emeis.labels" . | nindent 4 }}
annotations:
checksum/config: {{ include "emeis.configMap" . | sha256sum }}
checksum/secret: {{ include "emeis.secret" . | sha256sum }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "emeis.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "emeis.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "emeis.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "emeis.fullname" . }}
{{- if .Values.existingSecret }}
- secretRef:
name: {{ .Values.existingSecret }}
{{- else }}
- secretRef:
name: {{ include "emeis.fullname" . }}
{{- end }}
env:
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.postgresql.enabled }}
name: "{{ template "emeis.fullname" . }}-postgresql"
key: password
{{- else }}
name: {{ .Values.existingSecret | quote }}
key: DATABASE_PASSWORD
{{- end }}
{{- if .Values.emeis.additionalEnvironmentVariables }}
{{ toYaml .Values.emeis.additionalEnvironmentVariables | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
# TODO: we need a proper healthz endpoint to replace these woefully inadequate checks
livenessProbe:
tcpSocket:
port: http
#httpGet:
# path: /
# port: http
readinessProbe:
tcpSocket:
port: http
#httpGet:
# path: /
# port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- 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 }}
Loading

0 comments on commit 05b5ea4

Please sign in to comment.