AspNetCore.IgniteServer: A .NET Core, Kubernetes ready, authentication, and SSL enabled Apache Ignite server implementation
AspNetCore.IgniteServer 2.19.0 (extracted from Tarzan and improved)
AspNetCore.IgniteServer is an implementation of Apache Ignite 2 embedded mode that references necessary assemblies to provide a server-side component for the ASP.NET Core platform. Kubernetes ready, authentication and SSL enabled with auto-discovery clustering capabilities. Usually, every node runs one or more instances of the server.
The repository also contains AspNetCore.Ignite, a thin client library for ASP.NET Core applications (see Client library below).
What's new
Version 2.19.0 targets .NET 10. It is the first published image that starts (the JVM options of the 2.17.0 and 2.18.0 images included -server, which the embedded JVM rejects). The highlights:
- Settings from environment variables, validated at startup: every error is listed, and the server exits with code 1.
- Health and metrics on port 9464: /health/startup, /health/readiness, /health/liveness and Prometheus /metrics, optionally pushed to an OpenTelemetry collector.
- Readiness that waits until a restarted node holds its data again, so a rolling restart does not move on too early.
- Automatic cluster activation, password rotation, certificate rotation without downtime, and lost partitions that are reset automatically.
- A graceful stop, with meaningful exit codes.
- Secure defaults: no default passwords or sample keystores, REST and peer assembly loading off, and no secrets in node attributes.
- A lean multi-platform image (linux/amd64, linux/arm64) with a minimal Java 17 runtime and Ignite's control utility (control.sh).
Quick start
docker run -d --name aspnetcore.ignite-server -p 10800:10800 -p 9464:9464 \ -e IGNITE_USER_PASSWORD='<password>' ghcr.io/dradoaica/aspnetcore.ignite-server:2.19.0 curl http://localhost:9464/health/readiness
Thin clients connect to port 10800 (user ignite), and /metrics on port 9464 serves Prometheus metrics.
Usage
The server can be executed with various options:
dotnet AspNetCore.IgniteServer.dll [options] Options: -?, -h, --help, -Help Show help and usage information -ConfigFile <ConfigFile> XML configuration file. If no file is specified then the default configuration is used. -OffHeap <OffHeap> Size of off-heap memory given in megabytes. -OnHeap <OnHeap> Size of on-heap memory given in megabytes. -SpiPort <SpiPort> Specifies port for Discovery Spi. -Cluster <Cluster> Specifies IP address and port of a cluster node. Multiple nodes can be specified. -ConsistentId <ConsistentId> Specifies as a consistent id of the node. This value is used in topology. -PersistenceEnabled If set, it enables persistence mode.
Option names are case-sensitive. Every option also has a setting of the same meaning, which can be given as an environment variable (e.g., DEFAULT_OFF_HEAP_MEMORY, CLUSTER_ENDPOINTS). Settings have defaults, overridden by appsettings.json, then by environment variables, then by the command line options.
The default configuration uses the default parameters of the Ignite environment. A configuration file (-ConfigFile, Ignite.NET XML) is applied over it: the properties it sets override the defaults, and the others stay. There are two predefined configuration files available in the config folder:
- default-config.xml - this is minimal configuration for running memory only Ignite server.
- persistent-config.xml - this is minimal configuration for running persistent Ignite server.
Examples
Runs the server locally with the specified amount of memory. It uses 1G of on-heap memory (for computation and queries) and 2G of off-heap memory (data and indexes). It uses default settings, e.g., the Spi port will be the first available port starting from 47500.
dotnet AspNetCore.IgniteServer.dll -OnHeap 1024 -OffHeap 2048 -Cluster "127.0.0.1:47500"
Persistent Mode
If the server is run in persistent mode, the situation is slightly more complicated and depends on whether the cluster is run for the first time or it is resumed. It is because, for running a cluster with persistence enabled, Ignite needs to form a topology before the cluster is activated. If the cluster is created for the first time, the cluster has to be activated when it reaches the required topology. The cluster records the topology information, which is used when the cluster is resumed.
The server now does this automatically: an inactive persistent cluster is activated once ACTIVATION_MIN_SERVER_NODES server nodes have joined (set it to the cluster size), while a resumed cluster that is already active is left as is. Afterward, baseline auto-adjust keeps the baseline in sync with the topology, 5 minutes after it changed by default (BASELINE_AUTO_ADJUST_TIMEOUT_IN_SECONDS): a node that restarts within that time keeps its place in the baseline and its data. In containers, mount a volume at /app/work and give every node a unique, stable DEFAULT_CONSISTENT_ID.
Configuring Memory
memory calculation: ON_HEAP_MEMORY (JVM Heap max size)
+ 256MB (JVM Metaspace max size)
+ 240MB (JVM ReservedCodeCache size)
+ OFF_HEAP_MEMORY (default region max size; data + indexes (basic use cases will add a 30% increase on top of data))
+ MIN(256MB, OFF_HEAP_MEMORY) (OFF_HEAP_MEMORY < 1 GB)
|| OFF_HEAP_MEMORY/4 (OFF_HEAP_MEMORY between 1 GB and 8 GB)
|| 2GB (OFF_HEAP_MEMORY > 8 GB)
(default region checkpointing buffer size)
+ 100MB (sysMemPlc region max size)
+ 100MB (metastoreMemPlc region max size)
+ 100MB (TxLog region max size)
+ 100MB (volatileDsMemPlc region max size)
+ ~512MB (other overheads; e.g., thread stacks, GC, symbols, etc.)
The JVM starts with its whole heap allocated (as in the Apache Ignite Helm chart) and exits on an out-of-memory error, so the container restarts instead of running half-dead.
Authentication and SSL
With authentication enabled (the default), every start makes IGNITE_USER_PASSWORD the password of the ignite user. To rotate it, set the new password in IGNITE_USER_PASSWORD and the old one in IGNITE_USER_PREVIOUS_PASSWORD: the first node that starts with it changes the password for the whole cluster.
With SSL enabled (USE_SSL between nodes, USE_CLIENT_SSL for thin clients), the key store, trust store and client certificate files are watched, so renewed certificates (e.g., by cert-manager) are picked up without manual restarts. Once the files have settled, plus a random delay so that nodes do not restart together, the node restarts gracefully with the renewed files. The cluster's last server node deactivates the cluster first, so it restarts at once, and activates it again.
Kubernetes
The Helm chart runs the server as a StatefulSet. Its nodes find each other through the Kubernetes API (USE_TCP_DISCOVERY_STATIC_IP_FINDER=false, K8S_NAMESPACE and K8S_SERVICE_NAME), and Kubernetes probes the three health endpoints:
- /health/startup: the node has joined the topology, also while its cluster waits for the other nodes, so that a startup probe does not restart nodes that wait for each other.
- /health/readiness: the cluster is active and the node has caught up after its start (it holds its data again).
- /health/liveness: the process is alive.
On SIGTERM, the node stops gracefully: Ignite's GRACEFUL shutdown policy waits until its partitions have copies on other nodes, within GRACEFUL_STOP_TIMEOUT_IN_SECONDS. The exit code tells how it went:
- 0: stopped gracefully.
- 1: invalid arguments or settings, a failed start, or a node that stopped unexpectedly.
- 2: stopped, but not gracefully (the node stopped with the process; a persistent one recovers from its write-ahead log on the next start).
Client library
AspNetCore.Ignite registers a thin client in ASP.NET Core's dependency injection. It connects on first use (with retries) rather than at startup, retries transient failures only, and comes with a health check:
services.AddIgnite(); // the ASPNETCORE_IGNITE_* settings
services.AddIgnite(configuration.GetSection("Ignite")); // or a section bound to IgniteClientOptions
services.AddIgnite(options => options.Cache.Backups = 2); // and/or code
services.AddHealthChecks().AddIgnite(); // healthy when the cluster is reachable and active
Documentation
The repository documents everything above in detail:
- Configuration: all settings, authentication, SSL and certificate rotation, health and metrics, the control utility and snapshots, logging, persistence and memory.
- Kubernetes: deployment guidance and alerts.
- Architecture: the components, the node lifecycle and certificate rotation, with diagrams.
- Client library and Upgrading to 2.19.0.
The source code can be found on GitHub at: https://github.com/dradoaica/AspNetCore.Ignite
The Helm chart: https://github.com/dradoaica/helm-charts/tree/main/charts/aspnetcore-ignite-server
Enjoy (ง'̀-'́)ง
Comments
Post a Comment