Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from QJoly/joplin
Browse files Browse the repository at this point in the history
Creation of the Joplin chart
  • Loading branch information
qjoly authored Dec 4, 2022
2 parents e42ba62 + 36f9298 commit 52bf9a5
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 44 deletions.
2 changes: 1 addition & 1 deletion charts/joplin/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: joplin
description: Joplin is an open source note-taking app. Capture your thoughts and securely access them from any device.
version: 0.0.1
version: 0.2.1
appVersion: "2.9.7-beta"
keywords:
- joplin
19 changes: 19 additions & 0 deletions charts/joplin/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

_ _ _
| | ___ _ __ | (_)_ __
_ | |/ _ \| ‘_ \| | | ‘_ \
| |_| | (_) | |_) | | | | | |
\___/ \___/| .__/|_|_|_| |_|
|_|

You have just deployed {{ .Chart.Name }}.

To find out more about the release, try :

$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}
———–
To connect to the application, here are the default identifiers

mail: admin@localhost
password: admin
62 changes: 62 additions & 0 deletions charts/joplin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "joplin.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 "joplin.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 "joplin.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "joplin.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "joplin.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
16 changes: 12 additions & 4 deletions charts/joplin/templates/db-persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{{- if .Values.persistence.enabled -}}
{{- if not .Values.persistence.pvcClaim }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
labels:
io.kompose.service: db
name: joplin-beta-db
{{- include "joplin.labels" . | nindent 4 }}
name: {{ .Chart.Name }}
spec:
storageClassName: "longhorn"
{{- if .Values.persistence.storageClassName }}
storageClassName: "{{ .Values.persistence.storageClassName }}"
{{ else }}

{{- end }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 4Gi
storage: {{ .Values.persistence.size }}
status: {}
{{- end }}
{{- end }}
62 changes: 46 additions & 16 deletions charts/joplin/templates/joplin-app-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: joplin-app
name: {{ .Chart.Name }}-app
labels:
{{- include "joplin.labels" . | nindent 4 }}
spec:
replicas: 1
replicas: {{ .Values.replicaCount }}
strategy:
type: Recreate
selector:
matchLabels:
app: joplin-app
app: {{ .Chart.Name }}-app
strategy: {}
template:
metadata:
labels:
app: joplin-app
app: {{ .Chart.Name }}-app
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- env:
- name: APP_BASE_URL
value: http://localhost:22300
value: {{ .Values.joplin.base_url }}
- name: APP_PORT
value: "22300"
- name: DB_CLIENT
value: pg
{{- if .Values.mailer.enabled }}
- name: MAILER_ENABLED
value: "0"
value: "1"
- name: MAILER_HOST
value: smtp.domain.tld
value: "{{ .Values.mailer.host }}"
- name: MAILER_NOREPLY_EMAIL
value: [email protected]
value: {{ .Values.mailer.noreplymail }}
- name: MAILER_NOREPLY_NAME
value: joplin-server
value: {{ .Values.mailer.noreplyname }}
- name: MAILER_PORT
value: "25"
value: "{{ .Values.mailer.port }}"
- name: MAILER_SECURITY
value: none
value: {{ .Values.mailer.security }}
- name: MAILER_AUTH_USER
value: {{ .Values.mailer.user }}
- name: MAILER_AUTH_PASSWORD
value: {{ .Values.mailer.password }}
{{- else }}
- name: MAILER_ENABLED
value: "0"
{{- end }}
- name: POSTGRES_DATABASE
value: joplin
value: {{ .Values.database.dbname }}
- name: POSTGRES_HOST
value: joplin-db
value: {{ .Chart.Name }}-db
- name: POSTGRES_PASSWORD
value: veryhugepasswordhere
value: {{ .Values.database.dbpassword }}
- name: POSTGRES_PORT
value: "5432"
- name: POSTGRES_USER
value: joplin
image: joplin/server:2.9.7-beta
value: {{ .Values.database.dbuser }}
image: "{{ .Values.image.joplin.repository }}:{{ .Values.image.joplin.tag }}"
name: joplin-app
ports:
- containerPort: 22300
resources: {}
restartPolicy: Always
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
status: {}

2 changes: 2 additions & 0 deletions charts/joplin/templates/joplin-app-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: v1
kind: Service
metadata:
name: joplin-app
labels:
{{- include "joplin.labels" . | nindent 4 }}
spec:
ports:
- name: "22300"
Expand Down
57 changes: 46 additions & 11 deletions charts/joplin/templates/joplin-db-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,75 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: joplin-db
labels:
{{- include "joplin.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: joplin-db
app: {{ .Chart.Name }}-db
replicas: 1
strategy:
type: Recreate
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: joplin-db
app: {{ .Chart.Name }}-db
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- env:
- name: POSTGRES_DB
value: joplin
value: {{ .Values.database.dbname }}
- name: POSTGRES_PASSWORD
value: veryhugepasswordhere
value: {{ .Values.database.dbpassword }}
- name: POSTGRES_USER
value: joplin
value: {{ .Values.database.dbuser }}
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
image: postgres:15
name: joplin-db
value: "/var/lib/postgresql/data/pgdata"
image: "{{ .Values.image.postgres.repository }}:{{ .Values.image.postgres.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
name: {{ .Chart.Name }}-db
ports:
- containerPort: 5432
resources: {}
livenessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 190
readinessProbe:
tcpSocket:
port: 5432
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.persistence.enabled }}
volumeMounts:
- mountPath: /var/lib/postgresql/data
subPath: pgdata
name: db
restartPolicy: Always
volumes:
- name: db
persistentVolumeClaim:
claimName: joplin-beta-db
claimName: {{ .Values.persistence.pvcClaim | default .Chart.Name }}
{{- end }}
restartPolicy: Always
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
status: {}
10 changes: 6 additions & 4 deletions charts/joplin/templates/joplin-db-service.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: joplin-db
name: {{ .Chart.Name }}-db
labels:
{{- include "joplin.labels" . | nindent 4 }}
spec:
ports:
- name: "5432"
- name: "postgresql"
port: 5432
targetPort: 5432
targetPort: {{ .Values.service.database.port }}
selector:
app: joplin-db
app: {{ .Chart.Name }}-db
status:
loadBalancer: {}
50 changes: 50 additions & 0 deletions charts/joplin/templates/joplin-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- if .Values.ingress.enabled -}}
{{- if not .Values.ingress.isIngressRoute -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Chart.Name }}-ingress
labels:
{{- include "joplin.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ .Values.ingress.domain }}
http:
paths:
- path: "/"
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ .Chart.Name }}-app
port:
number: 22300
{{- else }}
serviceName: {{ .Chart.Name }}-app
servicePort: 22300
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit 52bf9a5

Please sign in to comment.