The old seafile (6.3.5) was very easy to deploy to kubernetes since it was just a single container! Even if it wasn’t too scalable…
I’ve made a new Kubernetes config for the modern Seafile (8.0) which seems to work and is pretty much plug and play. Ideally one should separate the services out as individual pods which would make it scalable as needed but this is working for my purposes.
The main issue I ran into here was with memcached… it seems the “memcached” hostname is hardcoded and can’t be overridden. In a kubernetes deployment everything is on localhost (127.0.0.1) - you likely won’t run into this issue if you want to create separate pods and services.
Note you’ll need to do your volume mounts first, in my example you’d need a claim called seafile-pv-claim. You’ll also need to sort some of the indentations out… I can’t get them pasting correctly >.>
apiVersion: apps/v1
kind: Deployment
metadata:
name: seafile
spec:
selector:
matchLabels:
app: seafile
strategy:
type: Recreate
template:
metadata:
labels:
app: seafile
spec:
hostAliases:
- ip: “127.0.0.1”
hostnames:
- “memcached”
containers:
- image: mariadb:10.5
name: seafile-mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: “asecret”
- name: MYSQL_LOG_CONSOLE
value: “true”
volumeMounts:
- name: seafile-data
mountPath: /var/lib/mysql/
subPath: seafile-db
- image: memcached:1.5.6
name: seafile-memcached
command: [“memcached”]
args: ["-m 256"]
- image: seafileltd/seafile-mc:latest
name: seafile
env:
- name: DB_HOST
value: “127.0.0.1”
- name: DB_ROOT_PASSWD
value: “asecret”
- name: SEAFILE_ADMIN_EMAIL
value: “hello@example.com”
- name: SEAFILE_ADMIN_PASSWORD
value: “asecret”
- name: SEAFILE_SERVER_LETSENCRYPT
value: “false”
- name: SEAFILE_SERVER_HOSTNAME
value: “xxx”
volumeMounts:
- name: seafile-data
mountPath: /shared/
subPath: seafile-data
volumes:
- name: seafile-data
persistentVolumeClaim:
claimName: seafile-pv-claim
You’d then need a service
apiVersion: v1
kind: Service
metadata:
name: seafile
spec:
ports:
- port: 80
selector:
app: seafile
And finally an ingress, note I’ve got certmanager handling SSL here so I’ve got a cluster issuer called “letsencrypt-prod” which will dish out certificates.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: seafile
annotations:
kubernetes.io/ingress.class: “nginx”
cert-manager.io/cluster-issuer: “letsencrypt-prod”
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $server_name;
spec:
tls:
- hosts:
- cloud.example.com
secretName: cloud
rules:
- host: cloud.example.com
http:
paths:
- path: /
backend:
serviceName: seafile
servicePort: 80