### Install NATS and NACK with Helm Source: https://github.com/nats-io/nack/blob/main/README.md Installs the NATS server and the NACK controller using Helm charts. Ensure NATS JetStream is enabled. ```sh helm repo add nats https://nats-io.github.io/k8s/helm/charts/ helm repo update helm upgrade --install nats nats/nats \ --set config.jetstream.enabled=true \ --set config.jetstream.memoryStore.enabled=true \ --set config.cluster.enabled=true --wait helm upgrade --install nack nats/nack \ --set jetstream.nats.url=nats://nats.default.svc.cluster.local:4222 --wait ``` -------------------------------- ### Build All Binaries with Make Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Use the 'make build' command to compile all project binaries. This is a common starting point for development. ```bash make build ``` -------------------------------- ### Kubernetes Setup for NATS JetStream with TLS Source: https://github.com/nats-io/nack/blob/main/README.md Commands to set up cert-manager, TLS certificates, NATS cluster, and the NATS JetStream controller in a Kubernetes environment. This includes installing custom resources for accounts, streams, and consumers. ```bash # Install cert-manager kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.17.0/cert-manager.yaml # Install TLS certs cd examples/secure # Install certificate issuer kubectl apply -f issuer.yaml # Install account A cert kubectl apply -f nack-a-client-tls.yaml # Install server cert kubectl apply -f server-tls.yaml # Install nats-box cert kubectl apply -f client-tls.yaml # Install NATS cluster helm upgrade --install -f nats-helm.yaml nats nats/nats # Verify pods are healthy kubectl get pods # Install JetStream Controller from nack helm upgrade --install nack nats/nack --set jetstream.enabled=true # Verify pods are healthy kubectl get pods # Create account A resource kubectl apply -f nack/nats-account-a.yaml # Create stream using account A kubectl apply -f nack/nats-stream-foo-a.yaml # Create consumer using account A kubectl apply -f nack/nats-consumer-bar-a.yaml ``` -------------------------------- ### Configure NATS Boot Config Source: https://github.com/nats-io/nack/blob/main/README.md Example YAML configuration for the NATS boot config utility. Specify the image and pull policy. ```yaml bootconfig: image: natsio/nats-boot-config:0.16.1 pullPolicy: IfNotPresent ``` -------------------------------- ### Start Local NATS Server Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Start a local NATS server with JetStream enabled. The '-DV' flags enable debug logging and verbose output. ```bash nats-server -DV -js ``` -------------------------------- ### Build and Run JetStream Controller Locally Source: https://github.com/nats-io/nack/blob/main/README.md Commands to build the JetStream controller locally and run it with specified configuration. Includes an example of increasing log verbosity. ```bash # First, build the jetstream controller. make jetstream-controller # Next, run the controller like this ./jetstream-controller -kubeconfig ~/.kube/config -s nats://localhost:4222 # Pro tip: jetstream-controller uses klog just like kubectl or kube-apiserver. # This means you can change the verbosity of logs with the -v flag. # # For example, this prints raw HTTP requests and responses. # ./jetstream-controller -v=10 ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/nats-io/nack/blob/main/CONTRIBUTING.md Executes the full end-to-end test suite for both legacy and control-loop controller modes. Requires 'kind' and 'kubectl-kuttl' to be installed. ```bash make test-e2e ``` -------------------------------- ### Build Jetstream Controller Docker Image Source: https://github.com/nats-io/nack/blob/main/README.md Builds a Docker image for the Jetstream controller with a specified version. Ensure you have make and Docker installed. ```sh make jetstream-controller-docker ver=1.2.3 ``` -------------------------------- ### Add NATS Helm Repository and Install Source: https://github.com/nats-io/nack/blob/main/README.md Adds the NATS Helm chart repository and installs or upgrades the NATS release. This is used for deploying NATS and its related components like the config reloader. ```sh helm repo add nats https://nats-io.github.io/k8s/helm/charts/ ``` ```sh helm upgrade --install nats nats/nats ``` -------------------------------- ### Enable Experimental Controller-Runtime Controllers Source: https://github.com/nats-io/nack/blob/main/README.md Upgrades the NACK installation to enable the experimental controller-runtime controllers, which offer more reliable resource state enforcement. This includes enabling the `--control-loop` flag for enhanced capabilities. ```sh helm upgrade nack nats/nack \ --set jetstream.nats.url=nats://nats.default.svc.cluster.local:4222 \ --set jetstream.additionalArgs={--control-loop} --wait ``` -------------------------------- ### Configure NATS Server Config Reloader Source: https://github.com/nats-io/nack/blob/main/README.md Example YAML configuration for enabling the NATS server config reloader. Specify the image and pull policy. ```yaml reloader: enabled: true image: natsio/nats-server-config-reloader:0.16.1 pullPolicy: IfNotPresent ``` -------------------------------- ### Run Namespaced NACK Controllers Source: https://github.com/nats-io/nack/blob/main/README.md Installs NACK with the `namespaced` option enabled, allowing the controller to reconcile resources only within its own namespace. This is useful for managing multiple NATS systems within a single Kubernetes cluster. ```sh helm upgrade --install nack nats/nack \ --create-namespace --namespace nats \ --set namespaced=true \ --set jetstream.nats.url=nats://nats.nats.svc.cluster.local:4222 --wait ``` -------------------------------- ### Stream Specification Sources Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines the configuration for stream sources, including external API and deliver prefixes, filter subjects, names, and optional start sequence or time. ```APIDOC ## Stream.spec.sources[index] ### Description Configuration for stream sources. ### Parameters #### Path Parameters - **index** (integer) - Required - Index of the source in the sources array. #### Request Body - **externalApiPrefix** (string) - Optional - Prefix for external API calls. - **externalDeliverPrefix** (string) - Optional - Prefix for external delivery. - **filterSubject** (string) - Optional - Subject to filter messages. - **name** (string) - Optional - Name of the source. - **optStartSeq** (integer) - Optional - Optional starting sequence number. - **optStartTime** (string) - Optional - Optional starting time in RFC3339 format. - **subjectTransforms** (array of objects) - Optional - List of subject transforms for this mirror. ``` -------------------------------- ### Get Deliver Subject of a Consumer Source: https://github.com/nats-io/nack/blob/main/README.md Retrieve the deliver subject configured for a specific push-based consumer using kubectl. ```bash $ kubectl get consumer my-push-consumer -o jsonpath={.spec.deliverSubject} my-push-consumer.orders ``` -------------------------------- ### Access nats-box Container Shell Source: https://github.com/nats-io/nack/blob/main/README.md Command to get an interactive shell inside the nats-box container for managing NATS JetStream. ```bash # Get container shell kubectl exec -it deployment/nats-box -- /bin/sh -l ``` -------------------------------- ### Define an Example NATS Stream Source: https://github.com/nats-io/nack/blob/main/README.md Defines a NATS JetStream Stream resource named 'bar' with specified subjects, storage type, replica count, and maximum age. This manifest is used to create the stream within the NATS system. ```yaml apiVersion: jetstream.nats.io/v1beta2 kind: Stream metadata: name: bar spec: name: bar subjects: ["bar", "bar.>"] storage: file replicas: 3 maxAge: 1h servers: - nats://nats.nats.svc.cluster.local:4222 ``` -------------------------------- ### Build and Run NATS Boot Config Locally Source: https://github.com/nats-io/nack/blob/main/README.md First, build the NATS boot config utility using make. Then, run the utility from your terminal. ```sh # First, build the project. make nats-boot-config # Next, run the project like this ./nats-boot-config ``` -------------------------------- ### Build NATS Boot Config Utility with Make Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Build the utility used as an init container for node-level network configuration. ```bash make nats-boot-config ``` -------------------------------- ### Run Unit Tests with Make Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Execute all unit tests, including static analysis (go vet), environment testing (envtest), and Go tests. This command ensures code quality and correctness. ```bash make test ``` -------------------------------- ### Get Filter Subject of a Consumer Source: https://github.com/nats-io/nack/blob/main/README.md Retrieve the filter subject configured for a specific consumer using kubectl. ```bash $ kubectl get consumer my-pull-consumer -o jsonpath={.spec.filterSubject} orders.received ``` -------------------------------- ### Build JetStream Controller with Make Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Build the main JetStream controller binary. The race detector is enabled by default for this build. ```bash make jetstream-controller ``` -------------------------------- ### Format Go Code Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Format all Go code in the project using 'go fmt'. This command ensures consistent code style across the repository. ```bash go fmt ./... ``` -------------------------------- ### Build NATS Boot Config Docker Image Source: https://github.com/nats-io/nack/blob/main/README.md Builds a Docker image for the NATS boot config utility with a specified version. Requires make and Docker. ```sh make nats-boot-config-docker ver=1.2.3 ``` -------------------------------- ### Build and Push Docker Images for Release Source: https://github.com/nats-io/nack/wiki/Releasing This sequence of commands is used to create a Docker builder, tag a new release version, build Docker images for various components using make tasks, and finally push the Git tag. ```sh # Create a builder for the Docker images docker buildx create --name mybuilder --use --bootstrap # Create the tag git tag -a v0.7.4 -m "v0.7.4" # Use the dockerx task for each one of the containers make jetstream-controller-dockerx ver=0.7.4 make nats-server-config-reloader-dockerx ver=0.7.4 make nats-boot-config-dockerx ver=0.7.4 # Push the tag git push origin main v0.7.4 ``` -------------------------------- ### Clean Built Binaries with Make Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Remove all compiled binaries from the project directory. Use this command to ensure a clean build environment. ```bash make clean ``` -------------------------------- ### ObjectStore.spec.placement Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines the placement configuration for an ObjectStore. ```APIDOC ## ObjectStore.spec.placement ### Description The Object Store placement via tags or cluster name. ### Fields - **cluster** (string) - Optional - **tags** ([]string) - Optional ``` -------------------------------- ### Run Specific Test Package Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Execute Go tests for a specific package with race detection, coverage, and a 30-second timeout. Useful for focused testing during development. ```bash go test -race -cover -count=1 -timeout 30s ./internal/controller/... ``` ```bash go test -race -cover -count=1 -timeout 30s ./controllers/jetstream/... ``` -------------------------------- ### NATS Stream CRD Definition Linked to Account Source: https://github.com/nats-io/nack/blob/main/README.md Define a Stream resource and link it to an Account, so the Stream uses the Account's information for creation. This example creates a stream named 'foo' that accepts messages on subjects 'foo' and 'foo.>', using file storage. ```yaml --- apiVersion: jetstream.nats.io/v1beta2 kind: Stream metadata: name: foo spec: name: foo subjects: ["foo", "foo.>"] storage: file replicas: 1 account: a # <-- Create stream using account A information ``` -------------------------------- ### Build NATS Server Config Reloader with Make Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Build the sidecar binary responsible for reloading NATS server configurations. ```bash make nats-server-config-reloader ``` -------------------------------- ### Build and Run NATS Server Config Reloader Locally Source: https://github.com/nats-io/nack/blob/main/README.md First, build the NATS server config reloader executable using make. Then, run the reloader from your terminal. ```sh # First, build the config reloader. make nats-server-config-reloader # Next, run the reloader like this ./nats-server-config-reloader ``` -------------------------------- ### Build and Run Controller Locally Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Build the JetStream controller and run it against a local Kubernetes cluster using a provided kubeconfig. The NATS server address can also be specified. ```bash make jetstream-controller ./jetstream-controller -kubeconfig ~/.kube/config -s nats://localhost:4222 ``` -------------------------------- ### KeyValue.spec.placement Source: https://github.com/nats-io/nack/blob/main/docs/api.md Specifies the placement of a KeyValue store using tags or a cluster name. ```APIDOC ## KeyValue.spec.placement ### Description The KV Store placement via tags or cluster name. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **cluster** (string) - Optional - Description: None - **tags** ([]string) - Optional - Description: None ### Request Example ```json { "cluster": "string", "tags": [ "string" ] } ``` ### Response #### Success Response (200) None explicitly defined in source. #### Response Example None explicitly defined in source. ``` -------------------------------- ### KeyValue.spec.sources[index] Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for a source KeyValue store, used for mirroring or other integrations. ```APIDOC ## KeyValue.spec.sources[index] ### Description Configuration for a source KV Store. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **externalApiPrefix** (string) - Optional - Description: None - **externalDeliverPrefix** (string) - Optional - Description: None - **filterSubject** (string) - Optional - Description: None - **name** (string) - Optional - Description: None - **optStartSeq** (integer) - Optional - Description: None - **optStartTime** (string) - Optional - Description: Time format must be RFC3339. - **subjectTransforms** ([]object) - Optional - Description: List of subject transforms for this mirror. ### Request Example ```json { "externalApiPrefix": "string", "externalDeliverPrefix": "string", "filterSubject": "string", "name": "string", "optStartSeq": 0, "optStartTime": "1970-01-01T00:00:00Z", "subjectTransforms": [ { "source": "string", "dest": "string" } ] } ``` ### Response #### Success Response (200) None explicitly defined in source. #### Response Example None explicitly defined in source. ``` -------------------------------- ### Apply and Verify NATS Resources using kubectl Source: https://github.com/nats-io/nack/blob/main/README.md Applies NATS JetStream resource manifests (Stream and Consumers) using kubectl and verifies their successful creation by querying the Kubernetes API. Includes commands for describing resources if they enter an Errored state. ```sh # Create a stream. $ kubectl apply -f https://raw.githubusercontent.com/nats-io/nack/main/deploy/examples/stream.yml # Check if it was successfully created. $ kubectl get streams NAME STATE STREAM NAME SUBJECTS mystream Ready mystream [orders.*] # Create a push-based consumer $ kubectl apply -f https://raw.githubusercontent.com/nats-io/nack/main/deploy/examples/consumer_push.yml # Create a pull based consumer $ kubectl apply -f https://raw.githubusercontent.com/nats-io/nack/main/deploy/examples/consumer_pull.yml # Check if they were successfully created. $ kubectl get consumers NAME STATE STREAM CONSUMER ACK POLICY my-pull-consumer Ready mystream my-pull-consumer explicit my-push-consumer Ready mystream my-push-consumer none # If you end up in an Errored state, run kubectl describe for more info. # kubectl describe streams mystream # kubectl describe consumers my-pull-consumer ``` -------------------------------- ### Run Single Go Test Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Execute a single Go test function within a specified package. The '-run' flag filters tests by name, and '-count=1' ensures it runs only once. ```bash go test -race -count=1 -timeout 30s -run TestMyFunction ./internal/controller/... ``` -------------------------------- ### Stream.spec.placement Source: https://github.com/nats-io/nack/blob/main/docs/api.md Specifies the placement configuration for a stream. ```APIDOC ## Stream.spec.placement ### Description Specifies the placement configuration for a stream. ### Parameters #### Request Body - **cluster** (string) - Optional - - **tags** ([]string) - Optional - ``` -------------------------------- ### Build NATS Server Config Reloader Docker Image Source: https://github.com/nats-io/nack/blob/main/README.md Builds a Docker image for the NATS server config reloader with a specified version. Requires make and Docker. ```sh make nats-server-config-reloader-docker ver=1.2.3 ``` -------------------------------- ### Consumer.spec Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration options for a NATS consumer. ```APIDOC ## Consumer.spec ### Description Configuration options for a NATS consumer. ### Parameters #### Request Body - **maxWaiting** (integer) - Optional - The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored. - **memStorage** (boolean) - Optional - Force the consumer state to be kept in memory rather than inherit the setting from the stream. Default: false - **metadata** (map[string]string) - Optional - Additional Consumer metadata. - **nkey** (string) - Optional - NATS user NKey for connecting to servers. - **optStartSeq** (integer) - Optional - Minimum sequence number to start consuming from. Minimum: 0 - **optStartTime** (string) - Optional - Time format must be RFC3339. Specifies the time to start consuming from. - **preventDelete** (boolean) - Optional - When true, the managed Consumer will not be deleted when the resource is deleted. Default: false - **preventUpdate** (boolean) - Optional - When true, the managed Consumer will not be updated when the resource is updated. Default: false - **rateLimitBps** (integer) - Optional - Rate at which messages will be delivered to clients, expressed in bit per second. - **replayPolicy** (enum) - Optional - How messages are sent. Enum: instant, original. Default: instant - **replicas** (integer) - Optional - When set do not inherit the replica count from the stream but specifically set it to this amount. - **sampleFreq** (string) - Optional - What percentage of acknowledgements should be samples for observability. - **servers** ([]string) - Optional - A list of servers for creating consumer. Default: [] - **streamName** (string) - Required - The name of the Stream to create the Consumer in. - **tls** (object) - Optional - A client's TLS certs and keys. - **tlsFirst** (boolean) - Optional - When true, the KV Store will initiate TLS before server INFO. Default: false ``` -------------------------------- ### ObjectStore.spec.tls Source: https://github.com/nats-io/nack/blob/main/docs/api.md TLS configuration for clients connecting to the ObjectStore. ```APIDOC ## KeyValue.spec.tls ### Description Client TLS certificates and keys configuration. ### Fields - **clientCert** (string) - Optional - A client's cert filepath. Should be mounted. - **clientKey** (string) - Optional - A client's key filepath. Should be mounted. - **rootCas** ([]string) - Optional - A list of filepaths to CAs. Should be mounted. ``` -------------------------------- ### List NATS Streams Source: https://github.com/nats-io/nack/blob/main/README.md Use the 'nats stream ls' command within the nats-box container to list available streams. ```bash # List streams nats stream ls ``` -------------------------------- ### ObjectStore.status.conditions[index] Source: https://github.com/nats-io/nack/blob/main/docs/api.md Details of a specific condition for the ObjectStore's status. ```APIDOC ## KeyValue.status.conditions[index] ### Description Represents a single condition in the ObjectStore's status. ### Fields - **lastTransitionTime** (string) - Optional - The last time the condition's status changed. - **message** (string) - Optional - A human-readable message indicating the condition's details. - **reason** (string) - Optional - A machine-readable reason for the condition. - **status** (string) - Optional - The status of the condition (e.g., True, False, Unknown). - **type** (string) - Optional - The type of the condition. ``` -------------------------------- ### Define NATS Stream, Push Consumer, Pull Consumer, KeyValue, and ObjectStore Source: https://github.com/nats-io/nack/blob/main/README.md Defines various NATS JetStream resources including a Stream, a push-based Consumer, a pull-based Consumer, a KeyValue store, and an ObjectStore. Note that KeyValue and ObjectStore require control-loop mode to be enabled. ```yaml --- apiversion: jetstream.nats.io/v1beta2 kind: Stream metadata: name: mystream spec: name: mystream subjects: ["orders.*"] storage: memory maxAge: 1h --- apiversion: jetstream.nats.io/v1beta2 kind: Consumer metadata: name: my-push-consumer spec: streamName: mystream durableName: my-push-consumer deliverSubject: my-push-consumer.orders deliverPolicy: last ackPolicy: none replayPolicy: instant --- apiversion: jetstream.nats.io/v1beta2 kind: Consumer metadata: name: my-pull-consumer spec: streamName: mystream durableName: my-pull-consumer deliverPolicy: all filterSubject: orders.received maxDeliver: 20 ackPolicy: explicit --- # Note: KeyValue requires control-loop mode to be enabled apiversion: jetstream.nats.io/v1beta2 kind: KeyValue metadata: name: my-key-value spec: bucket: my-key-value history: 20 storage: file maxBytes: 2048 compression: true --- # Note: ObjectStore requires control-loop mode to be enabled apiversion: jetstream.nats.io/v1beta2 kind: ObjectStore metadata: name: my-object-store spec: bucket: my-object-store storage: file replicas: 1 maxBytes: 536870912 # 512 MB compression: true ``` -------------------------------- ### ObjectStore.spec Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines the specification for an ObjectStore, including its properties and configuration. ```APIDOC ## ObjectStore.spec ### Description Defines the specification for an ObjectStore, including its properties and configuration. ### Fields - **account** (string) - Optional - Name of the account to which the Object Store belongs. - **bucket** (string) - Optional - A unique name for the Object Store. - **compression** (boolean) - Optional - Object Store compression. - **creds** (string) - Optional - NATS user credentials for connecting to servers. Please make sure your controller has mounted the creds on its path. - **description** (string) - Optional - The description of the Object Store. - **maxBytes** (integer) - Optional - The maximum size of the Store in bytes. - **metadata** (map[string]string) - Optional - Additional Object Store metadata. - **nkey** (string) - Optional - NATS user NKey for connecting to servers. - **placement** (object) - Optional - The Object Store placement via tags or cluster name. - **preventDelete** (boolean) - Optional - When true, the managed Object Store will not be deleted when the resource is deleted. Default: false - **preventUpdate** (boolean) - Optional - When true, the managed Object Store will not be updated when the resource is updated. Default: false - **replicas** (integer) - Optional - The number of replicas to keep for the Object Store in clustered JetStream. Default: 1. Minimum: 1. Maximum: 5. - **servers** ([]string) - Optional - A list of servers for creating the Object Store. Default: [] - **storage** (enum) - Optional - The storage backend to use for the Object Store. Enum: file, memory - **tls** (object) - Optional - A client's TLS certs and keys. - **tlsFirst** (boolean) - Optional - When true, the KV Store will initiate TLS before server INFO. Default: false - **ttl** (string) - Optional - The time expiry for keys. ``` -------------------------------- ### ObjectStore.status Source: https://github.com/nats-io/nack/blob/main/docs/api.md The current status of the ObjectStore. ```APIDOC ## KeyValue.status ### Description Represents the current status of the ObjectStore. ### Fields - **conditions** ([]object) - Optional - Conditions related to the ObjectStore's state. - **observedGeneration** (integer) - Optional - The generation observed by the controller. ``` -------------------------------- ### Account.spec Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines the configuration for an Account, including connection details like credentials, TLS, and tokens. ```APIDOC ## Account.spec ### Description Defines the configuration for an Account, including connection details like credentials, TLS, and tokens. ### Fields - **creds** (object) - Optional - The creds to be used to connect to the NATS Service. - **name** (string) - Optional - A unique name for the Account. - **servers** ([]string) - Optional - A list of servers to connect. - **tls** (object) - Optional - The TLS certs to be used to connect to the NATS Service. - **tlsFirst** (boolean) - Optional - When true, the KV Store will initiate TLS before server INFO. Defaults to false. - **token** (object) - Optional - The token to be used to connect to the NATS Service. - **user** (object) - Optional - The user and password to be used to connect to the NATS Service. ``` -------------------------------- ### KeyValue.spec Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration options for a KeyValue store. ```APIDOC ## KeyValue.spec ### Description Configuration options for a KeyValue store. ### Parameters #### Request Body - **account** (string) - Optional - Name of the account to which the Stream belongs. - **bucket** (string) - Optional - A unique name for the KV Store. - **compression** (boolean) - Optional - KV Store compression. - **creds** (string) - Optional - NATS user credentials for connecting to servers. Please make sure your controller has mounted the creds on its path. - **description** (string) - Optional - The description of the KV Store. - **history** (integer) - Optional - The number of historical values to keep per key. - **maxBytes** (integer) - Optional - The maximum size of the KV Store in bytes. - **maxValueSize** (integer) - Optional - The maximum size of a value in bytes. - **mirror** (object) - Optional - A KV Store mirror. - **nkey** (string) - Optional - NATS user NKey for connecting to servers. - **placement** (object) - Optional - The KV Store placement via tags or cluster name. - **preventDelete** (boolean) - Optional - When true, the managed KV Store will not be deleted when the resource is deleted. (Default: false) - **preventUpdate** (boolean) - Optional - When true, the managed KV Store will not be updated when the resource is updated. (Default: false) - **replicas** (integer) - Optional - The number of replicas to keep for the KV Store in clustered JetStream. (Default: 1, Minimum: 1, Maximum: 5) - **republish** (object) - Optional - Republish configuration for the KV Store. - **servers** ([]string) - Optional - A list of servers for creating the KV Store. (Default: []) - **sources** ([]object) - Optional - A KV Store's sources. - **storage** (enum) - Optional - The storage backend to use for the KV Store. (Enum: file, memory) - **tls** (object) - Optional - A client's TLS certs and keys. - **tlsFirst** (boolean) - Optional - When true, the KV Store will initiate TLS before server INFO. (Default: false) - **ttl** (string) - Optional - The time expiry for keys. - **limitMarkerTtl** (integer) - Optional - ``` -------------------------------- ### KeyValue.spec.republish Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for republishing messages from a KeyValue store. ```APIDOC ## KeyValue.spec.republish ### Description Republish configuration for the KV Store. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **destination** (string) - Optional - Description: Messages will be additionally published to this subject after Bucket. - **source** (string) - Optional - Description: Messages will be published from this subject to the destination subject. ### Request Example ```json { "destination": "string", "source": "string" } ``` ### Response #### Success Response (200) None explicitly defined in source. #### Response Example None explicitly defined in source. ``` -------------------------------- ### Consumer.spec Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines the configuration parameters for a NATS Consumer. ```APIDOC ## Consumer.spec ### Description Defines the configuration parameters for a NATS Consumer. ### Fields - **ackPolicy** (enum) - Optional - How messages should be acknowledged. Enum: none, all, explicit. Default: none. - **ackWait** (string) - Optional - How long to allow messages to remain un-acknowledged before attempting redelivery. Default: 1ns. - **deliverGroup** (string) - Optional - The name of a queue group. - **deliverPolicy** (enum) - Optional - Enum: all, last, new, byStartSequence, byStartTime. Default: all. - **deliverSubject** (string) - Optional - The subject to deliver observed messages, when not set, a pull-based Consumer is created. - **description** (string) - Optional - The description of the consumer. - **durableName** (string) - Optional - The name of the Consumer. - **filterSubject** (string) - Optional - Select only a specific incoming subjects, supports wildcards. - **flowControl** (boolean) - Optional - Enables flow control. Default: false. - **heartbeatInterval** (string) - Optional - The interval used to deliver idle heartbeats for push-based consumers, in Go's time.Duration format. - **maxAckPending** (integer) - Optional - Maximum pending Acks before consumers are paused. - **maxDeliver** (integer) - Optional - Minimum value is -1. - **optStartSeq** (integer) - Optional - Minimum value is 0. - **optStartTime** (string) - Optional - Time format must be RFC3339. - **rateLimitBps** (integer) - Optional - Rate at which messages will be delivered to clients, expressed in bit per second. - **replayPolicy** (enum) - Optional - How messages are sent. Enum: instant, original. Default: instant. - **sampleFreq** (string) - Optional - What percentage of acknowledgements should be samples for observability. - **streamName** (string) - Optional - The name of the Stream to create the Consumer in. ``` -------------------------------- ### KeyValue.spec.mirror Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for mirroring a KeyValue store to another location. This allows for replication and disaster recovery. ```APIDOC ## KeyValue.spec.mirror ### Description A KV Store mirror configuration. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **externalApiPrefix** (string) - Optional - Description: None - **externalDeliverPrefix** (string) - Optional - Description: None - **filterSubject** (string) - Optional - Description: None - **name** (string) - Optional - Description: None - **optStartSeq** (integer) - Optional - Description: None - **optStartTime** (string) - Optional - Description: Time format must be RFC3339. - **subjectTransforms** ([]object) - Optional - Description: List of subject transforms for this mirror. ### Request Example ```json { "externalApiPrefix": "string", "externalDeliverPrefix": "string", "filterSubject": "string", "name": "string", "optStartSeq": 0, "optStartTime": "1970-01-01T00:00:00Z", "subjectTransforms": [ { "source": "string", "dest": "string" } ] } ``` ### Response #### Success Response (200) None explicitly defined in source. #### Response Example None explicitly defined in source. ``` -------------------------------- ### ObjectStore Source: https://github.com/nats-io/nack/blob/main/docs/api.md The ObjectStore resource definition for NATS JetStream. ```APIDOC ## ObjectStore > **⚠️ Important**: ObjectStore resources require the JetStream controller to be running in **control-loop mode** (`--control-loop` flag). They are not supported in the default legacy mode. ### Description Represents an ObjectStore resource in NATS JetStream. ### Fields - **apiVersion** (string) - Required - `jetstream.nats.io/v1beta2` - **kind** (string) - Required - `ObjectStore` - **metadata** (object) - Required - Refer to the Kubernetes API documentation for the fields of the `metadata` field. - **spec** (object) - Optional - Specification for the ObjectStore. - **status** (object) - Optional - Status of the ObjectStore. ``` -------------------------------- ### Account Spec TLS Configuration Source: https://github.com/nats-io/nack/blob/main/docs/api.md Details the TLS configuration options for an Account's consumer. ```APIDOC ## Consumer.spec.tls ### Description A client's TLS certs and keys for a consumer. ### Fields - **clientCert** (string) - Optional - A client's cert filepath. Should be mounted. - **clientKey** (string) - Optional - A client's key filepath. Should be mounted. - **rootCas** (array of strings) - Optional - A list of filepaths to CAs. Should be mounted. ``` -------------------------------- ### ObjectStore.spec.subjectTransforms Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for subject transformation rules within the ObjectStore specification. ```APIDOC ## KeyValue.spec.subjectTransforms[index] ### Description A subject transform pair used for routing or modifying subjects. ### Fields - **dest** (string) - Optional - Destination subject. - **source** (string) - Optional - Source subject. ``` -------------------------------- ### KeyValue Resource Definition Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines the structure of a KeyValue resource, including its apiVersion, kind, metadata, spec, and status. ```APIDOC ## KeyValue Resource ### Description Represents a KeyValue store resource within NATS JetStream. Requires the JetStream controller to be running in control-loop mode. ### Fields - **apiVersion** (string) - Required - `jetstream.nats.io/v1beta2` - **kind** (string) - Required - `KeyValue` - **metadata** (object) - Required - Refer to the Kubernetes API documentation for the fields of the `metadata` field. - **spec** (object) - Optional - Configuration for the KeyValue resource. - **status** (object) - Optional - Current status of the KeyValue resource. ``` -------------------------------- ### Publish Messages with nats-box Source: https://github.com/nats-io/nack/blob/main/README.md Use the nats-box CLI to publish messages to a specified subject. ```bash nats-box:~$ nats pub orders.received "order 1" ``` ```bash nats-box:~$ nats pub orders.received "order 2" ``` -------------------------------- ### Stream.spec.placement Source: https://github.com/nats-io/nack/blob/main/docs/api.md Specifies the placement strategy for a stream, determining where the stream's data should be stored. ```APIDOC ## Stream.spec.placement ### Description A stream's placement configuration. ### Parameters #### Request Body - **cluster** (string) - Optional - - **tags** ([]string) - Optional - ``` -------------------------------- ### Publish Message to a Stream Source: https://github.com/nats-io/nack/blob/main/README.md Publish a message to a stream using the 'nats pub' command. ```bash # Push message nats pub foo hi ``` -------------------------------- ### Stream Specification Parameters Source: https://github.com/nats-io/nack/blob/main/docs/api.md This section details the parameters that can be configured for a NATS Stream. ```APIDOC ## Stream.spec ### Description Details the configuration parameters for a NATS Stream. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body ##### account (string) - Optional - Name of the account to which the Stream belongs. ##### allowDirect (boolean) - Optional - When true, allow higher performance, direct access to get individual messages. Default: false ##### allowRollup (boolean) - Optional - When true, allows the use of the Nats-Rollup header to replace all contents of a stream, or subject in a stream, with a single new message. Default: false ##### compression (enum) - Optional - Stream specific compression. Enum: s2, none. Default: (empty) ##### consumerLimits (object) - Optional - Limits for consumers. ##### creds (string) - Optional - NATS user credentials for connecting to servers. Please make sure your controller has mounted the creds on this path. Default: (empty) ##### denyDelete (boolean) - Optional - When true, restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true. Default: false ##### denyPurge (boolean) - Optional - When true, restricts the ability to purge a stream via the API. Cannot be changed once set to true. Default: false ##### description (string) - Optional - The description of the stream. ##### discard (enum) - Optional - When a Stream reach it's limits either old messages are deleted or new ones are denied. Enum: old, new. Default: old ##### discardPerSubject (boolean) - Optional - Applies discard policy on a per-subject basis. Requires discard policy 'new' and 'maxMsgs' to be set. Default: false ##### duplicateWindow (string) - Optional - The duration window to track duplicate messages for. ##### firstSequence (number) - Optional - Sequence number from which the Stream will start. Default: 0 ##### maxAge (string) - Optional - Maximum age of any message in the stream, expressed in Go's time.Duration format. Empty for unlimited. Default: (empty) ##### maxBytes (integer) - Optional - How big the Stream may be, when the combined stream size exceeds this old messages are removed. -1 for unlimited. Default: -1 ##### maxConsumers (integer) - Optional - How many Consumers can be defined for a given Stream. -1 for unlimited. Default: -1 ##### maxMsgSize (integer) - Optional - The largest message that will be accepted by the Stream. -1 for unlimited. Default: -1 ##### maxMsgs (integer) - Optional - The maximum number of messages allowed in the stream. -1 for unlimited. Default: -1 ``` -------------------------------- ### Account.spec.user Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for user and password-based authentication to connect to the NATS Service. ```APIDOC ## Account.spec.user ### Description Configuration for user and password-based authentication to connect to the NATS Service. ### Parameters #### Request Body - **password** (string) - Optional - Key in the secret that contains the password. - **secret** (object) - Optional - Configuration for the secret containing the user and password. - **user** (string) - Optional - Key in the secret that contains the user. ``` -------------------------------- ### Pull Messages from a Stream Source: https://github.com/nats-io/nack/blob/main/README.md Use the nats-box CLI to pull messages from a specified stream and consumer. Each pull acknowledges the message. ```bash # Pull first message. nats-box:~$ nats consumer next mystream my-pull-consumer --- subject: orders.received / delivered: 1 / stream seq: 1 / consumer seq: 1 order 1 Acknowledged message # Pull next message. nats-box:~$ nats consumer next mystream my-pull-consumer --- subject: orders.received / delivered: 1 / stream seq: 2 / consumer seq: 2 order 2 Acknowledged message ``` -------------------------------- ### Stream.spec.mirror Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for mirroring stream data to another stream. ```APIDOC ## Stream.spec.mirror ### Description Configuration for mirroring stream data to another stream. ### Parameters #### Request Body - **externalApiPrefix** (string) - Optional - - **externalDeliverPrefix** (string) - Optional - - **filterSubject** (string) - Optional - - **name** (string) - Optional - - **optStartSeq** (integer) - Optional - - **optStartTime** (string) - Optional - Time format must be RFC3339. - **subjectTransforms** ([]object) - Optional - List of subject transforms for this mirror. ``` -------------------------------- ### Stream.spec Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration options for a NATS Stream. ```APIDOC ## Stream.spec ### Description Configuration options for a NATS Stream. ### Fields - **subjectTransform** (object) - Description: SubjectTransform is for applying a subject transform (to matching messages) when a new message is received. - **subjects** ([]string) - Description: A list of subjects to consume, supports wildcards. - **tls** (object) - Description: A client's TLS certs and keys. - **tlsFirst** (boolean) - Description: When true, the KV Store will initiate TLS before server INFO. Default: false ``` -------------------------------- ### Pull Message from a Consumer Source: https://github.com/nats-io/nack/blob/main/README.md Pull a message from a consumer associated with a stream using the 'nats consumer next' command. ```bash # Pull message nats consumer next foo bar ``` -------------------------------- ### Account.spec.token Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for token-based authentication to connect to the NATS Service. ```APIDOC ## Account.spec.token ### Description Configuration for token-based authentication to connect to the NATS Service. ### Parameters #### Request Body - **secret** (object) - Optional - Configuration for the secret containing the token. - **token** (string) - Optional - Key in the secret that contains the token. ``` -------------------------------- ### Increase Log Verbosity Source: https://github.com/nats-io/nack/blob/main/CLAUDE.md Run the JetStream controller with increased logging verbosity using klog flags. This is useful for debugging. ```bash ./jetstream-controller -kubeconfig ~/.kube/config -s nats://localhost:4222 -v=10 ``` -------------------------------- ### KeyValue.spec.mirror.subjectTransforms[index] Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines a subject transformation pair for mirroring. ```APIDOC ## KeyValue.spec.mirror.subjectTransforms[index] ### Description A subject transform pair for a KV Store mirror. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **dest** (string) - Optional - Description: Destination subject. - **source** (string) - Optional - Description: Source subject. ### Request Example ```json { "dest": "string", "source": "string" } ``` ### Response #### Success Response (200) None explicitly defined in source. #### Response Example None explicitly defined in source. ``` -------------------------------- ### Stream.spec.sources[index] Source: https://github.com/nats-io/nack/blob/main/docs/api.md Defines a source for a stream, which can be used for mirroring or other data ingestion purposes. ```APIDOC ## Stream.spec.sources[index] ### Description Defines a source for a stream. ### Parameters #### Request Body - **externalApiPrefix** (string) - Optional - - **externalDeliverPrefix** (string) - Optional - - **filterSubject** (string) - Optional - - **name** (string) - Optional - - **optStartSeq** (integer) - Optional - - **optStartTime** (string) - Optional - Time format must be RFC3339. ``` -------------------------------- ### Stream.spec.republish Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configuration for republishing messages from a stream. ```APIDOC ## Stream.spec.republish ### Description Configuration for republishing messages from a stream. ### Parameters #### Request Body - **destination** (string) - Optional - Messages will be additionally published to this subject. - **source** (string) - Optional - Messages will be published from this subject to the destination subject. ``` -------------------------------- ### Configure NACK Helm Chart with CRD Connect Source: https://github.com/nats-io/nack/blob/main/README.md Upgrades the NACK Helm chart to include the `--crd-connect` flag, which is necessary for older NACK versions not running in `--control-loop` mode. This flag enables resource-level connection configuration within CRD manifests. ```sh helm upgrade nack nats/nack \ --set jetstream.additionalArgs={--crd-connect} --wait ``` -------------------------------- ### Stream.status.conditions[index] Source: https://github.com/nats-io/nack/blob/main/docs/api.md Details about a specific condition of a stream's status. ```APIDOC ## Stream.status.conditions[index] ### Description Represents a condition of the stream's status. ### Parameters #### Request Body - **lastTransitionTime** (string) - Optional - - **message** (string) - Optional - - **reason** (string) - Optional - - **status** (string) - Optional - - **type** (string) - Optional - ``` -------------------------------- ### Access NATS Management Utilities via nats-box Source: https://github.com/nats-io/nack/blob/main/README.md Executes into a running nats-box pod to access NATS management utilities. This is typically done to interact with NATS resources after they have been deployed. ```sh # Run nats-box that includes the NATS management utilities, and exec into it. $ kubectl exec -it deployment/nats-box -- /bin/sh -l ``` -------------------------------- ### Account.status.conditions[index] Source: https://github.com/nats-io/nack/blob/main/docs/api.md Details of a specific condition for the NATS account status. ```APIDOC ## Account.status.conditions[index] ### Description Details of a specific condition for the NATS account status. ### Parameters #### Response Body - **lastTransitionTime** (string) - Optional - The last time the condition transitioned. - **message** (string) - Optional - A human-readable message indicating the condition. - **reason** (string) - Optional - The reason for the condition. - **status** (string) - Optional - The status of the condition (e.g., True, False, Unknown). - **type** (string) - Optional - The type of condition (e.g., Available, Degraded). ``` -------------------------------- ### Stream Specification TLS Source: https://github.com/nats-io/nack/blob/main/docs/api.md Configures TLS settings for a stream, including client certificates, keys, and root CAs. ```APIDOC ## Stream.spec.tls ### Description Client's TLS certs and keys configuration. ### Parameters #### Request Body - **clientCert** (string) - Optional - Filepath to the client's certificate. Should be mounted. - **clientKey** (string) - Optional - Filepath to the client's key. Should be mounted. - **rootCas** (array of strings) - Optional - List of filepaths to CAs. Should be mounted. ``` -------------------------------- ### Account Status Conditions Source: https://github.com/nats-io/nack/blob/main/docs/api.md Details the conditions associated with an Account's status. ```APIDOC ## Account.status.conditions[index] ### Description Represents a condition of the Account. ### Fields - **lastTransitionTime** (string) - Optional - The last time the condition transitioned. - **message** (string) - Optional - A human-readable message indicating details about the condition. - **reason** (string) - Optional - A machine-readable reason for the condition. - **status** (string) - Optional - The status of the condition (e.g., True, False, Unknown). - **type** (string) - Optional - The type of the condition (e.g., Ready, Synced). ```