From b00699732c3c5c7041be248ccd5fa13a5e80ffe0 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Mon, 5 Oct 2020 13:52:59 -0700 Subject: [PATCH] Add Azure FT mode for STAN to docs --- nats-on-kubernetes/stan-ft-k8s-aws.md | 76 ++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/nats-on-kubernetes/stan-ft-k8s-aws.md b/nats-on-kubernetes/stan-ft-k8s-aws.md index 9df77d3..cb45ca8 100644 --- a/nats-on-kubernetes/stan-ft-k8s-aws.md +++ b/nats-on-kubernetes/stan-ft-k8s-aws.md @@ -1,4 +1,4 @@ -# NATS Streaming Cluster with FT Mode +# NATS Streaming Cluster with FT Mode on AWS ## Preparation @@ -382,3 +382,77 @@ $ kubectl logs stan-0 -c stan [1] 2019/12/04 20:40:41.671546 [INF] STREAM: Streaming Server is ready ``` +# 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`: + +```yaml +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: stan-efs + annotations: + volume.beta.kubernetes.io/storage-class: "azurefile" +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 100Mi +``` + +Next create a NATS cluster using the Helm charts: + +```yaml +helm repo add nats https://nats-io.github.io/k8s/helm/charts/ +helm install nats nats/nats +``` + +To create an FT setup using AzureFile you can use the following Helm chart values file: + +```yaml +stan: + image: nats-streaming:alpine + replicas: 2 + nats: + url: nats://nats:4222 +store: + type: file + ft: + group: my-group + file: + path: /data/stan/store + volume: + enabled: true + + # Mount path for the volume. + mount: /data/stan + + # FT mode requires a single shared ReadWriteMany PVC volume. + persistentVolumeClaim: + claimName: stan-efs +``` + + +Now deploy with Helm: + +```sh +helm install stan nats/stan -f ./examples/deploy-stan-ft-file.yaml +``` + +Send a few commands to the NATS Server to which STAN/NATS Streaming is connected: + +```sh +kubectl port-forward nats-0 4222:4222 & + +stan-pub -c stan foo bar.1 +stan-pub -c stan foo bar.2 +stan-pub -c stan foo bar.3 +``` + +Subscribe to get all the messages: + +```sh +stan-sub -c stan -all foo +```