seafile-admin-docs/manual/setup/helm_chart_single_node.md
2025-02-14 17:42:52 +08:00

7.5 KiB

Setup Seafile with a single K8S pod with Seafile Helm Chart

This manual explains how to deploy and run Seafile server on a Linux server using Seafile Helm Chart (chart thereafter) in a single pod (i.e., single node mode). Comparing to Setup by K8S resource files, deployment with helm chart can simplify the deployment process and provide more flexible deployment control, which the way we recommend in deployment with K8S.

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.

Preparation

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 in this document.

System requirements

Please refer here for system requirements about Seafile service. By the way, this will apply to all nodes where Seafile pods may appear in your K8S cluster.

Install Seafile helm chart

  1. Create namespace

    kubectl create namespace seafile
    
  2. Create a secret for sensitive data

    === "Seafile Pro"

     ```sh
     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=INIT_S3_SECRET_KEY=''  
     ```
    

    === "Seafile CE"

     ```sh
     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>'
     ```
    
  3. Download and modify the my-values.yaml according to your configurations. By the way, you can follow here for the details:

    === "Seafile Pro"

     ```sh
     wget -O my-values.yaml https://seafileltd.github.io/seafile-helm-chart/values/pro.yaml
    
     nano my-values.yaml
     ```
    

    === "Seafile CE"

     ```sh
     wget -O my-values.yaml https://seafileltd.github.io/seafile-helm-chart/values/ce.yaml
    
     nano my-values.yaml
     ```
    
  4. Then install the chart use the following command:

    === "Seafile Pro"

     ```sh
     helm repo add seafile https://github.com/seafileltd/seafile-helm-chart
     helm upgrade --install seafile seafile/pro  --namespace seafile --create-namespace --values my-values.yaml
     ```
    

    === "Seafile CE"

     ```sh
     helm repo add seafile https://github.com/seafileltd/seafile-helm-chart
     helm upgrade --install seafile seafile/ce  --namespace seafile --create-namespace --values my-values.yaml
     ```
    

After installing the chart, the Seafile pod should startup automaticlly.

!!! note "About Seafile service" The default service type of Seafile is LoadBalancer. You should specify K8S load balancer for Seafile or specify at least one external ip, that can be accessed from external networks.

!!! warning "Important for Pro edition" By default, Seafile (Pro) 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:

```sh
kubectl delete pods -n seafile $(kubectl get pods -n seafile -o jsonpath='{.items[*].metadata.name}' | grep 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.

!!! danger "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)

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 -n seafile

You can check a status of a pod by

kubectl logs seafile-748b695648-d6l4g -n seafile

and enter a container by

kubectl exec -it seafile-748b695648-d6l4g -n seafile --  bash

Uninstall chart

You can uninstall chart by the following command:

helm delete seafile --namespace seafile

Advanced operations

Extra volumes

In this part, we take encrypted seafile-license file for example. You can also create a secret resource to encrypt your license file in your K8S cluster:

kubectl create secret generic seafile-license --from-file=seafile-license.txt=$PATH_TO_YOUR_LICENSE_FILE --namespace seafile

Then modify my-values.yaml to add the information extra volumes:

seafile:
  ...
  extraVolumes:
    - name: seafileLicense
    volumeInfo:
        secret:
        secretName: seafile-license
            items:
            - key: seafile-license.txt
                path: seafile-license.txt
    subPath: seafile-license.txt
    mountPath: /shared/seafile/seafile-license.txt
    readOnly: true

Finally you can upgrade your chart by:

=== "Seafile Pro"

```sh
helm upgrade --install seafile seafile/pro  --namespace seafile --create-namespace --values my-values.yaml
```

=== "Seafile CE"

```sh
helm upgrade --install seafile seafile/ce  --namespace seafile --create-namespace --values my-values.yaml
```

!!! success "Flexible in Seafile Helm Chart" No only the extra volumes, you can also define the other environment variables objects (i.e., extraEnv) and resources objects (i.e., extraResources) in my-values.yaml

Other advanced operations

Please refer from here for futher advanced operations.