使用Helm从0到K8S再到叶子节点

First, we need a number of Kubernetes clusters to be setup already. In this case we'll create a few in Digital Ocean using the doctl tool but you could use any K8S solution available:

brew install doctl
doctl kubernetes cluster create nats-k8s-sfo2 --count 3 --region sfo2
doctl kubernetes cluster create nats-k8s-ams3 --count 3 --region ams3

Next, get your NGS credentials with leafnodes enabled. For this follow these instructionsarrow-up-right and choose the Developer plan which is free and will allow you to create leafnode connections for a couple of clusters. Once you got the credentials, upload them as a secret to your K8S clusters:

for ctx in do-ams3-nats-k8s-ams3 do-sfo2-nats-k8s-sfo2; do
  kubectl --context $ctx create secret generic ngs-creds --from-file $HOME/.nkeys/creds/synadia/NGS/NGS.creds
done

Install Helm3 and add the NATS helm chart repo:

brew install helm
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm repo update

Create the config that adds the leafnode connection to Synadia's NGS:

# nats.yaml
leafnodes:
  enabled: true
  remotes:
    - url: tls://connect.ngs.global:7422
      credentials:
        secret:
          name: ngs-creds
          key: NGS.creds
natsbox:
  enabled: true

Deploy it to your K8S regions:

To test the multi-region connectivity by using the nats-box container that got deployed in each cluster:

Results from the subscribe session:

最后更新于