Setup Seafile with a single K8S pod¶
This manual explains how to deploy and run Seafile server on a Linux server using Kubernetes (k8s thereafter) in a single pod (i.e., single node mode). So this document is essentially an extended description of the Docker-based Seafile single-node deployment (support both CE and Pro).
For specific environment and configuration requirements, please refer to the description of the Docker-based Seafile single-node deployment. Please also refer to the description of the K8S tool section in here.
Gettings started¶
For persisting data using in the docker-base deployment, /opt/seafile-data
, is still adopted in this manual. What's more, all K8S YAML files will be placed in /opt/seafile-k8s-yaml
(replace it when following these instructions if you would like to use another path).
By the way, we don't provide the deployment methods of basic services (e.g., Memcached, MySQL and Elasticsearch) and seafile-compatibility components (e.g., SeaDoc) for K8S in our document. If you need to install these services in K8S format, you can refer to the rewrite method of this document.
Down load the YAML files for Seafile Server¶
mkdir -p /opt/seafile-k8s-yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/pro/seafile-deployment.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/pro/seafile-persistentvolume.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/pro/seafile-persistentvolumeclaim.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/pro/seafile-service.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/pro/seafile-env.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/pro/seafile-secret.yaml
mkdir -p /opt/seafile-k8s-yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/ce/seafile-deployment.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/ce/seafile-persistentvolume.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/ce/seafile-persistentvolumeclaim.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/ce/seafile-service.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/ce/seafile-env.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/12.0/repo/k8s/ce/seafile-secret.yaml
In here we suppose you download the YAML files in /opt/seafile-k8s-yaml
, which mainly include about:
seafile-deployment.yaml
for Seafile server pod management and creation,seafile-service.yaml
for exposing Seafile services to the external network,seafile-persistentVolume.yaml
for defining the location of a volume used for persistent storage on the hostseafile-persistentvolumeclaim.yaml
for declaring the use of persistent storage in the container.
For futher configuration details, you can refer the official documents.
Modify seafile-env.yaml
and seafile-secret.yaml
¶
Similar to Docker-base deployment, Seafile cluster in K8S deployment also supports use files to configure startup progress, you can modify common environment variables by
nano /opt/seafile-k8s-yaml/seafile-env.yaml
and sensitive information (e.g., password) by
nano /opt/seafile-k8s-yaml/seafile-secret.yaml
For seafile-secret.yaml
To modify sensitive information (e.g., password), you need to convert the password into base64 encoding before writing it into the seafile-secret.yaml
file:
echo -n '<your-value>' | base64
Warning
For the fields marked with <...>
are required, please make sure these items are filled in, otherwise Seafile server may not run properly.
Start Seafile server¶
You can start Seafile server simply by
kubectl apply -f /opt/seafile-k8s-yaml/
Warning
By default, Seafile will access the Memcached and Elasticsearch with the specific service name:
- Memcached:
memcached
with port 11211 - Elasticsearch:
elasticsearch
with port 9200
If the above services are:
- Not in your K8S pods (including using an external service)
- With different service name
- With different server port
Please modfiy the files in /opt/seafile-data/seafile/conf
(especially the seafevents.conf
, seafile.conf
and seahub_settings.py
) to make correct the configurations for above services, otherwise the Seafile server cannot start normally. Then restart Seafile server:
kubectl delete -f /opt/seafile-k8s-yaml/
kubectl apply -f /opt/seafile-k8s-yaml/
Activating the Seafile License¶
If you have a seafile-license.txt
license file, simply put it in the volume of the Seafile container. The volumne's default path in the Compose file is /opt/seafile-data
. If you have modified the path, save the license file under your custom path.
If the license file has a different name or cannot be read, Seafile server will start with in trailer mode with most THREE users
Then restart Seafile:
kubectl delete -f /opt/seafile-k8s-yaml/
kubectl apply -f /opt/seafile-k8s-yaml/
Container management¶
Similar to docker installation, you can also manage containers through some kubectl commands. For example, you can use the following command to check whether the relevant resources are started successfully and whether the relevant services can be accessed normally. First, execute the following command and remember the pod name with seafile-
as the prefix (such as seafile-748b695648-d6l4g
)
kubectl get pods
You can check a status of a pod by
kubectl logs seafile-748b695648-d6l4g
and enter a container by
kubectl exec -it seafile-748b695648-d6l4g -- bash
HTTPS¶
Please refer to here about suggestions of enabling HTTPS in K8S.
Seafile directory structure¶
Please refer to here for the details.
Send logs to Loki
You can directly view the log files of single-pod Seafile in the persistent volume directory, as the log files are distinguishable even the node of pod has changed (because there will only be one node running Seafile), so by default single-pod Seafile logs are not output to standard output. If you need to record these log files to a log server (e.g., Loki), you can refer to here for more informations.