Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NET-4952 Add docs for export command #18425

Merged
merged 9 commits into from
Aug 11, 2023
65 changes: 65 additions & 0 deletions website/content/commands/services/export.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
layout: commands
page_title: 'Commands: Services Export'
description: |
The `consul services export` command exports a service from one peer or admin partition to another.
---

# Consul Services Export

Command: `consul services export`

The services export subcommand is used to export a service from one admin partition
or cluster peer to another. This is accomplished by creating or updating the corresponding
`exported-services` configuration entry. Running the command multiple times with the same
arguments will result in a no-op.
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

```text
Usage: consul services export [options] -name <service name> -consumer-peers <other cluster name>

Export a service to a peered cluster.

$ consul services export -name=web -consumer-peers=other-cluster

Use the -consumer-partitions flag instead of -consumer-peers to export to a different partition in the same cluster.

$ consul services export -name=web -consumer-partitions=other-partition

Additional flags and more advanced use cases are detailed below.
```

#### Command Options
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

- `-name=<string>` - (Required) The name of the service to export.

- `-consumer-peers=<string>` - (Required) A comma-separated list of cluster peers to export the service to.
In Consul Enterprise, this flag is optional if -consumer-partitions is specified.
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

#### Enterprise Options
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

- `-consumer-partitions=<string>` - A comma-separated list of admin partitions within the
same datacenter to export the service to. This flag is optional if -consumer-peers is specified.
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

@include 'http_api_partition_options.mdx'

@include 'http_api_namespace_options.mdx'

#### API Options
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

@include 'http_api_options_client.mdx'

## Examples

The example below shows using the `export` command to export the `web` service to a cluster
peer named `dc2`.
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

```shell-session hideClipboard
$ consul services export -name=web -consumer-peers=dc2
```

The example below shows using the `export` command to export the `web` service located in the
namespace `ns1` and the admin partition `part1` to other admin partitions named `part2` and `part3`.
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved

```shell-session hideClipboard
$ consul services export -name=web -namespace=ns1 -partition=part1 -consumer-partitions=part2,part3
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved
```
1 change: 1 addition & 0 deletions website/content/commands/services/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Usage: consul services <subcommand> [options] [args]
Subcommands:
deregister Deregister services with the local agent
register Register services with the local agent
export Export services from one cluster peer or admin partition to another
```

For more information, examples, and usage about a subcommand, click on the name
Expand Down
4 changes: 4 additions & 0 deletions website/data/commands-nav-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@
{
"title": "deregister",
"path": "services/deregister"
},
{
"title": "export",
"path": "services/export"
}
]
},
Expand Down