open-consul/website/content/commands/connect/expose.mdx

73 lines
2.7 KiB
Plaintext
Raw Normal View History

2020-06-05 21:54:45 +00:00
---
layout: commands
2020-06-05 21:54:45 +00:00
page_title: 'Commands: Connect Expose'
description: >
The connect expose subcommand is used to expose a Connect-enabled service
2020-06-05 21:54:45 +00:00
through an Ingress gateway by modifying the gateway's configuration and adding
an intention to allow traffic from the gateway to the service.
---
# Consul Connect Expose
Command: `consul connect expose`
2020-07-08 23:09:00 +00:00
The connect expose subcommand is used to expose a Connect-enabled service
2020-06-05 21:54:45 +00:00
through an Ingress gateway by modifying the gateway's configuration and adding
an intention to allow traffic from the gateway to the service. See the
[Ingress gateway documentation](/docs/connect/ingress-gateway) for more information
about Ingress gateways.
```text
Usage: consul connect expose [options]
Exposes a Connect-enabled service through the given ingress gateway, using the
given protocol and port.
```
#### API Options
@include 'http_api_options_client.mdx'
@include 'http_api_options_server.mdx'
#### Expose Options
- `-ingress-gateway` - (Required) The name of the ingress gateway service to use.
A partition and namespace can optionally be specified as a prefix via the
'[[partition/]namespace]/service' format. If a partition is not specified 'default' is assumed.
If a partition is specified a namespace must be specified. Partitions and namespaces are Enterprise features.
2020-06-05 21:54:45 +00:00
- `-port` - (Required) The listener port to use for the service on the Ingress
gateway.
2020-06-05 21:54:45 +00:00
- `-service` - (Required) The name of destination service to expose. A namespace
can optionally be specified as a prefix via the '[[partition/]namespace]/service'
format. If a partition is not specified 'default' is assumed.
If a partition is specified a namespace must be specified. Partitions and namespaces are Enterprise features.
2020-06-05 21:54:45 +00:00
2020-06-08 23:59:47 +00:00
- `-protocol` - The protocol for the service. Defaults to 'tcp'.
2020-07-08 23:09:00 +00:00
- `-host` - Additional DNS hostname to use for routing to this service. Can be
2020-06-08 23:59:47 +00:00
specified multiple times.
2020-06-05 21:54:45 +00:00
## Examples
The example below shows using the `expose` command to make the `foo` service available
through the Ingress gateway service `ingress`. The protocol argument is optional and
defaults to `tcp` if not provided.
```shell-session
$ consul connect expose -service=foo -ingress-gateway=ingress -port 8888 -protocol=tcp
Successfully updated config entry for ingress service "ingress"
Successfully set up intention for "ingress" -> "foo"
```
Running the command again when the config entry/intention are already set up will result
in a no-op:
```shell-session
$ consul connect expose -service=foo -ingress-gateway=ingress -port 8888 -protocol=tcp
Service "foo" already exposed through listener with port 8888
Intention already exists for "ingress" -> "foo"
```