Setup Seafile with a single K8S pod with K8S resources files¶
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.
System requirements¶
Please refer here for the details of system requirements about Seafile service. By the way, this will apply to all nodes where Seafile pods may appear in your K8S cluster. In general, we recommend that each node should have at least 2G RAM and a 2-core CPU (> 2GHz).
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., Redis, MySQL and the search engine service) 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.
Create namespace and secretMap¶
kubectl create ns seafile
kubectl create secret generic seafile-secret --namespace seafile \
--from-literal=JWT_PRIVATE_KEY='<required>' \
--from-literal=SEAFILE_MYSQL_DB_PASSWORD='<required>' \
--from-literal=INIT_SEAFILE_ADMIN_PASSWORD='<required>' \
--from-literal=INIT_SEAFILE_MYSQL_ROOT_PASSWORD='<required>' \
--from-literal=REDIS_PASSWORD='' \
--from-literal=S3_SECRET_KEY='' \
--from-literal=S3_SSE_C_KEY=''
kubectl create ns seafile
kubectl create secret generic seafile-secret --namespace seafile \
--from-literal=JWT_PRIVATE_KEY='<required>' \
--from-literal=SEAFILE_MYSQL_DB_PASSWORD='<required>' \
--from-literal=INIT_SEAFILE_ADMIN_PASSWORD='<required>' \
--from-literal=INIT_SEAFILE_MYSQL_ROOT_PASSWORD='<required>' \
--from-literal=REDIS_PASSWORD=''
Down load the YAML files for Seafile Server¶
mkdir -p /opt/seafile-k8s-yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/pro/seafile-deployment.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/pro/seafile-persistentvolume.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/pro/seafile-persistentvolumeclaim.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/pro/seafile-service.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/pro/seafile-env.yaml
mkdir -p /opt/seafile-k8s-yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/ce/seafile-deployment.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/ce/seafile-persistentvolume.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/ce/seafile-persistentvolumeclaim.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/ce/seafile-service.yaml
wget -P /opt/seafile-k8s-yaml https://manual.seafile.com/14.0/repo/k8s/ce/seafile-env.yaml
In here we suppose you download the YAML files in /opt/seafile-k8s-yaml, which mainly include about:
seafile-deployment.yamlfor Seafile server pod management and creation,seafile-service.yamlfor exposing Seafile services to the external network,seafile-persistentVolume.yamlfor defining the location of a volume used for persistent storage on the hostseafile-persistentvolumeclaim.yamlfor declaring the use of persistent storage in the container.
Use PV bound from a storage class
If you would like to use automatically allocated persistent volume (PV) by a storage class, please modify seafile-persistentvolumeclaim.yaml and specify storageClassName. On the other hand, the PV defined by seafile-persistentvolume.yaml can be disabled:
rm /opt/seafile-k8s-yaml/seafile-persistentvolume.yaml
For futher configuration details, you can refer the official documents.
Modify seafile-env.yaml¶
Edit seafile-env.yaml to configure non-sensitive server settings. This ConfigMap includes the common server, database, cache, storage, extension, and search settings, as well as Kubernetes-specific SEAFILE_LOG_TO_STDOUT, SITE_ROOT, and SEAFILE_MYSQL_DB_PORT. Keep passwords and keys in the seafile-secret Secret created above.
nano /opt/seafile-k8s-yaml/seafile-env.yaml
Warning
Fields marked with <...> are required. Fill them in before deployment, otherwise Seafile server may not run properly.
Start Seafile server¶
You can start Seafile server and specify the resources into the namespace seafile for easier management by
kubectl apply -f /opt/seafile-k8s-yaml/ -n seafile
Activating the Seafile License (Pro)¶
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 pods -n seafile $(kubectl get pods -n seafile -o jsonpath='{.items[*].metadata.name}' | grep seafile)
Uninstall Seafile K8S¶
You can uninstall the Seafile K8S by the following command:
kubectl delete -f /opt/seafile-k8s-yaml/ -n seafile
Advanced operations¶
Please refer from here or click Extensions tab for futher Seafile functions