NATS Streaming with Fault Tolerance.
NATS Streaming Cluster with FT Mode on AWS
Preparation
First, we need a Kubernetes cluster with a provider that offers a service with a ReadWriteMany filesystem available. In this short guide, we will create the cluster on AWS and then use EFS for the filesystem:
# Create 3 nodes Kubernetes cluster
eksctl create cluster --name stan-k8s \
--nodes 3 \
--node-type=t3.large \ # t3.small
--region=us-east-2
# Get the credentials for your cluster
eksctl utils write-kubeconfig --name stan-k8s --region us-east-2For the FT mode to work, we will need to create an EFS volume which can be shared by more than one pod. Go into the AWS console and create one and make the sure that it is in a security group where the k8s nodes will have access to it. In case of clusters created via eksctl, this will be a security group named ClusterSharedNodeSecurityGroup:


Creating the EFS provisioner
Confirm from the FilesystemID from the cluster and the DNS name, we will use those values to create an EFS provisioner controller within the K8S cluster:

Result of deploying the manifest:
Setting up the NATS Streaming cluster
Now create a NATS Streaming cluster with FT mode enabled and using NATS embedded mode that is mounting the EFS volume:
Your cluster now will look something like this:
If everything was setup properly, one of the servers will be the active node.
NATS Streaming Cluster with FT Mode on Azure
First need to create a PVC (PersistentVolumeClaim), in Azure we can use azurefile to get a volume with ReadWriteMany:
Next create a NATS cluster using the Helm charts:
To create an FT setup using AzureFile you can use the following Helm chart values file:
Now deploy with Helm:
Send a few commands to the NATS Server to which STAN/NATS Streaming is connected:
Subscribe to get all the messages:
最后更新于