nats-streaming

by Devtron

Helm chartv0.3.1App 0.6.0Apache-2.0

A NATS Streaming cluster setup

About this chart

NATS Streaming Clustering Helm Chart

Sets up a NATS Streaming server cluster with Raft based replication.

Getting started

This chart relies on an already available NATS Service to which the NATS Streaming nodes that will form a clusters can connect to. You can install the NATS Operator and then use it to create a NATS cluster via the following:

$ kubectl apply -f https://raw.githubusercontent.com/nats-io/nats-operator/master/example/deployment-rbac.yaml
$ kubectl apply -f https://raw.githubusercontent.com/nats-io/nats-operator/master/example/example-nats-cluster.yaml

This will create a NATS cluster on the nats-io namespace. Then, to install a NATS Streaming cluster the URL to the NATS cluster can be specified as follows (using my-release for a name label for the cluster):

$ git clone https://github.com/wallyqs/nats-streaming-cluster-chart nats-streaming-cluster
$ helm install nats-streaming -n my-release --set natsUrl=nats://nats.nats-io.svc.cluster.local:4222

This will create 3 follower nodes plus an extra Pod which is configured to be in bootstrapping mode, which will start as the leader of the Raft group as soon as it joins.

$ kubectl get pods --namespace default -l "app=nats-streaming,release=my-release"
NAME                                          READY     STATUS    RESTARTS   AGE
my-release-nats-streaming-0           1/1       Running   0          30s
my-release-nats-streaming-1           1/1       Running   0          23s
my-release-nats-streaming-2           1/1       Running   0          17s

Note that in case the bootstrapping Pod fails then it will not be recreated and instead one of the extra follower Pods will take over the leadership. The follower Pods are part of a Deployment so those in case of failure they will be recreated.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

ParameterDescriptionDefault
global.imageRegistryGlobal Docker image registrynil
image.registryNATS Streaming image registrydocker.io
image.repositoryNATS Streaming Image namenats-streaming
image.tagNATS Streaming Image tag{VERSION}
image.pullPolicyImage pull policyIfNotPresent
image.pullSecretsSpecify image pull secretsnil
auth.enabledSwitch to enable/disable client authenticationtrue
auth.userClient authentication usernats_cluster
auth.passwordClient authentication passwordrandom alhpanumeric string (10)
auth.tokenClient authentication tokennil
auth.secretNameClient authentication secret namenil
auth.secretKeyClient authentication secret keynil
clusterIDNATS Streaming Cluster Name ID"test-cluster"
natsSvcExternal NATS Server URL"nats://username:password@nats:4222"
maxChannelsMax # of channels100
maxSubsMax # of subscriptions per channel1000
maxMsgsMax # of messages per channel"1000000"
maxBytesMax messages total size per channel900mb
maxAgeMax duration a message can be stored"0s" (unlimited)
maxMsgsMax # of messages per channel1000000
debugEnable debuggingfalse
traceEnable detailed tracingfalse
replicaCountNumber of NATS Streaming nodes3
securityContext.enabledEnable security contexttrue
securityContext.fsGroupGroup ID for the container1001
securityContext.runAsUserUser ID for the container1001
statefulset.updateStrategyStatefulsets Update strategyRollingUpdate
statefulset.rollingUpdatePartitionPartition for Rolling Update strategynil
podLabelsAdditional labels to be added to pods{}
podAnnotationsAnnotations to be added to pods{}
nodeSelectorNode labels for pod assignmentnil
schedulerNameName of an alternatenil
antiAffinityAnti-affinity for pod assignmentsoft
tolerationsToleration labels for pod assignmentnil
resourcesCPU/Memory resource requests/limits{}
livenessProbe.initialDelaySecondsDelay before liveness probe is initiated30
livenessProbe.periodSecondsHow often to perform the probe10
livenessProbe.timeoutSecondsWhen the probe times out5
livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.6
readinessProbe.initialDelaySecondsDelay before readiness probe is initiated5
readinessProbe.periodSecondsHow often to perform the probe10
readinessProbe.timeoutSecondsWhen the probe times out5
readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.6
readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
monitoring.service.typeKubernetes Service type (NATS Streaming monitoring)ClusterIP
monitoring.service.portNATS Streaming monitoring port8222
monitoring.service.nodePortPort to bind to for NodePort service type (NATS Streaming monitoring)nil
monitoring.service.annotationsAnnotations for NATS Streaming monitoring service{}
monitoring.service.loadBalancerIPloadBalancerIP if NATS Streaming monitoring service type is LoadBalancernil
networkPolicy.enabledEnable NetworkPolicyfalse
sidecarsAttach additional containers to the pod.nil

File Specific Persistence Configuration

ParameterDescriptionDefault
persistence.file.compactEnabledEnable compactiontrue
persistence.file.bufferSizeFile buffer size (in bytes)"2097152" (2MB)
persistence.file.crcEnable file CRC-32 checksumtrue
persistence.file.syncEnable File.Sync on Flushtrue
persistence.file.fdsLimitMax File Descriptor limit (approx)0 (unlimited)

Additional configuration parameters not typically used may be found in values.yaml.

Deploy nats-streaming with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has nats-streaming on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartnats-streaming is pinned at v0.3.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply