Server Installation
Kahuna Server is one self-hosted process that provides the three building blocks: the key/value store, distributed locks, the sequencer. You can run it in three supported ways without requiring the source repository.
- Homebrew:
brew install kahunakv/tap/kahuna, including the server and CLI - Docker image:
kahunakv/kahuna:latest - .NET global tool:
Kahuna.Server, which installs thekahuna-servercommand
Each option fits a different case.
- Homebrew installs native binaries on macOS or Linux, with the .NET runtime included. Choose it for a local server or a machine managed with Homebrew.
- Docker is the fastest way to try Kahuna and the usual choice for container-based deployments. It does not need .NET on the host.
- The .NET global tool executes the server directly on a machine with the .NET SDK, and containers aren't needed. Choose it if you already use .NET tooling, or if you deploy to virtual machines that don't have Docker.
- On Kubernetes, use the Kubernetes Operator, which also manages cluster membership when you scale.
Homebrew
Install the server and CLI from the Kahuna tap.
brew install kahunakv/tap/kahuna
kahuna-server
The package supports Apple Silicon and Intel Macs, and ARM64 and x64 Linux. Connect from another terminal with kahuna-cli; its default endpoint is http://127.0.0.1:8083. A server started by hand stores files under ~/.local/share/kahuna by default, or under KAHUNA_HOME when set.
These commands start a background standalone node.
brew services start kahuna
brew services stop kahuna
The service sets KAHUNA_HOME to $(brew --prefix)/var/kahuna, placing backend data in data/ and WAL files in wal/. Its log is $(brew --prefix)/var/log/kahuna.log. It uses default standalone settings. When you deploy a cluster, configure explicit node identity and peers, and also listeners and security. Stop a manually started server before starting the service if they would bind the same ports.
Update the installed binaries with brew update followed by brew upgrade kahuna. Plan service restarts and cluster upgrades as you would for any server binary replacement.
Docker
For the quickest container-based setup, run the published Kahuna image. This command opens the client ports and uses a named Docker volume for persistent data.
docker run --rm -p 8081:8081 -p 8082:8082 -p 8083:8083 -v kahuna-data:/data --name kahuna kahunakv/kahuna:latest
Use http://127.0.0.1:8081 for REST, https://127.0.0.1:8082 for HTTPS REST/gRPC, or http://127.0.0.1:8083 for cleartext gRPC from local clients. When you connect with kahuna-cli to the local HTTPS endpoint, allow the development certificate.
kahuna-cli -c "https://127.0.0.1:8082" --insecure
For local cleartext gRPC, use this command.
kahuna-cli -c "http://127.0.0.1:8083"
Stop the container with Ctrl+C. Because the command uses --rm, the container is removed after it exits, but the kahuna-data Docker volume remains available for the next run.
The published image starts one standalone node with settings for local development.
- Synchronous WAL writes are off (
--disable-wal-sync-writes). This means that writes acknowledged shortly before a machine crash or power loss may not be on disk. - HTTPS uses a development certificate bundled in the image.
- Inter-node certificate validation is skipped (
--raft-allow-insecure-certificate-validation). - The cleartext HTTP and gRPC listeners stay open beside HTTPS (
--allow-plaintext-listener).
The entrypoint does not take extra flags. For production, run kahuna-server with your own settings, or override the image entrypoint (--entrypoint dotnet, then /app/Kahuna.Server.dll and your flags). See Server Configuration and Node Transport Security.
The entrypoint reads these environment variables.
| Variable | Default | Sets |
|---|---|---|
KAHUNA_HTTP_PORT | 8081 | REST over HTTP (--http-ports). |
KAHUNA_HTTPS_PORT | 8082 | HTTPS REST and gRPC (--https-ports), also used as the Raft port (--raft-port). |
KAHUNA_GRPC_CLEARTEXT_PORT | 8083 | Cleartext gRPC over HTTP/2 (--grpc-cleartext-ports). An empty value omits the flag; a standalone node then binds its default 8083. |
KAHUNA_DATA_DIR | /data | Root of the data and wal directories (--storage-path, --wal-path). |
KAHUNA_PARTITIONS | 3 | Number of partitions (--initial-cluster-partitions). |
For example, this command starts the node with eight partitions.
docker run --rm -p 8081:8081 -p 8082:8082 -p 8083:8083 -v kahuna-data:/data \
-e KAHUNA_PARTITIONS=8 --name kahuna kahunakv/kahuna:latest
If you change a port variable, change the matching -p mapping too.
.NET Aspire
Aspire is an easy way to run a local Kahuna cluster alongside your application. The Kahuna Aspire integration creates the node containers and connects them as peers. It also supplies client endpoints to your services and waits for readiness. You can try replication and node failures, and you don't need to write container commands or seed lists by hand.
| Project / package | Add it to | Purpose |
|---|---|---|
Kahuna.Aspire.Hosting | Aspire AppHost | Standalone or cluster resources and readiness checks, with per-node storage options and OTLP configuration |
Kahuna.Aspire.Client | Each consuming service | Singleton client and connection-string binding, with a membership health check and client trace and metric registration |
Install the Packages
The integration targets .NET 10 and uses Aspire 13.6.4. Install Kahuna.Aspire.Hosting in the AppHost and Kahuna.Aspire.Client in each consuming service.
dotnet add MyApp.AppHost/MyApp.AppHost.csproj package Kahuna.Aspire.Hosting
dotnet add MyApp.ApiService/MyApp.ApiService.csproj package Kahuna.Aspire.Client
Replace the project paths with your own. The client integration brings in Kahuna.Client; published packages do not require a Kahuna source checkout.
The currently published 1.15.0 packages provide standalone hosting. AddKahunaCluster and the updated client health check described below are in the latest source and require a build containing those changes. Until a newer package is published, replace the package references with project references to the integration checkout.
<ProjectReference Include="../../kahuna-aspire/src/Kahuna.Aspire.Hosting/Kahuna.Aspire.Hosting.csproj"
IsAspireProjectResource="false" />
<ProjectReference Include="../../kahuna-aspire/src/Kahuna.Aspire.Client/Kahuna.Aspire.Client.csproj" />
Adjust paths for your solution layout. The integration uses the adjacent kahuna checkout when present; -p:UseLocalKahuna=false selects released Kahuna dependencies instead.
Start a Three-Node Cluster
In your AppHost, register the cluster and reference it from the API project.
var builder = DistributedApplication.CreateBuilder(args);
var kahuna = builder.AddKahunaCluster("kahuna", nodes: 3)
.WithDataVolume();
builder.AddProject<Projects.MyApp_ApiService>("api")
.WithReference(kahuna)
.WaitFor(kahuna);
builder.Build().Run();
Replace Projects.MyApp_ApiService with your AppHost's generated project type. The dashboard groups kahuna-1 to kahuna-3 under kahuna. The parent doesn't have a container. Each node has a separate ID and storage, with an HTTP dashboard and readiness endpoint and a gRPC endpoint. Container port 8081 is for HTTP, and 8083 is for cleartext gRPC. Port 8082 is for HTTPS peer traffic. Client-facing host ports are assigned dynamically.
WithReference(kahuna) supplies a comma-separated list of the gRPC URLs of all nodes as ConnectionStrings:kahuna. The consuming service calls builder.AddKahunaClient("kahuna") as usual; see Aspire client setup. The same service code works against a standalone resource or a cluster.
Use an odd node count for quorum-based replication: three replicas can continue with one unavailable, and five with two, once leadership and quorum are established. Adding more API replicas does not add Kahuna nodes. The cluster node count is an AppHost declaration. It isn't load-based autoscaling or a decommissioning workflow.
| Cluster option | Behavior |
|---|---|
AddKahunaCluster("kahuna", nodes: 3) | Create the cluster and its node containers; 3 is the default, and the count must be positive. |
.WithDataVolume("kahuna-data") | Mount a separate volume for each node at /data, named with a node suffix, such as kahuna-data-1. Omit the prefix to generate names. No persistent mount is added unless requested. |
.WithDataBindMount("/absolute/path/to/data") | Give each node a separate subdirectory, such as kahuna-1, under the host directory. |
.WithPartitions(8) | Set the initial partition count on all nodes. The default is 3. Existing storage doesn't change its partition map. |
.ConfigureNodes(node => node.WithImageTag("local")) | Apply configuration to all nodes. Keep image and relevant cluster settings consistent across nodes. |
For a single standalone node, use builder.AddKahuna("kahuna").WithDataVolume() instead. Its optional grpcPort and httpPort parameters set fixed host ports. Its data bind mount targets one host directory. It doesn't create a subdirectory for each node.
Startup, Health, and Node Failures
Each node is probed through GET /v1/cluster/health. Before the first healthy start, the cluster requires all nodes to be running and healthy. This means that WaitFor(kahuna) starts dependent services only after the complete cluster is ready. After that, the cluster is healthy while a majority of nodes is healthy, with a description such as 2 of 3 nodes are healthy. Losing the majority makes it unhealthy. If all node containers stop, the all-nodes requirement applies on the next start. The aggregate check counts node readiness. It isn't a read/write probe, and it doesn't prove that all requests will succeed.
The cluster disables routing hints because peer addresses on the container network are not generally reachable by host applications. Clients use the supplied endpoint list, and a contacted node forwards operations to the owner. A stopped node's Aspire proxy can accept a connection and not answer: an individual call may time out even while a quorum remains available. Bound calls and implement retry handling appropriate to the operation; cluster health does not automatically retry application writes.
The client health check is deliberately weaker: it succeeds if any endpoint returns initialized membership, even when too few replicas remain for reads or writes.
Development Profile and Telemetry
The cluster profile is for local development. Nodes use the image's public development certificate and skip peer certificate validation. They don't have node authentication, and they expose cleartext client endpoints. Its generated command leaves synchronous WAL writes enabled. The standalone image entrypoint disables them. For production deployment, use explicit server/TLS configuration or the Kubernetes operator.
The current source pins kahunakv/kahuna:1.15.6 and configures OTLP export on each node. Server metrics and logs can appear alongside client telemetry in the Aspire dashboard, and so can request spans; keep your application's service-defaults/OTLP exporter configured. The published integration 1.15.0 pins server image 1.15.0, which predates server OTLP export; an image built from Kahuna 1.15.1 or later is needed for those server signals.
To use a locally built server image, run this command in the Kahuna checkout.
docker build -f docker/Dockerfile.standalone -t kahunakv/kahuna:local .
Then use .ConfigureNodes(node => node.WithImageTag("local")) on a cluster, or .WithImageTag("local") on a standalone resource. See server telemetry.
Try the Cluster Example
The cluster example runs three nodes with separate data volumes and a Notes application. From the integration checkout, with Docker and .NET 10 available, run this command.
dotnet run --project examples/ClusterExample/ClusterExample.AppHost --launch-profile http
Open the API's Notes URL from the Aspire dashboard. Add a note, then stop kahuna-3. Add another note while two replicas remain. Restart the node to observe catch-up. Stop two nodes to observe quorum loss. The page's per-node counts are reads routed through each node. They aren't inspections of the local replica on each node. The example uses bounded retries and the same note key across retries to avoid duplicate notes.
The standalone sample has one Kahuna node and two API replicas. It demonstrates key/value operations and job locking, and also sequences and a shared rate-limit budget.
.NET Global Tool
The tool targets .NET 10 (net10.0). Install the .NET 10 SDK first. Then install the server tool from NuGet.
dotnet tool install --global Kahuna.Server
This command updates an existing installation.
dotnet tool update --global Kahuna.Server
This command starts a standalone server.
kahuna-server \
--http-ports 8081 \
--grpc-cleartext-ports 8083 \
--storage rocksdb \
--wal-storage rocksdb \
--storage-path ~/.kahuna/data \
--wal-path ~/.kahuna/wal \
--storage-revision v1 \
--wal-revision v1
The server listens on http://127.0.0.1:8081 for REST and http://127.0.0.1:8083 for cleartext gRPC. Connect local gRPC clients with this command.
kahuna-cli -c "http://127.0.0.1:8083"
Press Ctrl+C in the terminal to stop the server.
A standalone server honors --raft-wal-single-fsync-commit (default true), --read-io-threads, --write-io-threads (default 16), --raft-max-wal-group-batch-partitions, and --raft-wal-group-commit-linger-ms. Single-fsync commits acknowledge after durable proposal agreement and persist commit markers lazily; process-loss durability also requires persistent WAL storage with synchronous writes. Its snapshot staging uses the embedded defaults.
Process Exit Codes
Use the exit status to distinguish a normal stop from a failed deployment.
| Code | Meaning |
|---|---|
0 | Graceful shutdown, for example after Ctrl+C or SIGTERM. A help or version request also returns 0. |
1 | Startup or server failure, for example invalid configuration or an extension loading failure. The terminal error on stderr begins with Kahuna stopped because. |
2 | Command-line parsing failure. |
Startup failures exit normally with status 1. The runtime doesn't abort to produce a crash dump. Inspect stderr and the preceding logs for the cause.
Running a Cluster
For local development, Aspire starts a cluster from one AppHost declaration, including peer discovery and per-node volumes. The manual setup below is useful when you need control over the individual server commands.
Run production or staging clusters with the same kahuna-server tool or the Docker image on each node. Each node needs a separate identity and storage paths, and a separate Raft endpoint. It also needs TLS configuration and the --initial-cluster seed list.
The most important flags for a cluster are in this list. Server Configuration documents all flags.
--raft-nodename--raft-nodeid--raft-host--raft-port--initial-cluster--join-existing--storage-path--wal-path--grpc-cleartext-ports--https-certificate
For local single-node development, prefer the standalone Docker or NuGet examples above.
Local Three-Node Cluster
To try replication on one machine, start three nodes in three terminals. Each node has a separate name and ID, and a separate Raft port and data directories. Each node lists the other two nodes in --initial-cluster.
# Terminal 1
kahuna-server \
--raft-nodename kahuna1 --raft-nodeid 1 \
--raft-host 127.0.0.1 --raft-port 8281 \
--raft-grpc-scheme http:// \
--http-ports 8181 --grpc-cleartext-ports 8281 \
--initial-cluster 127.0.0.1:8282 127.0.0.1:8283 \
--storage-path ~/.kahuna/node1/data --wal-path ~/.kahuna/node1/wal
# Terminal 2
kahuna-server \
--raft-nodename kahuna2 --raft-nodeid 2 \
--raft-host 127.0.0.1 --raft-port 8282 \
--raft-grpc-scheme http:// \
--http-ports 8182 --grpc-cleartext-ports 8282 \
--initial-cluster 127.0.0.1:8281 127.0.0.1:8283 \
--storage-path ~/.kahuna/node2/data --wal-path ~/.kahuna/node2/wal
# Terminal 3
kahuna-server \
--raft-nodename kahuna3 --raft-nodeid 3 \
--raft-host 127.0.0.1 --raft-port 8283 \
--raft-grpc-scheme http:// \
--http-ports 8183 --grpc-cleartext-ports 8283 \
--initial-cluster 127.0.0.1:8281 127.0.0.1:8282 \
--storage-path ~/.kahuna/node3/data --wal-path ~/.kahuna/node3/wal
Storage defaults to RocksDB. When all three nodes report "ready":true, write through one node and read through another.
curl http://127.0.0.1:8181/v1/cluster/health
kahuna-cli -c "http://127.0.0.1:8281" --set greeting --value hello
kahuna-cli -c "http://127.0.0.1:8283" --get greeting
The Raft port is each node's cleartext gRPC port, and --raft-grpc-scheme http:// makes the nodes dial each other over cleartext gRPC, and TLS and certificates aren't used. That traffic is unencrypted: use this layout only for local testing. In production, configure --https-certificate and --https-ports, put --raft-port on an HTTPS port, and keep the default https:// scheme. See Node Transport Security.
Kubernetes
To run Kahuna on Kubernetes, use the Kahuna Kubernetes Operator.