1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00

GitBook: [master] one page modified

This commit is contained in:
Ginger Collison 2020-01-21 20:01:04 +00:00 committed by gitbook-bot
parent e692de533f
commit a63cb10317
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF

View File

@ -1,10 +1,10 @@
# Basic NATS and NATS Streaming Setup in K8S
# Basic 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:
```sh
```bash
# Single server NATS
kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-server/single-server-nats.yml
@ -13,22 +13,16 @@ kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-strea
This will setup:
- A statefulset with a single NATS server (no auth nor TLS)
* 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`
- A single NATS Streaming node using file store with persistence
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.
- A `nats` headless service to which you can connect
Next, try using `nats-box` to connect to the `nats` service to confirm that you have set both NATS and NATS Streaming correctly.
- A NATS Streaming Server that uses the cluster name `stan`
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.
Next, try using `nats-box` to connect to the `nats` service to confirm
that you have set both NATS and NATS Streaming correctly.
```sh
```bash
kubectl run -i --rm --tty nats-box --image=synadia/nats-box --restart=Never
# Send message to NATS
@ -36,8 +30,6 @@ 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'
@ -45,17 +37,14 @@ 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
[#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. 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.
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, 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
```bash
# Create NATS cluster
kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/master/nats-server/simple-nats.yml
@ -63,7 +52,5 @@ 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/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](stan-ft-k8s-aws).
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.](stan-ft-k8s-aws.md)