sophora-server
A Helm chart for the Sophora Server
About this chart
Sophora server
The required secrets must be present before you install the server.
Archive repository persistence
Starting with Sophora 5, the archive repository is no longer available.
To disable all archive-related storage options, set sophora.server.persistence.archiveType to none.
In later chart versions this will be the default.
Postgres connection
Starting with Sophora 5, the installation requires postgres.
You can provide credentials via a secret: sophora.server.persistence.postgres.secret.
To enable postgres support set sophora.server.persistence.postgres.enabled to true.
For all other configuration options use sophora.server.properties.
It's also possible to use postgres as your jcr repository. To use postgres with jcr set sophora.server.persistence.repositoryType to postgres.
Multi Postgres support
Starting with Sophora 6, staging servers require postgres. Typically, Sophora staging servers use statefulset scaling, but they still need a unique postgres database per instance. You can achieve this by doing the following:
- Set
sophora.server.persistence.multiPostgres.enabledtotrue. - Configure all postgres connections under
sophora.server.persistence.multiPostgres.byPodIndex. Each config entry belongs to a pod at the index.
Example
sophora:
server:
persistence:
multiPostgres:
enabled: true
byPodIndex:
# config for pod 0
- hostname: db.host
port: "5432"
database: "sophora-0"
secret:
name: secret-1
usernameKey: username
passwordKey: password
# config for pod 1
- hostname: db.host
port: "5432"
database: "sophora-1"
secret:
name: secret-1
usernameKey: username
passwordKey: password
See also: Postgres Native Sidecar
Sophora RPC (Sophora v6+)
Sophora 6 introduces a completely new API for client-server communication called Sophora RPC (short srpc). Srpc is based on gRPC which in return is essentially HTTP/2 but requires specific non-default settings in most HTTP proxies, including Ingress Controllers. To deal with this, the chart now supports deploying a second Ingress or HTTPRoute for the gRPC API, which can be configured differently from the main Ingress/HTTPRoute.
This is not enabled by default.
To enable it, set grpcIngress.enabled, grpcRoute.enabled or grpcHttproute to true and configure it as needed.
The example configuration contains the required settings for the Nginx Ingress Controller (all paths starting with /sophora.srpc. need to be forwarded as gRPC traffic). Use grpcHttproute instead of grpcRoute if the same hostname is used as for the httpRoute (see Cross Serving).
Note on addressability
As the Sophora Server now offers two services on different ports (1196 and 2026) different scenarios occur how this will be accessible:
-
Different hostnames
This is the simplest solution: Create an Ingress or HttpRoute for each target port with a distinct hostname. With this configuration it is clear what a client will reach when using that hostname. But the ServerInfo only contains a single external hostname! So beware if utils use that to connect as only a single hostname can be configured.
https://server-http.example.com:443 -> server-headless.mycluster.local:1196 https://server-grpc.example.com:443 -> server-headless.mycluster.local:2026 -
Same hostname
-
Different ports
When using the same hostname for the Sophora Server clients can use a different port to distinguish which service they want to use. This requires the reverse proxy/Ingerss Controller/Gateway to provide that additional port.https://server.example.com:1196 -> server-headless.mycluster.local:1196 https://server.example.com:443 -> server-headless.mycluster.local:2026 -
Same port
This is difficult. The external URL uses the same hostname and port. But request should reach different backends dependent on the request. One possible solution is to match the request path. A regular expression match for/sophora.srpc.*can be used for all traffic going to port 2026 of the Sophora Server.https://server.example.com:443/ -> server-headless.mycluster.local:1196 https://server.example.com:443/sophora.srpc.v1.ServerService/GetServerInfo -> server-headless.mycluster.local:2026
-
Tips for productive installations
Cluster servers
Cluster servers require one statefulset per instance. Deploy multiple statefulsets to create an actual sophora cluster.
Therefore replicaCount only supports 0 and 1.
Pod Anti-Affinity
To prevent multiple cluster servers from being scheduled on the same k8s node, you can use the podAntiAffinity. Per default, you can write the following in your values file:
additionalSelectorLabels:
sophora.cloud/app: cluster-server
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: sophora.cloud/app
operator: In
values:
- cluster-server
topologyKey: "kubernetes.io/hostname"
This configuration will give all sophora servers deployed by this file the label sophora.cloud/app=cluster-server and then perform
a check during scheduling whether a deployment on a k8s node already has a pod running with these labels. If so, the scheduler
will use a different node to schedule the deployment.
You could also use a different topologyKey in order to make sure that deployments are not only spread across unique nodes but
also across unique zones or regions.
This is only necessary for cluster servers as there are usually only two of them, and you would want to ensure that in case of a node failure, at least one cluster server remains running.
Taint tolerations
Kubernetes allows selecting a node to schedule a pod based on different criteria. If one wants to make sure pod is only scheduled on a certain node, one shall set a node affinity. If the node shall be exclusive for this kind of pod, there is the possibility to taint the node and provide the pods with a set of toleration to tolerate the taint. In Sophora, one may use this to provide a separate node pool for a certain type of sophora servers exclusively. Further information on how taints work: kubernetes.io/Taints and Tolerations
Server pre-stop lifecycle hook
All Sophora cluster servers are equipped with a pre-stop lifecycle hook, that is executed when the pod is about to shut down due to user request, uninstallation or the Kubernetes scheduler deciding to move it to another node (etc.).
If the server to be shut down is the primary server, the hook will initiate a cluster switch to one of the other available servers, if there are any. Before switching, it filters the list of available replicas to find those suitable to switch to.
The behaviour of the hook can be manipulated using the following optional annotations on the server's Pods:
prestop.server.sophora.cloud/switch-enabled: "<true|false>"prestop.server.sophora.cloud/is-switch-target: "<true|false>"
The first annotation controls whether the server shutting down should switch. In some edge-cases, it might be useful to shut down a server without switching.
The second annotation can be used to specify whether the annotated server should be a valid switch target server.
If set to false, the tool will not switch to that server.
Both annotations default to true, if not specified or the value is not parseable to a boolean value, because generally
switches should happen and should only be deactivated for maintenance, recovery or similar scenarios.
For this to work, the server's pod requires a service account with the permission to get and list Pods and services
in the namespace the server runs in. The SA, Role and Role Binding are created automatically.
The creation of these resources can be controlled with the serviceAccount: section in the values file.
Server mode pod labels
Cluster servers run a sidecar container which continuously labels the pods with their server mode to make it possible to create a service which always points to the current primary server.
For the sidecar to work, the server requires a service account with the permission to get and patch Pods
in the namespace the server runs in. The SA, Role and Role Binding are created automatically by this chart.
The creation of these resources can be controlled with the serviceAccount: section in the values file.
Ingress with Ingress NGINX Controller
When using ingress-nginx you can set the following annotations. The proxy-*-timeout allows long running server requests like complex queries to run. The default timeout of nginx is 60 seconds which may not work for all cases and repository sizes. The client-body-buffer-size allows larger responses to be handled in memory.
ingress:
ingressClassName: "nginx"
enabled: true
annotations:
nginx.ingress.kubernetes.io/client-body-buffer-size: 2m
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
Postgres native sidecar (k8s 1.29+)
All Sophora cluster server since version 5 and all Sophora staging server since version 6 require a postgres database
However, while the Sophora staging server supports replica scaling, each instance still requires a dedicated PostgreSQL database. The simplest way to meet these requirements is by introducing native sidecar containers. With this setup, each Sophora server now includes its own PostgreSQL instance. Read more about native sidecar containers here.
Add a native sidecar container using the following configuration:
extraInitContainers:
- name: "postgres"
image: "postgres:17.5-alpine3.21"
imagePullPolicy: "IfNotPresent"
restartPolicy: Always
ports:
- name: http
containerPort: 5432
protocol: TCP
env:
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PASSWORD
value: postgres
- name: POSTGRES_DB
value: sophora
volumeMounts:
- name: sophora-server-storage
mountPath: /var/lib/postgresql/data
subPath: postgres
resources:
requests:
memory: 3G
limits:
memory: 3G
You may want to adjust configurations like resources or the postgres version.
The volume mount sophora-server-storage is provided by default. You can safely use postgres as the subPath.
If you want to use your own volume, configure one in extraVolumeClaimTemplates.
To complete the setup, add the following properties to sophora.server.properties to configure the postgres connection to the sidecar container.
# connection to postgres native sidecar container
sophora.persistence.postgres.database=sophora
sophora.persistence.postgres.username=postgres
sophora.persistence.postgres.password=postgres
sophora.persistence.postgres.hostname=localhost
sophora.persistence.postgres.port=5432
Note: For cluster servers we still recommend a separate postgres deployment, like Google Cloud SQL.
Notable Changes
3.8.6
Removes an invalid document separator when using gcp.backendPolicy.enabled:true
3.3.0
Added sophora.server.storage.useSeparateVolumes (default: true) to control the number of volumes. When enabled, /sophora/data uses a separate PVC.
When disabled, /sophora/data is stored on the same persistent volume as the repository content.
To transition to a single volume you have to copy the data over before removing the data PVC.
3.2.0
- Added HTTPRoute support for Gateway API. This adds the properties
httpRoute,grpcHttprouteandgrpcRouteto the values. These are similar to theingressandgrpcIngressoptions.
3.0.0
- Added the option do disable JCR support. Set
sophora.server.persistence.repositoryTypetonone, if you use Sophora 6.1.0 or later and completed the postgres migration. - Added
sophora.server.storage.accessModesandsophora.server.storage.dataDirAccessModes. Defaults toReadWriteOncefor both. - Removed support for Sophora ACS.
- Removed support for File System Binary Store. In case you still need it, add the following volume mount:
extraVolumeMounts:
- name: sophora-server-storage
mountPath: /sophora/repository/binaries
subPath: repository.binaries
- name: sophora-server-storage
mountPath: /sophora/repository/binarystore
subPath: repository.binarystore
- Removed support for the internal Solr (Sophora 4). In case you still need it, add the following volume mount:
extraVolumeMounts:
- name: sophora-server-storage
mountPath: /sophora/solr
subPath: solr
2.11.1
This version modifies how the checksum/* annotations in the StatefulSet's pod template are computed. Previously, the sha256sum was based on the whole rendered ConfigMap, leading to changes in a hash whenever merely a ConfigMap label changed (like the .Chart.AppVersion or any user-provided additionalSelectorLabels). This did not affect the volume-mounted content seen by the pod, but still resulted in an update of the pod template and termination and restart of the StatefulSet's pods.
This change only includes the .data portion of the ConfigMaps into the hash computation, such that changes to .metadata (like labels) don't af
Deploy sophora-server with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has sophora-server on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartsophora-server is pinned at v3.10.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply