How akka/akka-sample-cluster-kubernetes-scala works
Project Type and Purpose
• This is a Scala/SBT example demonstrating how to build and deploy an Akka Cluster using Kubernetes as the orchestration and discovery mechanism.
• The code lives under src/main/scala/akka/sample/cluster/kubernetes and uses Akka Cluster Bootstrap + Kubernetes API discovery to form a dynamic cluster inside Kubernetes pods.
File-Structure Analysis
• Top‐level SBT build files: build.sbt, project/plugins.sbt (includes Docker/SBT plugin).
• kubernetes/: YAML manifests for namespace, Deployment, Service.
• scripts/: helper scripts for Minikube and Docker Desktop workflows.
• src/main/resources: application.conf (Akka settings), logback.xml.
• src/main/scala/akka/sample/cluster/kubernetes: DemoApp.scala (actor system + HTTP endpoint), DemoHealthCheck.scala (health check actor).
Key Architectural Patterns
• Micro-service pods running a reactive Akka ActorSystem in cluster mode.
• Akka Cluster Bootstrap with Kubernetes API discovery (no static seed nodes).
• Side effect: HTTP interface (port 8080) for “hello world” plus Management HTTP (port 8558) for cluster status.
Main Components
a. CI/Build Pipeline
• SBT Build → Docker Image → Docker Registry
b. Kubernetes Cluster
• Namespace (appka-1)
• Deployment “appka” (2+ replicas)
• Service (LoadBalancer on port 8080)
• Kubernetes API Server (for discovery)
c. Pod Internals (per replica)
• Container running DemoApp ActorSystem
• Akka Management HTTP endpoint (8558)
• DemoHealthCheck actor
d. External Clients
• User/browser or curl hitting Service:8080 → pods
• curl to Management port for cluster members
Relationships and Data Flow
• CI pushes Docker image to registry → Kubernetes pulls image.
• Kubernetes Deployment creates pods → each pod queries the Kubernetes API Server to discover peer pods.
• Pods form an Akka Cluster via Bootstrap.
• Client HTTP requests (8080) hit the Service → LoadBalancer → one of the pods → handled by DemoApp.
• Monitoring calls (8558) go directly to the pod’s Management HTTP interface.
• All pods maintain cluster gossip and message passing internally over Akka remoting ports.