diff --git a/logseq-syncthing-chart/.helmignore b/logseq-syncthing-chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/logseq-syncthing-chart/.helmignore @@ -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/ diff --git a/logseq-syncthing-chart/Chart.yaml b/logseq-syncthing-chart/Chart.yaml new file mode 100644 index 0000000..be9528f --- /dev/null +++ b/logseq-syncthing-chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: logseq-syncthing +description: A Helm chart for deploying the webapp of logseq with syncthing in the background +type: application +version: 0.1.0 +appVersion: "latest" diff --git a/logseq-syncthing-chart/templates/_helpers.tpl b/logseq-syncthing-chart/templates/_helpers.tpl new file mode 100644 index 0000000..5e2879f --- /dev/null +++ b/logseq-syncthing-chart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "logseq-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 "logseq-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 "logseq-syncthing-chart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "logseq-syncthing-chart.labels" -}} +helm.sh/chart: {{ include "logseq-syncthing-chart.chart" . }} +{{ include "logseq-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 "logseq-syncthing-chart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "logseq-syncthing-chart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "logseq-syncthing-chart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "logseq-syncthing-chart.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/logseq-syncthing-chart/templates/deployment.yaml b/logseq-syncthing-chart/templates/deployment.yaml new file mode 100644 index 0000000..06190f3 --- /dev/null +++ b/logseq-syncthing-chart/templates/deployment.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "logseq-syncthing-chart.fullname" . }} + labels: + app: {{ include "logseq-syncthing-chart.name" . }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ include "logseq-syncthing-chart.name" . }} + template: + metadata: + labels: + app: {{ include "logseq-syncthing-chart.name" . }} + spec: + containers: + - name: logseq + image: "{{ .Values.image.logseq.repository }}:{{ .Values.image.logseq.tag }}" + imagePullPolicy: {{ .Values.image.logseq.pullPolicy }} + ports: + - containerPort: 80 + volumeMounts: + - name: logseq-vault + mountPath: /vault + - name: syncthing + image: "{{ .Values.image.syncthing.repository }}:{{ .Values.image.syncthing.tag }}" + imagePullPolicy: {{ .Values.image.syncthing.pullPolicy }} + ports: + - containerPort: 8384 + volumeMounts: + - name: logseq-vault + mountPath: /vault + - name: syncthing-config + mountPath: /config + + volumes: + - name: logseq-vault + persistentVolumeClaim: + claimName: logseq-vault-pvc + - name: syncthing-config + persistentVolumeClaim: + claimName: syncthing-config-pvc + diff --git a/logseq-syncthing-chart/templates/ingress-logseq.yaml b/logseq-syncthing-chart/templates/ingress-logseq.yaml new file mode 100644 index 0000000..f03d7f8 --- /dev/null +++ b/logseq-syncthing-chart/templates/ingress-logseq.yaml @@ -0,0 +1,14 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: logseq-ingress +spec: + defaultBackend: + service: + name: {{ include "logseq-syncthing-chart.fullname" . }}-logseq + port: + number: 80 + ingressClassName: tailscale + tls: + - hosts: + - notes \ No newline at end of file diff --git a/logseq-syncthing-chart/templates/ingress-syncthing.yaml b/logseq-syncthing-chart/templates/ingress-syncthing.yaml new file mode 100644 index 0000000..3c87d93 --- /dev/null +++ b/logseq-syncthing-chart/templates/ingress-syncthing.yaml @@ -0,0 +1,14 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: syncthing-ingress +spec: + defaultBackend: + service: + name: {{ include "logseq-syncthing-chart.fullname" . }}-syncthing + port: + number: 8384 + ingressClassName: tailscale + tls: + - hosts: + - syncthing-notes \ No newline at end of file diff --git a/logseq-syncthing-chart/templates/pvc-logseq-vault.yaml b/logseq-syncthing-chart/templates/pvc-logseq-vault.yaml new file mode 100644 index 0000000..b92d076 --- /dev/null +++ b/logseq-syncthing-chart/templates/pvc-logseq-vault.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: logseq-vault-pvc + labels: + app: logseq-syncthing +spec: + storageClassName: {{ .Values.persistentVolume.storageClass }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.persistentVolume.size }} diff --git a/logseq-syncthing-chart/templates/pvc-syncthing-config.yaml b/logseq-syncthing-chart/templates/pvc-syncthing-config.yaml new file mode 100644 index 0000000..fab1e92 --- /dev/null +++ b/logseq-syncthing-chart/templates/pvc-syncthing-config.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: syncthing-config-pvc + labels: + app: logseq-syncthing +spec: + storageClassName: {{ .Values.persistentVolume.storageClass }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "100Mi" diff --git a/logseq-syncthing-chart/templates/service-logseq.yaml b/logseq-syncthing-chart/templates/service-logseq.yaml new file mode 100644 index 0000000..4bb3556 --- /dev/null +++ b/logseq-syncthing-chart/templates/service-logseq.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "logseq-syncthing-chart.fullname" . }}-logseq + labels: + app: {{ include "logseq-syncthing-chart.name" . }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.service.logseq.port }} + targetPort: 80 + protocol: TCP + name: http + selector: + app: {{ include "logseq-syncthing-chart.name" . }} diff --git a/logseq-syncthing-chart/templates/service-syncthing.yaml b/logseq-syncthing-chart/templates/service-syncthing.yaml new file mode 100644 index 0000000..344ffea --- /dev/null +++ b/logseq-syncthing-chart/templates/service-syncthing.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "logseq-syncthing-chart.fullname" . }}-syncthing + labels: + app: {{ include "logseq-syncthing-chart.name" . }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.service.syncthing.port }} + targetPort: 8384 + protocol: TCP + name: syncthing + selector: + app: {{ include "logseq-syncthing-chart.name" . }} diff --git a/logseq-syncthing-chart/templates/tests/test-connection.yaml b/logseq-syncthing-chart/templates/tests/test-connection.yaml new file mode 100644 index 0000000..89b0895 --- /dev/null +++ b/logseq-syncthing-chart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "logseq-syncthing-chart.fullname" . }}-test-connection" + labels: + {{- include "logseq-syncthing-chart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "logseq-syncthing-chart.fullname" . }}:{{ .Values.service.logseq.port }}'] + restartPolicy: Never diff --git a/logseq-syncthing-chart/values.yaml b/logseq-syncthing-chart/values.yaml new file mode 100644 index 0000000..1cae1e1 --- /dev/null +++ b/logseq-syncthing-chart/values.yaml @@ -0,0 +1,34 @@ +replicaCount: 1 + +image: + logseq: + repository: ghcr.io/logseq/logseq-webapp + tag: "latest" + pullPolicy: IfNotPresent + syncthing: + repository: linuxserver/syncthing + tag: "1.27.11" + pullPolicy: IfNotPresent + +service: + logseq: + type: ClusterIP + port: 80 + syncthing: + type: ClusterIP + port: 8384 + +persistentVolume: + storageClass: "longhorn" + size: "5Gi" + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000