Deploying an akka Cluster on AWS EKS (Kubernetes)

With Amazon Elastic Kubernetes Service (EKS), AWS offers a managed Kubernetes solution that is ideal for deploying akka-based microservices. In this post, we show how to deploy an akka cluster on AWS EKS.
What is AWS EKS?
Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that makes it easy to run Kubernetes on AWS. AWS takes over the management of the control plane, allowing developers to focus on their applications.
Benefits of EKS
- Managed Control Plane: AWS takes care of availability and scaling
- Integration with AWS Services: Seamless connection to IAM, VPC, ELB, and more
- Security: Automatic security updates and integration with AWS security services
- High Availability: Control plane runs across multiple Availability Zones
akka and Kubernetes - A Perfect Combination
akka is a toolkit for building highly concurrent, distributed, and fault-tolerant applications on the JVM. In combination with Kubernetes, special advantages emerge:
akka Cluster Discovery
akka offers Kubernetes-native cluster discovery with the akka-management module. Instead of static seed nodes, akka nodes can automatically find each other via the Kubernetes API.
akka.discovery {
method = kubernetes-api
kubernetes-api {
pod-namespace = "default"
pod-label-selector = "app=my-akka-app"
}
}Health Checks
akka-management provides HTTP endpoints for Kubernetes liveness and readiness probes:
livenessProbe:
httpGet:
path: /alive
port: 8558
readinessProbe:
httpGet:
path: /ready
port: 8558Creating EKS Cluster
Prerequisites
- AWS CLI configured
- kubectl installed
- eksctl installed
Creating Cluster with eksctl
eksctl create cluster \
--name akka-cluster \
--region eu-central-1 \
--nodegroup-name standard-workers \
--node-type t3.medium \
--nodes 3 \
--nodes-min 1 \
--nodes-max 4 \
--managedUpdating kubeconfig
aws eks update-kubeconfig --region eu-central-1 --name akka-clusterPreparing akka Application for Kubernetes
Dockerfile
FROM openjdk:11-jre-slim
WORKDIR /app
COPY target/universal/stage/ .
EXPOSE 8080 8558 2552
CMD ["bin/my-akka-app"]Kubernetes Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-akka-app
spec:
replicas: 3
selector:
matchLabels:
app: my-akka-app
template:
metadata:
labels:
app: my-akka-app
spec:
containers:
- name: my-akka-app
image: my-registry/my-akka-app:latest
ports:
- containerPort: 8080
name: http
- containerPort: 8558
name: management
- containerPort: 2552
name: remoting
livenessProbe:
httpGet:
path: /alive
port: management
readinessProbe:
httpGet:
path: /ready
port: managementRBAC for Cluster Discovery
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
subjects:
- kind: ServiceAccount
name: default
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.ioPerforming Deployment
# Build and push image
docker build -t my-registry/my-akka-app:latest .
docker push my-registry/my-akka-app:latest
# Create Kubernetes resources
kubectl apply -f rbac.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
# Check status
kubectl get pods
kubectl logs -l app=my-akka-appMonitoring Cluster Status
To monitor the akka cluster status, you can use the akka-management endpoints:
kubectl port-forward svc/my-akka-app 8558:8558
curl http://localhost:8558/cluster/membersConclusion
AWS EKS provides a solid platform for deploying akka cluster applications. The combination of managed Kubernetes infrastructure and akka’s native Kubernetes integration enables the construction of highly available, distributed systems with minimal operational effort.
At innFactory, we successfully use akka and Kubernetes in numerous projects. As AWS and Lightbend partners, we support companies in developing and operating reactive cloud applications.

Tobias Jonas


