From 25d753efe5d4d487895bce4cfa0a460fc2d5ff81 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Mon, 20 Jan 2020 17:00:33 -0800 Subject: [PATCH 1/8] Add guide for simple NATS setup --- nats-on-kubernetes/minimal-setup.md | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 nats-on-kubernetes/minimal-setup.md diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md new file mode 100644 index 0000000..6b0ffd8 --- /dev/null +++ b/nats-on-kubernetes/minimal-setup.md @@ -0,0 +1,69 @@ +# Basic NATS and NATS Streaming setup in K8S + +## Minimal NATS and NATS Streaming setup + +To try NATS with the minimal components, you can start with the following: + +```sh +# Single server NATS +kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-server/single-server-nats.yml + +kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-streaming-server/single-server-stan.yml +``` + +This will setup for you: + +- A statefulset with a single NATS server (no auth nor TLS) + +- A single NATS Streaming node using file store with persistence + +- A `nats` headless service to which you can connect. + +- A NATS Streaming Server that uses the cluster name `stan`. + +Note that the only service that your applications have to connect is +the `nats` service, the NATS Streaming server will be available by +using NATS as a transport. + +Next, try using `nats-box` to connect to the `nats` service to confirm +that you have set both NATS and NATS Streaming correctly. + +```sh +kubectl run -i --rm --tty nats-box --image=synadia/nats-box --restart=Never + +# Send message to NATS +nats-box:~# nats-sub -s nats hello & +Listening on [hello] + +nats-box:~# nats-pub -s nats hello world +[#1] Received on [hello]: 'world' + +# Send/Receive message to STAN +nats-box:~# stan-pub -s nats -c stan hello world +Published [hello] : 'world' + +nats-box:~# stan-sub -s nats -c stan hello +Connected to nats clusterID: [stan] clientID: [stan-sub] +Listening on [hello], clientID=[stan-sub], qgroup=[] durable=[] +[#1] Received: sequence:1 subject:"hello" data:"world" timestamp:1579544643374163630 +``` + +## HA setup using StatefulSets + +In order to have higher availability you can setup NATS and NATS +Streaming (STAN) to run in clustering mode. The following commands +will setup a 3-node NATS cluster as well as a 3-node NATS Streaming +cluster that has an attached volume for persistence. + +```sh +# Create NATS cluster +kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-server/simple-nats.yml + +# Create STAN cluster +kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-streaming-server/simple-stan.yml +``` + +For NATS Streaming, it is actually recommended to use the Fault +Tolerance mode as that would show better performance than clustering +mode and better failover. You can follow this guide to setup +[NATS Streaming with Fault Tolerance](https://docs.nats.io/nats-on-kubernetes/stan-ft-k8s-aws). From 2b563d587f194611a3cf029cbe9e230f406704fa Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Tue, 21 Jan 2020 09:57:58 -0800 Subject: [PATCH 2/8] Update nats-on-kubernetes/minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index 6b0ffd8..a3a60ac 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -2,7 +2,7 @@ ## Minimal NATS and NATS Streaming setup -To try NATS with the minimal components, you can start with the following: +To try NATS with the minimal number of components, you can start with the following: ```sh # Single server NATS From 08d1baa2dc66679cee7d6ce6f10e4aba137c96ea Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Tue, 21 Jan 2020 10:00:01 -0800 Subject: [PATCH 3/8] Update nats-on-kubernetes/minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index a3a60ac..aa37bf0 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -53,7 +53,7 @@ Listening on [hello], clientID=[stan-sub], qgroup=[] durable=[] In order to have higher availability you can setup NATS and NATS Streaming (STAN) to run in clustering mode. The following commands will setup a 3-node NATS cluster as well as a 3-node NATS Streaming -cluster that has an attached volume for persistence. +cluster that has an attached volume for persistence. Note that you will need more than one node available in your Kubernetes cluster in order for this to work, so in case of deploying onto minikube or docker desktop, please try the single node installer instead. ```sh # Create NATS cluster From 17e72dfb650f026d0bfa6d2f22c9d192020120a3 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo Date: Tue, 21 Jan 2020 10:02:32 -0800 Subject: [PATCH 4/8] Update nats-on-kubernetes/minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index aa37bf0..70834f8 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -52,7 +52,7 @@ Listening on [hello], clientID=[stan-sub], qgroup=[] durable=[] In order to have higher availability you can setup NATS and NATS Streaming (STAN) to run in clustering mode. The following commands -will setup a 3-node NATS cluster as well as a 3-node NATS Streaming +will setup a 3 node NATS cluster as well as a 3-node NATS Streaming cluster that has an attached volume for persistence. Note that you will need more than one node available in your Kubernetes cluster in order for this to work, so in case of deploying onto minikube or docker desktop, please try the single node installer instead. ```sh From a18cc0e83e1a844f1f95eb455d87f260a588a3c5 Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Tue, 21 Jan 2020 13:26:42 -0600 Subject: [PATCH 5/8] Update minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index 70834f8..b28a876 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -1,6 +1,6 @@ -# Basic NATS and NATS Streaming setup in K8S +# Basic NATS and NATS Streaming Setup in K8S -## Minimal NATS and NATS Streaming setup +## Minimal NATS and NATS Streaming Setup To try NATS with the minimal number of components, you can start with the following: @@ -52,7 +52,7 @@ Listening on [hello], clientID=[stan-sub], qgroup=[] durable=[] In order to have higher availability you can setup NATS and NATS Streaming (STAN) to run in clustering mode. The following commands -will setup a 3 node NATS cluster as well as a 3-node NATS Streaming +will setup a 3 node NATS cluster as well as a 3 node NATS Streaming cluster that has an attached volume for persistence. Note that you will need more than one node available in your Kubernetes cluster in order for this to work, so in case of deploying onto minikube or docker desktop, please try the single node installer instead. ```sh From 56c837e42d6a5afd0b9d6a8a256c671ed080f515 Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Tue, 21 Jan 2020 13:48:18 -0600 Subject: [PATCH 6/8] Update minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index b28a876..54d5ccb 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -11,17 +11,17 @@ kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-serve kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-streaming-server/single-server-stan.yml ``` -This will setup for you: +This will setup: - A statefulset with a single NATS server (no auth nor TLS) - A single NATS Streaming node using file store with persistence -- A `nats` headless service to which you can connect. +- A `nats` headless service to which you can connect -- A NATS Streaming Server that uses the cluster name `stan`. +- A NATS Streaming Server that uses the cluster name `stan` -Note that the only service that your applications have to connect is +Note that the only service your applications have to connect to is the `nats` service, the NATS Streaming server will be available by using NATS as a transport. @@ -48,12 +48,12 @@ Listening on [hello], clientID=[stan-sub], qgroup=[] durable=[] [#1] Received: sequence:1 subject:"hello" data:"world" timestamp:1579544643374163630 ``` -## HA setup using StatefulSets +## HA Setup Using StatefulSets In order to have higher availability you can setup NATS and NATS Streaming (STAN) to run in clustering mode. The following commands will setup a 3 node NATS cluster as well as a 3 node NATS Streaming -cluster that has an attached volume for persistence. Note that you will need more than one node available in your Kubernetes cluster in order for this to work, so in case of deploying onto minikube or docker desktop, please try the single node installer instead. +cluster that has an attached volume for persistence. Note, you will need more than one node available in your Kubernetes cluster in order for this to work, so in case of deploying onto minikube or docker desktop, please try the single node installer instead. ```sh # Create NATS cluster @@ -66,4 +66,4 @@ kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-strea For NATS Streaming, it is actually recommended to use the Fault Tolerance mode as that would show better performance than clustering mode and better failover. You can follow this guide to setup -[NATS Streaming with Fault Tolerance](https://docs.nats.io/nats-on-kubernetes/stan-ft-k8s-aws). +[NATS Streaming with Fault Tolerance](/nats-on-kubernetes/stan-ft-k8s-aws). From f6032040eab8ed04b6bac748c5e2573293e48f02 Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Tue, 21 Jan 2020 13:50:49 -0600 Subject: [PATCH 7/8] Update minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index 54d5ccb..7f675fd 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -66,4 +66,4 @@ kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-strea For NATS Streaming, it is actually recommended to use the Fault Tolerance mode as that would show better performance than clustering mode and better failover. You can follow this guide to setup -[NATS Streaming with Fault Tolerance](/nats-on-kubernetes/stan-ft-k8s-aws). +[NATS Streaming with Fault Tolerance](nats-on-kubernetes/stan-ft-k8s-aws). From 31cc41804f0e170860947fe024e0839d1304c0f3 Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Tue, 21 Jan 2020 13:51:20 -0600 Subject: [PATCH 8/8] Update minimal-setup.md --- nats-on-kubernetes/minimal-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nats-on-kubernetes/minimal-setup.md b/nats-on-kubernetes/minimal-setup.md index 7f675fd..012bc6b 100644 --- a/nats-on-kubernetes/minimal-setup.md +++ b/nats-on-kubernetes/minimal-setup.md @@ -66,4 +66,4 @@ kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-strea For NATS Streaming, it is actually recommended to use the Fault Tolerance mode as that would show better performance than clustering mode and better failover. You can follow this guide to setup -[NATS Streaming with Fault Tolerance](nats-on-kubernetes/stan-ft-k8s-aws). +[NATS Streaming with Fault Tolerance](stan-ft-k8s-aws).