Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjusting based on best practices; #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions seafile/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: seafile
description: A Helm chart for Seafile Server
type: application
version: 0.5.2
appVersion: 8.0.5
version: 1.0.0
appVersion: 11.0.2
icon: https://www.seafile.com/media/img/seafile-logo.png
home: https://github.com/300481/seafile-server
description: Seafile Server, Reliable and Performant File Sync and Share Solution on Kubernetes
Expand All @@ -23,15 +23,15 @@ annotations:
- add option to disable subchart memcached
artifacthub.io/images: |
- name: Seafile
image: 300481/seafile:8.0.5-20210627
image: seafileltd/seafile-mc:11.0.2
artifacthub.io/maintainers: |
- name: 300481
email: 300481@300481.de
dependencies:
- name: mariadb
version: 9.3.16
version: 14.1.2
repository: https://charts.bitnami.com/bitnami
- name: memcached
version: 5.13.1
version: 6.7.0
repository: https://charts.bitnami.com/bitnami
condition: memcached.enabled
59 changes: 59 additions & 0 deletions seafile/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ If release name contains chart name it will be used as a full name.
{{- end -}}
{{- end -}}


{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "seafile.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}


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

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand All @@ -39,3 +60,41 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}


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

{{/*
Looks if there's an existing secret and reuse its password. If not it generates
new password and use it.
*/}}
{{- define "seafile.adminPassword" -}}
{{- $secret := (lookup "v1" "Secret" (include "seafile.namespace" .) (include "seafile.fullname" .) ) -}}
{{- if $secret -}}
{{- index $secret "data" "admin-password" -}}
{{- else if .Values.seafile.adminPassword -}}
{{- .Values.seafile.auth.adminPassword -}}
{{- else -}}
{{- (randAlphaNum 40) | b64enc | quote -}}
{{- end -}}
{{- end -}}

{{/*
Defines default user.
*/}}
{{- define "seafile.adminMail" -}}
{{- if .Values.seafile.adminMail -}}
{{- .Values.seafile.auth.adminMail -}}
{{- else -}}
{{- "seafileadmin@example.com" | b64enc | quote -}}
{{- end -}}
{{- end -}}
19 changes: 19 additions & 0 deletions seafile/templates/helper_service_memcached.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.memcached.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: memcached
spec:
type: ExternalName
externalName: "{{ .Release.Name }}-memcached.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
{{- else if ne .Values.memcached.serviceFqdn "memcached" }}
---
apiVersion: v1
kind: Service
metadata:
name: memcached
spec:
type: ExternalName
externalName: "{{ .Values.memcached.serviceFqdn }}"
{{- end }}
11 changes: 8 additions & 3 deletions seafile/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ metadata:
# https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md#custom-max-body-size
# http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
nginx.ingress.kubernetes.io/proxy-body-size: "0"
{{- toYaml .Values.ingress.annotations | nindent 4 }}
{{- with .Values.ingress.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:
- hosts:
Expand All @@ -23,6 +28,6 @@ spec:
pathType: Prefix
backend:
service:
name: {{ include "seafile.fullname" . }}
name: {{ include "seafile.fullname" . }}-web
port:
number: 80
name: http
16 changes: 16 additions & 0 deletions seafile/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if not .Values.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "seafile.fullname" . }}
labels:
{{- include "seafile.labels" . | nindent 4 }}
{{- with .Values.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
type: Opaque
data:
admin-username: {{ template "seafile.adminMail" . }}
admin-password: {{ template "seafile.adminPassword" . }}
{{- end }}
36 changes: 7 additions & 29 deletions seafile/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "seafile.fullname" . }}
name: {{ include "seafile.fullname" . }}-web
labels:
{{ include "seafile.labels" . | indent 4 }}
{{- include "seafile.labels" . | nindent 4 }}
spec:
type: ClusterIP
clusterIP: "None"
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "seafile.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.memcached.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: memcached
spec:
type: ExternalName
externalName: "{{ .Release.Name }}-memcached.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
{{- else if ne .Values.memcached.serviceFqdn "memcached" }}
---
apiVersion: v1
kind: Service
metadata:
name: memcached
spec:
type: ExternalName
externalName: "{{ .Values.memcached.serviceFqdn }}"
{{- end }}
{{- include "seafile.selectorLabels" . | nindent 4 }}
13 changes: 13 additions & 0 deletions seafile/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "seafile.serviceAccountName" . }}
labels:
{{- include "seafile.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
96 changes: 71 additions & 25 deletions seafile/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,69 @@ kind: StatefulSet
metadata:
name: {{ include "seafile.fullname" . }}
labels:
{{ include "seafile.labels" . | indent 4 }}
{{- include "seafile.labels" . | nindent 4 }}
spec:
serviceName: {{ include "seafile.fullname" . }}
replicas: {{ if .Values.seafile.pause }}{{ 0 }}{{ else }}{{ 1 }}{{ end }}
replicas: {{ .Values.seafile.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "seafile.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "seafile.selectorLabels" . | nindent 6 }}
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "seafile.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "seafile.selectorLabels" . | nindent 8 }}
spec:
{{- if .Values.seafile.extraVolumes }}
volumes:
{{- with .Values.seafile.extraVolumes }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "seafile.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: seafile
image: {{ .Values.seafile.image }}
imagePullPolicy: Always
image: "{{ .Values.seafile.image.repository }}:{{ .Values.seafile.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.seafile.image.pullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
env:
- name: DB_HOST
value: "{{ .Release.Name }}-mariadb.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
- name: DB_ROOT_PASSWD
valueFrom:
secretKeyRef:
name: "{{ .Release.Name }}-mariadb"
key: mariadb-root-password
- name: SEAFILE_SERVER_LETSENCRYPT
value: "false"
{{ toYaml .Values.seafile.environment | indent 8 }}
- name: DB_HOST
value: "{{ .Release.Name }}-mariadb.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
- name: DB_ROOT_PASSWD
valueFrom:
secretKeyRef:
name: "{{ .Release.Name }}-mariadb"
key: mariadb-root-password
- name: SEAFILE_SERVER_LETSENCRYPT
value: "false"
- name: SEAFILE_SERVER_HOSTNAME
value: {{ .Values.ingress.host }}
- name: SEAFILE_ADMIN_EMAIL
valueFrom:
secretKeyRef:
{{- if .Values.seafile.existingSecret }}
name: {{ .Values.seafile.existingSecret }}
{{- else }}
name: {{ template "seafile.fullname" . }}
{{- end }}
key: admin-username
- name: SEAFILE_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.seafile.existingSecret }}
name: {{ .Values.seafile.existingSecret }}
{{- else }}
name: {{ template "seafile.fullname" . }}
{{- end }}
key: admin-password
{{- with .Values.seafile.env }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.seafile.probes }}
{{- toYaml . | nindent 8 }}
{{- end }}
ports:
- name: http
containerPort: 80
Expand All @@ -48,13 +74,33 @@ spec:
- name: seafile-data
mountPath: /shared
{{- with .Values.seafile.extraVolumeMounts }}
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.seafile.resources | nindent 12 }}
{{- if .Values.seafile.extraVolumes }}
volumes:
{{- with .Values.seafile.extraVolumes }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- 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 }}
volumeClaimTemplates:
- metadata:
name: seafile-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.seafile.persistence.size }}
storage: {{ .Values.seafile.persistence.size }}
Loading