From 2f8dc99d0d76a3d2cf8caa4e704041ef2bc9aded Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Mon, 15 Mar 2021 14:47:03 +0000 Subject: [PATCH] GitBook: [master] 213 pages modified --- jetstream/configuration_mgmt/README.md | 74 +------------------ .../kubernetes_controller.md | 2 +- jetstream/configuration_mgmt/terraform.md | 66 +++++++++++++++++ 3 files changed, 70 insertions(+), 72 deletions(-) diff --git a/jetstream/configuration_mgmt/README.md b/jetstream/configuration_mgmt/README.md index 7869bbf..59a6459 100644 --- a/jetstream/configuration_mgmt/README.md +++ b/jetstream/configuration_mgmt/README.md @@ -5,9 +5,9 @@ In many cases managing the configuration in your application code is the best mo We support a number of tools to assist with this: * `nats` CLI with configuration files -* [Terraform](https://www.terraform.io/) -* [GitHub Actions](https://github.com/features/actions) -* [Kubernetes JetStream Controller](https://github.com/nats-io/nack#jetstream-controller) +* [Terraform](terraform.md) +* [GitHub Actions](github_actions.md) +* [Kubernetes JetStream Controller](kubernetes_controller.md) ## nats Admin CLI @@ -37,71 +37,3 @@ This creates a new Consumer based on `orders_new.json`. The `orders_new.json` fi $ nats con add ORDERS NEW --config orders_new.json ``` -## Terraform - -Terraform is a Cloud configuration tool from Hashicorp found at [terraform.io](https://www.terraform.io/), we maintain a Provider for Terraform called [terraform-provider-jetstream](https://github.com/nats-io/terraform-provider-jetstream/) that can maintain JetStream using Terraform. - -### Setup - -Our provider is not hosted by Hashicorp so installation is a bit more complex than typical. Browse to the [Release Page](https://github.com/nats-io/terraform-provider-jetstream/releases) and download the release for your platform and extract it into your Terraform plugins directory. - -```text -$ unzip -l terraform-provider-jetstream_0.0.2_darwin_amd64.zip -Archive: terraform-provider-jetstream_0.0.2_darwin_amd64.zip - Length Date Time Name ---------- ---------- ----- ---- - 11357 03-09-2020 10:48 LICENSE - 1830 03-09-2020 12:53 README.md - 24574336 03-09-2020 12:54 terraform-provider-jetstream_v0.0.2 -``` - -Place the `terraform-provider-jetstream_v0.0.2` file in `~/.terraform.d/plugins/terraform-provider-jetstream_v0.0.2` - -In your project you can configure the Provider like this: - -```text -provider "jetstream" { - servers = "connect.ngs.global" - credentials = "ngs_jetstream_admin.creds" -} -``` - -And start using it, here's an example that create the `ORDERS` example. Review the [Project README](https://github.com/nats-io/terraform-provider-jetstream#readme) for full details. - -```text -resource "jetstream_stream" "ORDERS" { - name = "ORDERS" - subjects = ["ORDERS.*"] - storage = "file" - max_age = 60 * 60 * 24 * 365 -} - -resource "jetstream_consumer" "ORDERS_NEW" { - stream_id = jetstream_stream.ORDERS.id - durable_name = "NEW" - deliver_all = true - filter_subject = "ORDERS.received" - sample_freq = 100 -} - -resource "jetstream_consumer" "ORDERS_DISPATCH" { - stream_id = jetstream_stream.ORDERS.id - durable_name = "DISPATCH" - deliver_all = true - filter_subject = "ORDERS.processed" - sample_freq = 100 -} - -resource "jetstream_consumer" "ORDERS_MONITOR" { - stream_id = jetstream_stream.ORDERS.id - durable_name = "MONITOR" - deliver_last = true - ack_policy = "none" - delivery_subject = "monitor.ORDERS" -} - -output "ORDERS_SUBJECTS" { - value = jetstream_stream.ORDERS.subjects -} -``` - diff --git a/jetstream/configuration_mgmt/kubernetes_controller.md b/jetstream/configuration_mgmt/kubernetes_controller.md index 3ea6392..df4d813 100644 --- a/jetstream/configuration_mgmt/kubernetes_controller.md +++ b/jetstream/configuration_mgmt/kubernetes_controller.md @@ -1,6 +1,6 @@ # Kubernetes Controller -The JetStream controllers allows you to manage NATS JetStream Streams and Consumers via K8S CRDs. You can find more info on how to deploy and usage [here](https://github.com/nats-io/nack#getting-started). Below you can find an example on how to create a stream and a couple of consumers: +The JetStream controllers allow you to manage NATS JetStream Streams and Consumers via K8S CRDs. You can find more info on how to deploy and usage [here](https://github.com/nats-io/nack#getting-started). Below you can find an example of how to create a stream and a couple of consumers: ```yaml --- diff --git a/jetstream/configuration_mgmt/terraform.md b/jetstream/configuration_mgmt/terraform.md index 6719963..574b59b 100644 --- a/jetstream/configuration_mgmt/terraform.md +++ b/jetstream/configuration_mgmt/terraform.md @@ -1,2 +1,68 @@ # Terraform +Terraform is a Cloud configuration tool from Hashicorp found at [terraform.io](https://www.terraform.io/), we maintain a Provider for Terraform called [terraform-provider-jetstream](https://github.com/nats-io/terraform-provider-jetstream/) that can maintain JetStream using Terraform. + +### Setup + +Our provider is not hosted by Hashicorp so installation is a bit more complex than typical. Browse to the [Release Page](https://github.com/nats-io/terraform-provider-jetstream/releases) and download the release for your platform and extract it into your Terraform plugins directory. + +```text +$ unzip -l terraform-provider-jetstream_0.0.2_darwin_amd64.zip +Archive: terraform-provider-jetstream_0.0.2_darwin_amd64.zip + Length Date Time Name +--------- ---------- ----- ---- + 11357 03-09-2020 10:48 LICENSE + 1830 03-09-2020 12:53 README.md + 24574336 03-09-2020 12:54 terraform-provider-jetstream_v0.0.2 +``` + +Place the `terraform-provider-jetstream_v0.0.2` file in `~/.terraform.d/plugins/terraform-provider-jetstream_v0.0.2` + +In your project you can configure the Provider like this: + +```text +provider "jetstream" { + servers = "connect.ngs.global" + credentials = "ngs_jetstream_admin.creds" +} +``` + +And start using it, here's an example that create the `ORDERS` example. Review the [Project README](https://github.com/nats-io/terraform-provider-jetstream#readme) for full details. + +```text +resource "jetstream_stream" "ORDERS" { + name = "ORDERS" + subjects = ["ORDERS.*"] + storage = "file" + max_age = 60 * 60 * 24 * 365 +} + +resource "jetstream_consumer" "ORDERS_NEW" { + stream_id = jetstream_stream.ORDERS.id + durable_name = "NEW" + deliver_all = true + filter_subject = "ORDERS.received" + sample_freq = 100 +} + +resource "jetstream_consumer" "ORDERS_DISPATCH" { + stream_id = jetstream_stream.ORDERS.id + durable_name = "DISPATCH" + deliver_all = true + filter_subject = "ORDERS.processed" + sample_freq = 100 +} + +resource "jetstream_consumer" "ORDERS_MONITOR" { + stream_id = jetstream_stream.ORDERS.id + durable_name = "MONITOR" + deliver_last = true + ack_policy = "none" + delivery_subject = "monitor.ORDERS" +} + +output "ORDERS_SUBJECTS" { + value = jetstream_stream.ORDERS.subjects +} +``` +