github.com/argoproj/argo-events@v1.9.1/docs/eventbus/stan.md (about)

     1  
     2  ## NATS Streaming
     3  
     4  You can create a `native` NATS EventBus, or connect to an existing NATS
     5  Streaming service with `exotic` NATS EventBus.
     6  
     7  ### Native
     8  
     9  A simplest `native` NATS EventBus example:
    10  
    11  ```yaml
    12  apiVersion: argoproj.io/v1alpha1
    13  kind: EventBus
    14  metadata:
    15    name: default
    16  spec:
    17    nats:
    18      native: {}
    19  ```
    20  
    21  The example above brings up a NATS Streaming
    22  [StatefulSet](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)
    23  with 3 replicas in the namespace.
    24  
    25  The following example shows an EventBus with `token` auth strategy and
    26  persistent volumes.
    27  
    28  ```yaml
    29  apiVersion: argoproj.io/v1alpha1
    30  kind: EventBus
    31  metadata:
    32    name: default
    33  spec:
    34    nats:
    35      native:
    36        replicas: 3 # optional, defaults to 3, and requires minimal 3
    37        auth: token # optional, default to none
    38        persistence: # optional
    39          storageClassName: standard
    40          accessMode: ReadWriteOnce
    41          volumeSize: 10Gi
    42  ```
    43  
    44  #### Properties
    45  
    46  Check
    47  [here](https://github.com/argoproj/argo-events/tree/stable/api/event-bus.md#argoproj.io/v1alpha1.NativeStrategy)
    48  for the full spec of `native`.
    49  
    50  - `replicas` - StatefulSet replicas, defaults to 3, and requires minimal 3.
    51    According to
    52    [NATS Streaming doc](https://docs.nats.io/nats-streaming-concepts/clustering),
    53    the size should probably be limited to 3 to 5, and odd number is recommended.
    54  
    55  - `auth` - The strategy that clients connect to NATS Streaming service, `none`
    56    or `token` is currently supported, defaults to `none`.
    57  
    58    If `token` strategy is used, the system will generate a token and store it in
    59    K8s secrets (one for client, one for server), EventSource and Sensor PODs will
    60    automatically load the client secret and use it to connect to the EventBus.
    61  
    62  - `antiAffinity` - Whether to create the StatefulSet PODs with anti-affinity
    63    rule. **Deprecated** in `v1.3`, will be removed in `v1.5`, use `affinity`
    64    instead.
    65  
    66  - `nodeSelector` -
    67    [Node selector](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/)
    68    for StatefulSet PODs.
    69  
    70  - `tolerations` -
    71    [Tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
    72    for the PODs.
    73  
    74  - `persistence` - Whether to use a
    75    [persistence volume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/)
    76    for the data.
    77  
    78  - `securityContext` - POD level
    79    [security attributes](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
    80    and common container settings.
    81  
    82  - `maxAge` - Max Age of existing messages, i.e. `72h`, `4h35m`, defaults to
    83    `72h`.
    84  
    85  - `maxMsgs` - Max number of messages before expiring the oldest messages, 0 means unlimited. Defaults to 1000000.
    86  
    87  - `maxBytes` - Total size of messages before expiring the oldest messages, 0 means unlimited. Defaults to 1GB.
    88  
    89  - `maxSubs` - Maximum number of subscriptions, 0 means unlimited. Defaults to 1000.
    90  
    91  - `maxPayload` - Maximum number of bytes in a message payload, 0 means unlimited. Defaults to 1MB.
    92  
    93  - `imagePullSecrets` - Secrets used to pull images.
    94  
    95  - `serviceAccountName` - In case your firm requires to use a service account
    96    other than `default`.
    97  
    98  - `priority` -
    99    [Priority](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
   100    of the StatefulSet PODs.
   101  
   102  - `priorityClassName` -
   103    [PriorityClassName](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
   104    of the StatefulSet PODs.
   105  
   106  - `affinity` -
   107    [Affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/)
   108    settings for the StatefulSet PODs.
   109  
   110  #### More About Native NATS EventBus
   111  
   112  - Messages limit per channel defaults to 1,000,000. It could be customized by
   113    setting `spec.nats.native.maxMsgs`, `0` means unlimited.
   114  
   115  - Message bytes per channel defaults to `1GB`, setting
   116    `spec.nats.native.maxBytes` to customize it, `"0"` means unlimited.
   117  
   118  - Max age of messages is 72 hours, which means messages over 72 hours will be
   119    deleted automatically. It can be customized by setting
   120    `spec.nats.native.maxAge`, i.e. `240h`.
   121  
   122  - Max subscription number is defaults to `1000`, it could be customized by
   123    setting `spec.nats.native.maxSubs`.
   124  
   125  ### Exotic
   126  
   127  To use an existing NATS Streaming service, follow the example below.
   128  
   129  ```yaml
   130  apiVersion: argoproj.io/v1alpha1
   131  kind: EventBus
   132  metadata:
   133    name: default
   134  spec:
   135    nats:
   136      exotic:
   137        url: nats://xxxxx:xxx
   138        clusterID: cluster-id
   139        auth: token
   140        accessSecret:
   141          name: my-secret-name
   142          key: secret-key
   143  ```
   144  
   145  ## More Information
   146  
   147  - To view a finalized EventBus config:
   148  
   149  ```sh
   150  kubectl get eventbus default  -o json | jq '.status.config'
   151  ```
   152  
   153  A sample result:
   154  
   155  ```json
   156  {
   157    "nats": {
   158      "accessSecret": {
   159        "key": "client-auth",
   160        "name": "eventbus-default-client"
   161      },
   162      "auth": "token",
   163      "clusterID": "eventbus-default",
   164      "url": "nats://eventbus-default-stan-svc:4222"
   165    }
   166  }
   167  ```
   168  
   169  All the events in a namespace are published to same channel/subject/topic
   170    named `eventbus-{namespace}` in the EventBus.