Skip to content

Commit

Permalink
Merge pull request #45 from JacekZubielik/syncthing
Browse files Browse the repository at this point in the history
Syncthing
  • Loading branch information
JacekZubielik authored Jun 4, 2024
2 parents 95483a0 + fc63155 commit b5cc335
Show file tree
Hide file tree
Showing 7 changed files with 408 additions and 185 deletions.
9 changes: 5 additions & 4 deletions charts/syncthing/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
apiVersion: v2
appVersion: 1.27.4
appVersion: 1.27.8
description: Syncthing Continuous File Synchronization
name: syncthing
version: 0.0.1
version: 0.0.2
type: application
keywords:
- synchronization
- peer-to-peer
- p2p
home: https://github.com/JacekZubielik/jz-helm-charts/tree/master/charts/syncthing
icon: https://raw.githubusercontent.com/syncthing/syncthing/main/assets/logo-only.svg
icon: https://github.com/syncthing/syncthing/blob/main/assets/logo-512.png
sources:
- https://github.com/syncthing/syncthing
- https://github.com/syncthing/syncthing
maintainers:
- name: jacekzubielik
185 changes: 128 additions & 57 deletions charts/syncthing/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,94 +1,165 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "app.fullname" . }}
name: {{ template "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ include "app.name" . }}
helm.sh/chart: {{ include "app.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
replicas: {{ .Values.replicas }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "app.selectorLabels" . | nindent 6 }}
app.kubernetes.io/name: {{ include "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
strategy:
type: {{ .Values.strategyType }}
template:
metadata:
{{- with .Values.podAnnotations }}
labels:
app.kubernetes.io/name: {{ include "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
labels:
{{- include "app.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
{{- with .Values.image.PullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
shareProcessNamespace: {{ .Values.sidecarSingleProcessNamespace }}
serviceAccountName: {{ include "app.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- toYaml .Values.securityContext | nindent 8 }}
{{- if .Values.hostNetwork }}
hostNetwork: {{ .Values.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
{{- end }}

containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.web.port }}
protocol: TCP
- name: tcp
containerPort: {{ .Values.service.tcp.port }}
protocol: TCP
- name: udp
containerPort: {{ .Values.service.udp.port }}
protocol: UDP
- name: discovery
containerPort: {{ .Values.service.discovery.port }}
protocol: UDP
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
volumeMounts:
- name: data
mountPath: {{ .Values.persistence.mountPath }}
{{- range .Values.persistence.extraVolumes }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}

ports:
- name: http
containerPort: {{ .Values.service.web.port }}
protocol: TCP
- name: tcp
containerPort: {{ .Values.service.tcp.port }}
protocol: TCP
- name: udp
containerPort: {{ .Values.service.udp.port }}
protocol: UDP
- name: discovery
containerPort: {{ .Values.service.discovery.port }}
protocol: UDP
{{- range .Values.service.additionalPorts }}
- name: {{ .name }}
containerPort: {{ .targetPort }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
tcpSocket:
port: {{ .Values.service.web.port }}
# scheme: {{ .Values.livenessProbe.scheme }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
tcpSocket:
port: {{ .Values.service.web.port }}
# scheme: {{ .Values.livenessProbe.scheme }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.startupProbe.enabled }}
startupProbe:
tcpSocket:
port: {{ .Values.service.web.port}}
# scheme: {{ .Values.startupProbe.scheme }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
{{- end }}
env:
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key | }}
value: {{ $value | }}
{{- end }}
{{- range $name, $opts := .Values.extraEnvSecrets }}
- name: {{ $name }}
valueFrom:
secretKeyRef:
name: {{ $opts.secret }}
key: {{ $opts.key }}
{{- end }}
envFrom:
{{- range .Values.extraSecretForEnvFrom }}
- secretRef:
name: {{ . }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /var/syncthing
name: data
{{- range .Values.hostMounts }}
{{- if .mountPath }}
- mountPath: {{ .mountPath }}
{{- else }}
- mountPath: {{ .hostPath }}
{{- end }}
name: {{ .name }}
{{- end }}
{{- if .Values.extraVolumeMounts }}{{ toYaml .Values.extraVolumeMounts | trim | nindent 10 }}
{{ end }}
volumes:
- name: data
{{- if .Values.persistence.enabled }}
{{- if .Values.persistence.configstorage.hostPath }}
{{- if .Values.persistence.hostPath }}
hostPath:
path: {{.Values.persistence.configstorage.hostPath}}
{{- else }}
path: {{.Values.persistence.hostPath }}
type: Directory
{{- else }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "app.fullname" . }}{{- end }}
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "app.fullname" . }}
{{- end }}
{{- end }}
{{- else }}
emptyDir: {}
{{ end }}

{{- range .Values.persistence.extraVolumes }}
{{- range .Values.hostMounts }}
- name: {{ .name }}
persistentVolumeClaim:
claimName: {{ if .existingClaim }}{{ .existingClaim }}{{- else }}{{ template "app.fullname" $ }}-{{ .name }}{{- end }}
hostPath:
path: {{ .hostPath }}
{{- if .type }}
type: {{ .type }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
33 changes: 21 additions & 12 deletions charts/syncthing/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "app.fullname" . }}
name: {{ template "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ include "app.name" . }}
helm.sh/chart: {{ include "app.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "app.fullname" . }}
name: {{ include "app.name" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
{{- if .Values.autoscaling.averageCPUUtilizationPercentage }}
- type: ContainerResource
containerResource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
container: {{ include "app.name" . }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.averageCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
{{- if .Values.autoscaling.averageMemoryUtilizationPercentage }}
- type: ContainerResource
containerResource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
container: {{ include "app.name" . }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.averageMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
25 changes: 15 additions & 10 deletions charts/syncthing/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{{- if and .Values.persistence.pvc.enabled (not .Values.persistence.configstorage.hostPath) }}
{{- if .Values.persistence.enabled -}}
{{- if not .Values.persistence.existingClaim -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
app.kubernetes.io/name: {{ include "app.name" . }}
helm.sh/chart: {{ include "app.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
accessModes:
- {{ .Values.persistence.pvc.accessMode }}
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.pvc.size }}
{{- if .Values.persistence.pvc.storageClass }}
{{- if (eq "-" .Values.persistence.pvc.storageClass) }}
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.pvc.storageClass }}"
{{- end }}
{{- end }}
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
Loading

0 comments on commit b5cc335

Please sign in to comment.