# Continuwuity for Kubernetes

Continuwuity doesn't support horizontal scalability or distributed loading
natively. However, a deployment in Kubernetes is very similar to the docker
setup. This is because Continuwuity can be fully configured using environment
variables. A sample StatefulSet is shared below. The only thing missing is
a PVC definition (named `continuwuity-data`) for the volume mounted to
the StatefulSet, an Ingress resources to point your webserver to the
Continuwuity Pods, and a Service resource (targeting `app.kubernetes.io/name: continuwuity`)
to glue the Ingress and Pod together.

Carefully go through the `env` section and add, change, and remove any env vars you like using the [Configuration reference](https://continuwuity.org/reference/config.html)

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: continuwuity
  namespace: matrix
  labels:
    app.kubernetes.io/name: continuwuity
spec:
  replicas: 1
  serviceName: continuwuity
  podManagementPolicy: Parallel
  selector:
    matchLabels:
      app.kubernetes.io/name: continuwuity
  template:
    metadata:
      labels:
        app.kubernetes.io/name: continuwuity
    spec:
      securityContext:
        sysctls:
          - name: net.ipv4.ip_unprivileged_port_start
            value: "0"
      containers:
        - name: continuwuity
          # use a sha hash <3
          image: forgejo.ellis.link/continuwuation/continuwuity:latest
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
          volumeMounts:
            - mountPath: /data
              name: data
              subPath: data
          securityContext:
            capabilities:
              add:
                - NET_BIND_SERVICE
          env:
            - name: TOKIO_WORKER_THREADS
              value: "2"
            - name: CONTINUWUITY_SERVER_NAME
              value: "example.com"
            - name: CONTINUWUITY_DATABASE_PATH
              value: "/data/db"
            - name: CONTINUWUITY_DATABASE_BACKEND
              value: "rocksdb"
            - name: CONTINUWUITY_PORT
              value: "80"
            - name: CONTINUWUITY_MAX_REQUEST_SIZE
              value: "20000000"
            - name: CONTINUWUITY_ALLOW_FEDERATION
              value: "true"
            - name: CONTINUWUITY_TRUSTED_SERVERS
              value: '["matrix.org"]'
            - name: CONTINUWUITY_ADDRESS
              value: "0.0.0.0"
            - name: CONTINUWUITY_ROCKSDB_PARALLELISM_THREADS
              value: "1"
            - name: CONTINUWUITY_WELL_KNOWN__SERVER
              value: "matrix.example.com:443"
            - name: CONTINUWUITY_WELL_KNOWN__CLIENT
              value: "https://matrix.example.com"
            - name: CONTINUWUITY_ALLOW_REGISTRATION
              value: "false"
            - name: RUST_LOG
              value: info
          readinessProbe:
            httpGet:
              path: /_matrix/federation/v1/version
              port: http
            periodSeconds: 4
            failureThreshold: 5
          resources:
            # Continuwuity might use quite some RAM :3
            requests:
              cpu: "2"
              memory: "512Mi"
            limits:
              cpu: "4"
              memory: "2048Mi"
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: continuwuity-data
```

---

Apart from manually configuring the containers,
[a community-maintained Helm Chart is available here to run
conduwuit on Kubernetes](https://gitlab.cronce.io/charts/conduwuit)

This should be compatible with Continuwuity, but you will need to change the image reference.

If changes need to be made, please reach out to the maintainer, as this is not maintained or controlled by the Continuwuity maintainers.
