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

docs: connect-service-upstreams annotation fixes #17312

Merged
merged 12 commits into from
May 12, 2023
Next Next commit
corrections
  • Loading branch information
boruszak committed May 11, 2023
commit 72fbc3d9ccc86a50e6b706ec0e35d7584fb337c9
66 changes: 40 additions & 26 deletions website/content/docs/k8s/annotations-and-labels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,83 +74,97 @@ The following Kubernetes resource annotations could be used on a pod to control
- `consul.hashicorp.com/connect-service-upstreams` - The list of upstream
services that this pod needs to connect to via the service mesh along with a static
local port to listen for those connections. When transparent proxy is enabled,
this annotation is optional. There are a few formats this annotation can take:
this annotation is optional. This annotation can be either _unlabeled_ or _labeled_. Unlabeled annotations use component names, and then infer component types based on the annotation's syntax. Labeled annotations explicitly associate component names and types in Consul DNS addressing. To configure upstreams for [cluster peering](/consul/docs/k8s/connect/cluster-peering/tech-specs), use the labeled format.

- Unlabeled:
- **Unlabeled**:
Use the unlabeled annotation format to specify a service name, Consul Enterprise namespaces and partitions, and
boruszak marked this conversation as resolved.
Show resolved Hide resolved
datacenters. To use [cluster peering](/consul/docs/k8s/connect/cluster-peering/tech-specs) with upstreams, use the following
labeled format.
- Service name: Place the service name at the beginning of the annotation to specify the upstream service. You can
also append the datacenter where the service is deployed (optional).
datacenters.

- Service name: Place the service name at the beginning of the annotation to specify the upstream service. You also have the option to append the datacenter where the service is deployed.
boruszak marked this conversation as resolved.
Show resolved Hide resolved

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name]:[port]:[optional datacenter]"
```

- Namespace (requires Consul Enterprise 1.7+): Upstream services may be running in a different namespace. Place
the upstream namespace after the service name. For additional details about configuring the injector, refer to

[Consul Enterprise Namespaces](#consul-enterprise-namespaces) .
the upstream namespace after the service name. For additional details about configuring the injector, refer to [Consul Enterprise namespaces](#consul-enterprise-namespaces) .

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].[service-namespace]:[port]:[optional datacenter]"
```

If the namespace is not specified, the annotation defaults to the namespace of the source service.
If you are not using Consul Enterprise 1.7+, Consul interprets the value placed in the namespace position as part of the service name.
If your version of Consul Enterprise in lower than v1.7, Consul interprets the value placed in the namespace position as part of the service name.
boruszak marked this conversation as resolved.
Show resolved Hide resolved

- Admin partitions (requires Consul Enterprise 1.11+): Upstream services may be running in a different
partition. You must specify the namespace when specifying a partition. Place the partition name after the namespace. If you specify the name of the datacenter (optional), it must be the local datacenter. Communicating across partitions using this method is only supported within a
datacenter. For cross partition communication across datacenters, refer to [cluster
peering](/consul/docs/k8s/connect/cluster-peering/tech-specs).
partition. When specifying a partition, you must also specify a namespace. Place the partition name after the namespace. If you specify the name of the datacenter, it must be the local datacenter. Communicating across partitions using this method is only supported within a
datacenter. For cross partition communication across datacenters, [establish a cluster
peering connection](/consul/docs/k8s/connect/cluster-peering/usage/establish-peering) and set the upstream with a labeled annotation format.

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].[service-namespace].[service-partition]:[port]:[optional datacenter]"
```
- [Prepared queries](/consul/api-docs/query): Prepend the annotation
with `prepared_query` and place the name of the query at the beginning of the string.
```yaml
annotations:
'consul.hashicorp.com/connect-service-upstreams': 'prepared_query:[query name]:[port]'
```

- Prepared queries: To configure a [prepared query](/consul/api-docs/query) in an upstream annotation, prepend the annotation
boruszak marked this conversation as resolved.
Show resolved Hide resolved
with `prepared_query` and then invoke the name of the query.

```yaml
annotations:
'consul.hashicorp.com/connect-service-upstreams': 'prepared_query:[query name]:[port]'
```

- **Labeled** (requires Consul for Kubernetes v0.45.0+):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this above the Unlabeled section

boruszak marked this conversation as resolved.
Show resolved Hide resolved

The labeled annotation format is required when specifying an upstream service in a different datacenter. You can specify a peer, namespace, partition, or datacenter, but the format supports only one peer, datacenter, or partition per annotation.
boruszak marked this conversation as resolved.
Show resolved Hide resolved

- Labeled (requires Consul for Kubernetes v0.45.0+):
The labeled format is required when using the cluster peering feature and specifying an upstream in another
peer. You can specify a Consul Enterprise namespace, partition, or datacenter. The format supports only one peer, datacenter, or partition.
- Service name: Place the service name at the beginning of the annotation followed by `.svc` to specify the upstream service.

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc:[port]"
```

- Peer or datacenter: Place the peer or datacenter after `svc.` followed by either `peer` or `dc` and the port number.

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc.[service-peer].peer:[port]"

```

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc.[service-dc].dc:[port]"
```
- Namespace (required Consul Enterprise): Place the namespace after `svc.` followed by `ns` and the port number.

- Namespace (requires Consul Enterprise): Place the namespace after `svc.` followed by `ns` and the port number.

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc.[service-namespace].ns:[port]"
```
When specifying a peer, datacenter, or admin partition when namespaces are enabled, you must
provide the namespace .

When namespaces are enabled, you must include the namespace in the annotation before specifying a peer, datacenter, or admin partition.
boruszak marked this conversation as resolved.
Show resolved Hide resolved

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc.[service-namespace].ns.[service-peer].peer:[port]"
```

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc.[service-namespace].ns.[service-partition].ap:[port]"
```

```yaml
annotations:
"consul.hashicorp.com/connect-service-upstreams":"[service-name].svc.[service-namespace].ns.[service-dc].dc:[port]"
```

- Multiple upstreams: Delimit multiple services or upstreams with commas. You can specify any of the unlabeled, labeled, or prepared query formats when using the supported versions for the formats.
- **Multiple upstreams**: Delimit multiple services or upstreams with commas. You can specify any of the unlabeled, labeled, or prepared query formats when using the supported versions for the formats.

```yaml
annotations:
Expand Down