In this 60 minute long webinar Petabridge and Akka.NET co-founder Aaron Stannard you will learn about how companies ranging from the Fortune 500 to brand new startups are changing the way the build .NET applications to leverage the very latest offerings from Microsoft and the .NET open source community.
You'll learn how and why companies are moving their applications onto .NET Core; rearchitecting them to use Akka.NET for fault tolerance, scalability, and the ability to respond to customers in real-time; containerizing them with Docker; putting everything together using Kubernetes for orchestration on-premise or on the cloud with Azure Container Services.
This session will provide an overview of how all of these technologies fit together and why companies are adopting them.
Continuous Deployment with Akka.Cluster and Kubernetes (Akka.NET)
Continuous Deployment with
Akka.Cluster and Kubernetes
By Aaron Stannard,
What We’re Going to Learn
• Akka.Cluster Overview
• Docker & .NET Core Fundamentals
• Akka.Cluster & Docker Best Practices
• Kubernetes Concepts
• Azure Kubernetes Service
• Putting it all Together into Continuous
Why .NET Core?
• Extremely fast
• Future of .NET
• Plays well with
• Ubiquitous – runs
• Easy, reproducible
configuration format –
• Easy to share output
via compiled Docker
• Ubiquitous – runs on-
premise, on the cloud,
• Robust deployment
models – including
handling for stateful
• Rich ecosystem.
Why Azure Kubernetes
• Takes only a few
minutes to setup.
• Integrates well with
• Great environment for
Docker Key Terms
• “Image” – a compiled image containing all of the files
needed to execute the process.
• “Repository” – a collection of named and tagged images
hosted at a specific URI.
• “Container” – represents a running instance of a Docker
image on a host machine.
• “Host” – a machine running the Docker engine, capable
of hosting 1 or more running containers.
• Need to program Akka.Remote to
automatically listen to reachable host +
port inside Docker vNet.
• Need to program Akka.Cluster to contact
seed nodes inside Docker vNet.
• Need to program Akka.Cluster to leave
cluster gracefully prior to / during container
parser – injects runtime &
environment networking values
directly into HOCON prior to
1. If CLUSTER_IP environment variable is set, that becomes akka.remote.dot-
netty.tcp.public-hostname. If not, then Dns.GetHostName() is used.
2. CLUSTER_PORT environment variable is used for dot-netty.tcp.port.
3. CLUSTER_SEEDS environment variable is a comma-delimited list of addresses.
FROM microsoft/dotnet:2.1-sdk AS base
# should be a comma-delimited list
ENV CLUSTER_SEEDS ""
ENV CLUSTER_IP ""
ENV CLUSTER_PORT "5213"
#Akka.Remote inbound listening endpoint
COPY ./bin/Release/netcoreapp2.1/publish/ /app
# Install Petabridge.Cmd client
RUN dotnet tool install --global pbm
# Needed because https://stackoverflow.com/questions/51977474/install-dotnet-core-tool-
# RUN pbm help
CMD ["dotnet", "WebCrawler.CrawlService.dll"]
Name of the base image we’re
going to use. Taken from the
public Microsoft .NET Core
repository on DockerHub
Set of environment variables
expected by Akka.Bootstrap.Docker
The container’s port expose to the
Copy application files from host machine
to container working directory
Execute command inside container
Container’s process entrypoint. If this
process dies, the container dies.
Using Petabridge.Cmd Inside
• Provides instrumentation to managing,
viewing cluster from inside Docker
• Can be used to trigger graceful shutdowns
• Secured inside container network – have
to be able to access host machine to
Private Docker Registries
• Don’t publish your company’s code onto
• Use Azure Container Registry (ACR) or
private hosts or services instead.
Kubernetes Core Concepts
• K8s is an “orchestration” platform – networks
multiple container hosts together into unified
• Applications are deployed to the K8s cluster –
K8s then orchestrates the instantiation of
containers across hosts.
• Applications define via configuration:
– Which parts can be exposed publicly and how.
– How different parts of application can be deployed and
K8s Key Terms (for
• “Pod” – represents a single application unit
of execution. Consists of 1 or more Docker
• “Stateful set” – a deployment group of
identical pods working together as a
• “Service” – defines how a stateful set
exposes itself to other services within K8s
and Akka.NET cluster.
Akka.Cluster K8s Methodology
• All applications are deployed as stateful
– State is fundamental to how Akka.Cluster
• All internal Akka.Cluster functionality is
exposed as “ClusterIp” services
• External / public functionality can exposed
as a “LoadBalancer” service or otherwise
• Petabridge.Cmd used for node exits
• Deployments / rollbacks performed by
K8s Stateful Set YAML File (pt1)
- name: lighthouse
command: ["/bin/sh", "-c", "pbm 127.0.0.1:9110 cluster leave"]
Declares “lighthouse” stateful set
Declares number of replicas in initial
Specifies the container name inside the pod
and the Docker image used.
Tells K8s to invoke this command prior to
Terminating any pods in this stateful set.
K8s Stateful Set YAML File (pt2)
- name: ACTORSYSTEM
- name: POD_NAME
- name: CLUSTER_IP
- name: CLUSTER_SEEDS
- containerPort: 4053
Populates the POD_NAME environment
variable using K8s metadata at deployment
Populates unique per-node hostname
consumed by Akka.Bootstrap.Docker.
Liveness probe. Terminates + restarts
container if this check fails. Using
Akka.Remote inbound port.
Container port – exposed to internal
K8s ClusterIP Service YAML
- port: 4053
Exposes Lighthouse services across-hosts on
their container port (4053) and host IP
addresses. Not accessible outside of K8s cluster.
Tells K8s that this service points to the
“lighthouse” stateful set we deployed earlier.
Azure Kubernetes Service
• Managed K8s on top of Azure virtual
machines and other resources.
• Easy to setup and instrument
– Azure CLI makes it easy to communicate with
AKS via kubectl.
– Works well with Azure DevOps.
– Dev Spaces make it easy to work across
multiple people & teams.
• Great environment for learning K8s.