nats-box

repository·main·Indexed 41 days ago

https://github.com/nats-io/nats-box

A lightweight containerized toolkit bundling essential NATS management and monitoring utilities, including the NATS CLI, NSC, nats-top, and nkeys.

Tokens
436
Snippets
3
Records
5
Agent score
50%

What's inside nats-box

  1. What is nats-box

    main
    nats-box is a lightweight container that bundles essential NATS utilities for management and monitoring. It is designed to provide a ready-to-use environment for interacting with NATS servers without needing to install multiple tools locally.
  2. Included NATS utilities in nats-box

    main

    The container includes the following tools:

    • nats: NATS management utility.
    • nsc: Tool for creating NATS accounts and users.
    • nats-top: A top-like monitoring tool for NATS servers.
    • nk: NATS nkeys tool.
  3. Manage NATS v2 users and accounts with NSC via volume mounting

    main

    To persist NSC accounts, nkeys, and configurations to your host machine, mount a local directory to the /nsc path inside the container.

    1. Run the container with a volume mount:
    docker run --rm -it -v $(pwd)/nsc:/nsc natsio/nats-box:latest
    1. If NSC is not yet initialized, run the initialization command inside the container pointing to the mounted directory:
    nsc init -d /nsc

    This will create the accounts and nkeys directories within your local ./nsc folder.

  4. Run nats-box using Docker

    main

    To start an interactive session with the NATS utilities, run the following Docker command:

    docker run --rm -it natsio/nats-box:latest

    Once inside, you can use the nats CLI to interact with servers, for example:

    nats pub -s demo.nats.io test 'Hello World'
  5. Run nats-box in Kubernetes

    main

    You can run an interactive nats-box pod in a Kubernetes cluster using kubectl:

    kubectl run -i --rm --tty nats-box --image=natsio/nats-box --restart=Never

    Example usage inside the pod:

    nats-box:~# nats sub -s nats hello &
    nats-box:~# nats pub -s nats hello world