nostr-strfry

by kriegalex

Helm chartv1.3.0App 1.1.0Verified publisher

A Helm chart for deploying a Nostr strfry relay

About this chart

nostr-strfry

A Helm chart for deploying a Nostr strfry relay

Introduction

This Helm chart deploys a strfry Nostr relay on a Kubernetes cluster. Strfry is a high-performance, resource-efficient Nostr relay implementation written in C++, designed to handle high traffic loads while maintaining efficient resource usage.

Prerequisites

  • Kubernetes 1.29+
  • Helm 3.16+
  • PV provisioner support in the underlying infrastructure (if persistence is enabled)

Installing the Chart

To install the chart with the release name nostr-strfry:

helm repo add k8s-charts https://kriegalex.github.io/k8s-charts/
helm repo update
helm install nostr-strfry k8s-charts/nostr-strfry

Uninstalling the Chart

To uninstall/delete the nostr-strfry deployment:

helm delete nostr-strfry

Configuration

The following table lists the configurable parameters for the nostr-strfry chart and their default values.

KeyTypeDefaultDescription
config.dbstring"/app/strfry-db"Directory that contains the strfry LMDB database
config.dbParams.mapsizestring"10995116277760"Size of mmap() to use when loading LMDB (default is 10TB)
config.dbParams.maxreadersint256Maximum number of threads/processes that can simultaneously have LMDB transactions open
config.dbParams.noReadAheadboolfalseDisables read-ahead when accessing the LMDB mapping
config.events.ephemeralEventsLifetimeSecondsint300Ephemeral events will be deleted from the DB when older than this (in seconds)
config.events.maxEventSizestring"65536"Maximum size of normalised JSON, in bytes
config.events.maxNumTagsint2000Maximum number of tags allowed
config.events.maxTagValSizeint1024Maximum size for tag values, in bytes
config.events.rejectEphemeralEventsOlderThanSecondsint60Ephemeral events older than this (in seconds) will be rejected
config.events.rejectEventsNewerThanSecondsint900Events newer than this (in seconds) will be rejected
config.events.rejectEventsOlderThanSecondsstring"94608000"Events older than this (in seconds) will be rejected
config.existingSecretstring""Name of an existing Secret providing the COMPLETE strfry.conf instead of the chart-rendered one. The Secret must contain a strfry.conf key. When set, the chart renders no config ConfigMap and every other config.* value below is ignored — lets you keep PII (e.g. the NIP-11 self/pubkey npubs) out of Helm values. Tip: generate a starting point with helm template ... -s templates/configmap.yaml. nip05.* is unaffected.
config.relay.auth.enabledboolfalseEnable NIP-42 authentication. When true, serviceUrl must be set.
config.relay.auth.serviceUrlstring""External relay URL required for NIP-42 validation (e.g. wss://relay.example.com)
config.relay.autoPingSecondsint55Websocket-level PING message frequency (seconds)
config.relay.bindstring"0.0.0.0"Interface to listen on (Use 0.0.0.0 for k3s)
config.relay.compression.enabledbooltrueEnable permessage-deflate compression if supported by client
config.relay.compression.slidingWindowbooltrueMaintain a sliding window buffer for each connection
config.relay.enableTcpKeepaliveboolfalseEnable TCP keep-alive to detect dropped connections
config.relay.filterValidation.allowedKindsstring""Comma-separated list of allowed kinds (empty = all)
config.relay.filterValidation.enabledboolfalseEnable REQ filter validation
config.relay.filterValidation.maxFiltersPerReqint3Maximum number of filters allowed per REQ
config.relay.filterValidation.maxKindsPerFilterint3Maximum number of kinds allowed per filter
config.relay.filterValidation.minFiltersPerReqint1Minimum number of filters required per REQ
config.relay.filterValidation.requireAuthorOrTagboolfalseRequire filters to contain an author or tag constraint
config.relay.info.bannerstring""NIP-11: Banner image URL
config.relay.info.contactstring""NIP-11: Alternative administrative contact
config.relay.info.descriptionstring"This is a strfry instance."NIP-11: Detailed information about relay
config.relay.info.iconstring""NIP-11: URL pointing to an image to be used as an icon for the relay
config.relay.info.namestring"strfry default"NIP-11: Name of this server (< 30 characters)
config.relay.info.nipsstring""List of supported NIPs as JSON array, or empty string to use default
config.relay.info.privacystring""NIP-11: Privacy policy URL
config.relay.info.pubkeystring""NIP-11: Administrative nostr pubkey, for contact purposes
config.relay.info.selfstring""NIP-11: Relay's own pubkey (npub or hex format)
config.relay.info.termsstring""NIP-11: Terms of service URL
config.relay.logging.dbScanPerfboolfalseLog performance metrics for initial REQ database scans
config.relay.logging.dumpInAllboolfalseDump all incoming messages
config.relay.logging.dumpInEventsboolfalseDump all incoming EVENT messages
config.relay.logging.dumpInReqsboolfalseDump all incoming REQ/CLOSE messages
config.relay.logging.invalidEventsbooltrueLog reason for invalid event rejection
config.relay.maxFilterLimitint500Maximum records that can be returned per filter
config.relay.maxFilterLimitCountstring"1000000"Maximum records that can be returned per filter for NIP-45 COUNT (0 = disable)
config.relay.maxReqFilterSizeint200Maximum number of filters allowed in a REQ
config.relay.maxSubsPerConnectionint200Maximum number of subscriptions a connection can have open
config.relay.maxWebsocketPayloadSizestring"131072"Maximum accepted incoming websocket frame size (bytes)
config.relay.negentropy.enabledbooltrueSupport negentropy protocol messages
config.relay.negentropy.maxSyncEventsstring"1000000"Maximum records that sync will process before returning an error
config.relay.nofilesstring"1000000"OS-limit on maximum number of open files/sockets (if 0, don't attempt to set)
config.relay.numThreads.ingesterint3Ingester threads: route incoming requests, validate events/sigs
config.relay.numThreads.negentropyint2negentropy threads: Handle negentropy protocol messages
config.relay.numThreads.reqMonitorint3reqMonitor threads: Handle filtering of new events
config.relay.numThreads.reqWorkerint3reqWorker threads: Handle initial DB scan for events
config.relay.portint7777Port to open for the nostr websocket protocol
config.relay.queryTimesliceBudgetMicrosecondsstring"10000"Uninterrupted CPU time for a REQ query during DB scan (microseconds)
config.relay.realIpHeaderstring""HTTP header that contains the client's real IP, before reverse proxying (must be all lower-case)
config.relay.writePolicy.pluginstring""Path to an executable script that implements the writePolicy plugin logic
config.relay.writePolicy.timeoutSecondsint10Timeout in seconds for the writePolicy plugin response
fullnameOverridestring""String to fully override nostr-relay.fullname template
image.pullPolicystring"IfNotPresent"Nostr relay Docker image pull policy
image.repositorystring"dockurr/strfry"Nostr strfry Docker image repository
image.tagstring""Overrides the image tag. Default is the chart appVersion
imagePullSecretslist[]Specify imagePullSecrets if your Docker repository requires authentication
ingress.annotationsobject{}Additional ingress annotations
ingress.classNamestring""Ingress class name
ingress.enabledboolfalseEnable ingress resource
ingress.hostslist[{ host: nostr.k3s.home }]List of ingress hosts
ingress.tlslist[]Ingress TLS configuration
nameOverridestring""String to partially override nostr-relay.fullname template
nip05.enabledboolfalseEnable NIP-05 verification service
nip05.identitiesstringnilNIP-05 identities mapping usernames to public keys
nip05.image.pullPolicystring"IfNotPresent"NIP-05 server Docker image pull policy
nip05.image.repositorystring"nginx"NIP-05 server Docker image repository
nip05.image.tagstring"alpine"Overrides the image tag
nip05.relaysstringnilNIP-05 identities mapping user public keys to relays
persistence.accessModestring"ReadWriteOnce"Access mode for the persistent volume
persistence.enabledbooltrueEnable persistent storage for the database
persistence.sizestring"10Gi"Size of the persistent volume
persistence.storageClassstring""StorageClass name. If empty, uses the default provisioner.
podAnnotationsobject{}Annotations to be added to the pod
podSecurityContext.fsGroupint1000
replicaCountint1Number of nostr-relay replicas
resourcesobject{}Resource limits and requests for the relay
securityContext.runAsGroupint1000Group ID to run the container
securityContext.runAsNonRootbooltrueRun container as non-root user
securityContext.runAsUserint1000User ID to run the container
service.portint7777Kubernetes Service port
service.typestring"ClusterIP"Kubernetes Service type
serviceAccount.createboolfalseSpecifies whether a service account should be created
serviceAccount.namestring""The name of the service account to use. If not set and create is true, a name is generated using the fullname template.
terminationGracePeriodSecondsint120Grace period for pod termination in seconds (corresponds to stop_grace_period)

Persistence

This chart mounts a Persistent Volume for the strfry database. The volume is created using dynamic volume provisioning. If you want to disable this (and instead use an emptyDir volume), set persistence.enabled to false.

For production use, it's recommended to:

  • Use a reliable storage class
  • Set an appropriate volume size (default is 10Gi)
  • Consider backup strategies for your database

Ingress and Reverse Proxy

This chart includes support for Ingress resources. If you have an Ingress controller installed on your cluster, such as nginx-ingress or traefik, you can utilize the ingress controller to serve your Nostr relay.

For proper WebSocket support in an ingress configuration, you may need to add specific annotations. For example, with NGINX:

ingress:
  enabled: true
  annotations:
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-body-size: "64m"
  hosts:
    - host: relay.example.com
      paths:
        - path: /
          pathType: Prefix
  tls:
    - secretName: relay-tls
      hosts:
        - relay.example.com

NIP Support

Strfry supports multiple NIPs (Nostr Implementation Possibilities). You can specify the supported NIPs in your values file:

config:
  relay:
    info:
      nips: "[1, 2, 4, 9, 11, 22, 28, 40, 70, 77]"

NIP-05 Support

This chart includes built-in support for NIP-05 (.well-known/nostr.json) verification. To enable it:

nip05:
  enabled: true
  identities:
    username1: "hex_public_key1"
    username2: "hex_public_key2"

When enabled, the chart deploys a small nginx container to serve the necessary static files, and updates the ingress to route .well-known paths to this service. Users can then verify themselves using NIP-05 identifiers like [email protected].

Configuring NIP-05 Identities

Add usernames and their corresponding public keys to the nip05.identities map in your values file:

nip05:
  enabled: true
  identities:
    alice: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
    bob: "fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210"

Using with Kubernetes

Once your relay is deployed, you can access it using the service endpoint. The default configuration creates a ClusterIP service, which means it's only accessible within the cluster.

Accessing the Relay

  1. For internal cluster access:

    ws://RELEASE-NAME-nostr-strfry.NAMESPACE.svc.cluster.local:7777
    
  2. To access from your local machine:

    kubectl port-forward --namespace NAMESPACE svc/RELEASE-NAME-nostr-strfry 7777:7777
    

    Then connect to ws://localhost:7777

  3. If you enabled Ingress, use the domain you specified.

Checking Logs

To view the logs of your relay:

kubectl logs -f deployment/RELEASE-NAME-nostr-strfry -n NAMESPACE

Notes on Production Use

For production deployments, consider:

  1. Using a specific image tag rather than latest
  2. Setting appropriate resource limits and requests
  3. Enabling TLS via Ingress or another method
  4. Setting up proper monitoring and backup strategies for the database
  5. Configuring appropriate pa

Deploy nostr-strfry with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has nostr-strfry 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartnostr-strfry is pinned at v1.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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