First charts - obsidian and trilium with syncthing

This commit is contained in:
2024-09-22 09:00:34 +01:00
parent 4f55980f3a
commit 89e3e40938
22 changed files with 496 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "trilium-syncthing-chart.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 "trilium-syncthing-chart.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 "trilium-syncthing-chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "trilium-syncthing-chart.labels" -}}
helm.sh/chart: {{ include "trilium-syncthing-chart.chart" . }}
{{ include "trilium-syncthing-chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "trilium-syncthing-chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "trilium-syncthing-chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "trilium-syncthing-chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "trilium-syncthing-chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "trilium-syncthing-chart.fullname" . }}
labels:
app: {{ include "trilium-syncthing-chart.name" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ include "trilium-syncthing-chart.name" . }}
template:
metadata:
labels:
app: {{ include "trilium-syncthing-chart.name" . }}
spec:
containers:
- name: trilium
image: "{{ .Values.image.trilium.repository }}:{{ .Values.image.trilium.tag }}"
imagePullPolicy: {{ .Values.image.trilium.pullPolicy }}
ports:
- containerPort: 8080
volumeMounts:
- name: trilium-vault
mountPath: /home/node/trilium-data
securityContext:
runAsUser: 1000
- name: syncthing
image: "{{ .Values.image.syncthing.repository }}:{{ .Values.image.syncthing.tag }}"
imagePullPolicy: {{ .Values.image.syncthing.pullPolicy }}
ports:
- containerPort: 8384
volumeMounts:
- name: trilium-vault
mountPath: /vault
- name: syncthing-config
mountPath: /config
securityContext:
runAsUser: 1000
volumes:
- name: trilium-vault
persistentVolumeClaim:
claimName: trilium-vault-pvc
- name: syncthing-config
persistentVolumeClaim:
claimName: syncthing-config-pvc

View File

@@ -0,0 +1,14 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: syncthing-ingress
spec:
defaultBackend:
service:
name: {{ include "trilium-syncthing-chart.fullname" . }}-syncthing
port:
number: 8384
ingressClassName: tailscale
tls:
- hosts:
- syncthing-notes

View File

@@ -0,0 +1,14 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: trilium-ingress
spec:
defaultBackend:
service:
name: {{ include "trilium-syncthing-chart.fullname" . }}-trilium
port:
number: 8080
ingressClassName: tailscale
tls:
- hosts:
- notes

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: syncthing-config-pvc
labels:
app: trilium-syncthing
spec:
storageClassName: {{ .Values.persistentVolume.storageClass }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "100Mi"

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: trilium-vault-pvc
labels:
app: trilium-syncthing
spec:
storageClassName: {{ .Values.persistentVolume.storageClass }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.persistentVolume.size }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "trilium-syncthing-chart.fullname" . }}-syncthing
labels:
app: {{ include "trilium-syncthing-chart.name" . }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.service.syncthing.port }}
targetPort: 8384
protocol: TCP
name: syncthing
selector:
app: {{ include "trilium-syncthing-chart.name" . }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "trilium-syncthing-chart.fullname" . }}-trilium
labels:
app: {{ include "trilium-syncthing-chart.name" . }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.service.trilium.port }}
targetPort: 8080
protocol: TCP
name: http
selector:
app: {{ include "trilium-syncthing-chart.name" . }}