![]() |
VOOZH | about |
dotnet add package Akka.Coordination.KubernetesApi --version 1.5.68
NuGet\Install-Package Akka.Coordination.KubernetesApi -Version 1.5.68
<PackageReference Include="Akka.Coordination.KubernetesApi" Version="1.5.68" />
<PackageVersion Include="Akka.Coordination.KubernetesApi" Version="1.5.68" />Directory.Packages.props
<PackageReference Include="Akka.Coordination.KubernetesApi" />Project file
paket add Akka.Coordination.KubernetesApi --version 1.5.68
#r "nuget: Akka.Coordination.KubernetesApi, 1.5.68"
#:package Akka.Coordination.KubernetesApi@1.5.68
#addin nuget:?package=Akka.Coordination.KubernetesApi&version=1.5.68Install as a Cake Addin
#tool nuget:?package=Akka.Coordination.KubernetesApi&version=1.5.68Install as a Cake Tool
This module is an implementation of an Akka Coordination Lease backed by a Custom Resource Definition (CRD) in Kubernetes. Resources in Kubernetes offer concurrency control and consistency that have been used to build a distributed lease/lock.
A lease can be used for:
In all cases the use of the lease increases the consistency of the feature. However, as the Kubernetes API server and its backing etcd cluster can also be subject to failure and network issues any use of this lease can reduce availability.
ActorSystem names because they all need a separate lease.This requires admin privileges to your Kubernetes / Open Shift cluster but only needs doing once.
Kubernetes:
kubectl apply -f lease.yml
Where lease.yml contains:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: leases.akka.io
spec:
group: akka.io
versions:
- name: v1
storage: true
served: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
owner:
type: string
version:
type: string
time:
type: integer
scope: Namespaced
names:
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: Lease
listKind: LeaseList
# singular name to be used as an alias on the CLI and for display
singular: lease
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: leases
Each pod needs permission to read/create and update lease resources. They only need access for the namespace they are in.
An example RBAC that can be used:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lease-access
rules:
- apiGroups: ["akka.io"]
resources: ["leases"]
verbs: ["get", "create", "update", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lease-access
subjects:
- kind: User
name: system:serviceaccount:<YOUR NAMESPACE>:default
roleRef:
kind: Role
name: lease-access
apiGroup: rbac.authorization.k8s.io
This defines a Role that is allows to get, create and update lease objects and a RoleBinding that gives the default service user this role in <YOUR NAMESPACE>.
Future versions may also require delete access for cleaning up old resources. Current uses within Akka only create a single lease so cleanup is not an issue.
To avoid giving an application the access to create new leases an empty lease can be created in the same namespace as the application with:
kubelctl create -f sbr-lease.yml -n <YOUR_NAMESPACE>
Where sbr-lease.yml contains:
apiVersion: "akka.io/v1"
kind: Lease
metadata:
name: <YOUR_ACTORSYSTEM_NAME>-akka-sbr
spec:
owner: ""
time: 0
NOTE
The lease gets created only during an actual Split Brain.
To enable Kubernetes lease inside SBR, you need to pass a LeaseMajorityOption instance into the second parameter of the WithClsutering() extension method and specify that you're using the Kubernetes lease implementation.
using var host = new HostBuilder()
.ConfigureServices((context, services) =>
{
services.AddAkka("k8sLeaseDemo", (builder, provider) =>
{
builder
.WithRemoting("", 4053)
.WithClustering(sbrOption: new LeaseMajorityOption
{
LeaseImplementation = KubernetesLeaseOption.Instance,
LeaseName = "myActorSystem-akka-sbr"
});
});
}).Build();
await host.RunAsync();
To enable the lease for use within SBR:
akka.cluster {
downing-provider-class = "Akka.Cluster.SBR.SplitBrainResolverProvider, Akka.Cluster"
split-brain-resolver {
active-strategy = lease-majority
lease-majority {
lease-implementation = "akka.coordination.lease.kubernetes"
}
}
}
akka.coordination.lease.kubernetes {
lease-class = "Akka.Coordination.KubernetesApi.KubernetesLease, Akka.Coordination.KubernetesApi"
api-ca-path = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
api-token-path = "/var/run/secrets/kubernetes.io/serviceaccount/token"
api-service-host-env-name = "KUBERNETES_SERVICE_HOST"
api-service-port-env-name = "KUBERNETES_SERVICE_PORT"
# Namespace file path. The namespace is to create the lock in. Can be overridden by "namespace"
#
# If this path doesn't exist, the namespace will default to "default".
namespace-path = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
# Namespace to create the lock in. If set to something other than "<namespace>" then overrides any value
# in "namespace-path"
namespace = "<namespace>"
# How often to write time into CRD so that if the holder crashes
# another node can take the lease after a given timeout. If left blank then the default is
# max(5s, heartbeat-timeout / 10) which will be 12s with the default heartbeat-timeout
heartbeat-interval = ""
# How long a lease must not be updated before another node can assume
# the holder has crashed.
# If the lease holder hasn't crashed its next heart beat will fail due to the version
# having been updated
heartbeat-timeout = 120s
# The individual timeout for each HTTP request. Defaults to 2/5 of the lease-operation-timeout
# Can't be greater than then lease-operation-timeout
api-service-request-timeout = ""
# Use TLS & auth token for communication with the API server
# set to false for plain text with no auth
secure-api-server = true
# The amount of time to wait for a lease to be aquired or released. This includes all requests to the API
# server that are required. If this timeout is hit then the lease *may* be taken due to the response being lost
# on the way back from the API server but will be reported as not taken and can be safely retried.
lease-operation-timeout = 5s
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.68 | 111 | 5/31/2026 |
| 1.5.67 | 144 | 4/28/2026 |
| 1.5.65 | 149 | 4/11/2026 |
| 1.5.63 | 127 | 3/31/2026 |
| 1.5.62 | 582 | 3/9/2026 |
| 1.5.61 | 383 | 2/27/2026 |
| 1.5.59 | 462 | 1/27/2026 |
| 1.5.57 | 569 | 12/16/2025 |
| 1.5.55 | 363 | 10/27/2025 |
| 1.5.52 | 1,470 | 10/10/2025 |
| 1.5.50 | 788 | 9/23/2025 |
| 1.5.48 | 1,677 | 8/29/2025 |
| 1.5.45.1 | 1,946 | 7/10/2025 |
| 1.5.45 | 364 | 7/8/2025 |
| 1.5.42 | 918 | 6/3/2025 |
| 1.5.37 | 3,151 | 1/23/2025 |
| 1.5.35 | 1,485 | 1/15/2025 |
| 1.5.33 | 467 | 12/31/2024 |
| 1.5.31 | 1,380 | 11/11/2024 |
| 1.5.30 | 1,438 | 10/3/2024 |
* Update to [Akka.NET v1.5.68](https://github.com/akkadotnet/akka.net/releases/tag/1.5.68)
* Update to [Akka.Hosting v1.5.68](https://github.com/akkadotnet/Akka.Hosting/releases/tag/1.5.68)