Last active
December 5, 2024 20:31
-
-
Save bronhy/6baf989b44acc3bae4aad7f7632c5961 to your computer and use it in GitHub Desktop.
NATS Cluster with Leaf Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # accounts.conf | |
| accounts { | |
| SYS: { | |
| users: [{user: admin, password: admin}] | |
| }, | |
| ACC: { | |
| users: [{user: acc, password: acc}], | |
| jetstream: enabled | |
| } | |
| } | |
| system_account: SYS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: "3.9" | |
| services: | |
| nats-node-1: | |
| image: nats | |
| command: "-c /tmp/server.conf" | |
| ports: | |
| - "4222:4222" | |
| volumes: | |
| - ./server.conf:/tmp/server.conf | |
| - ./accounts.conf:/tmp/accounts.conf | |
| - node-1:/data/jetstream | |
| networks: ["nats"] | |
| environment: | |
| SERVER_NAME: nats-node-1 | |
| nats-node-2: | |
| image: nats | |
| command: "-c /tmp/server.conf" | |
| ports: | |
| - "5222:4222" | |
| volumes: | |
| - ./server.conf:/tmp/server.conf | |
| - ./accounts.conf:/tmp/accounts.conf | |
| - node-2:/data/jetstream | |
| networks: [ "nats" ] | |
| environment: | |
| SERVER_NAME: nats-node-2 | |
| nats-node-3: | |
| image: nats | |
| command: "-c /tmp/server.conf" | |
| ports: | |
| - "6222:4222" | |
| volumes: | |
| - ./server.conf:/tmp/server.conf | |
| - ./accounts.conf:/tmp/accounts.conf | |
| - node-3:/data/jetstream | |
| networks: [ "nats" ] | |
| environment: | |
| SERVER_NAME: nats-node-3 | |
| nats-leaf: | |
| image: nats | |
| command: "-c /tmp/leaf.conf" | |
| ports: | |
| - "7222:4222" | |
| volumes: | |
| - ./leaf.conf:/tmp/leaf.conf | |
| - ./accounts.conf:/tmp/accounts.conf | |
| - leaf:/data/jetstream | |
| networks: ["nats"] | |
| environment: | |
| SERVER_NAME: leaf | |
| depends_on: | |
| - nats-node-1 | |
| networks: | |
| nats: | |
| name: nats | |
| volumes: | |
| node-1: | |
| node-2: | |
| node-3: | |
| leaf: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server_name: $SERVER_NAME | |
| jetstream { | |
| store_dir: /data/jetstream | |
| max_mem: 1G | |
| max_file: 1G | |
| domain=leaf | |
| } | |
| leafnodes { | |
| remotes = [ | |
| { | |
| urls: ["nats-leaf://admin:admin@nats-node-1:7422"] | |
| account: "SYS" | |
| }, | |
| { | |
| urls: ["nats-leaf://acc:acc@nats-node-1:7422"] | |
| account: "ACC" | |
| } | |
| ] | |
| } | |
| include ./accounts.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server_name: $SERVER_NAME | |
| leafnodes { | |
| port: 7422 | |
| } | |
| jetstream: { | |
| store_dir: /data/jetstream | |
| max_mem: 1G | |
| max_file: 1G | |
| domain=hub | |
| } | |
| cluster { | |
| name: C1 | |
| port: 6222 | |
| routes: [ | |
| nats-route://nats-node-1:6222 | |
| nats-route://nats-node-2:6222 | |
| nats-route://nats-node-3:6222 | |
| ] | |
| } | |
| include ./accounts.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment