Skip to content

Commit

Permalink
Fix config rendering in k8s usage docs, cross link to general usage f…
Browse files Browse the repository at this point in the history
…rom k8s docs
  • Loading branch information
im2nguyen committed Feb 23, 2023
1 parent 7bf20dd commit 6863c6e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 59 deletions.
6 changes: 3 additions & 3 deletions website/content/docs/connect/cluster-peering/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ The following resources are available to help you use Consul's cluster peering f

- To learn how to peer clusters and connect services across peers in AWS Elastic Kubernetes Service (EKS) and Google Kubernetes Engine (GKE) environments, complete the [Consul Cluster Peering on Kubernetes tutorial](/consul/tutorials/developer-mesh/cluster-peering).

**Usage information:**
**Usage documentation:**

- [Establish cluster peering connections](/consul/docs/connect/cluster-peering/usage/establish-peering)
- [Manage cluster peering connections](/consul/docs/connect/cluster-peering/usage/manage-connections)
- [Manage L7 traffic with cluster peering](/consul/docs/connect/cluster-peering/usage/peering-traffic-management)

**Runtime-specific information:**
**Kubernetes usage documentation:**

- [Cluster peering on Kubernetes technical specifications](/consul/docs/k8s/connect/cluster-peering/tech-specs)
- [Establish cluster peering connections on Kubernetes](/consul/docs/k8s/connect/cluster-peering/usage/establish-peering)
- [Manage cluster peering connections on Kubernetes](/consul/docs/k8s/connect/cluster-peering/usage/manage-peering)
- [Manage L7 traffic with cluster peering on Kubernetes](/consul/docs/k8s/connect/cluster-peering/usage/l7-traffic)

**Reference information:**
**Reference documentation:**

- [Cluster peering technical specifications](/consul/docs/connect/cluster-peering/tech-specs)
- [HTTP API reference: `/peering/` endpoint](/consul/api-docs/peering)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ The overall process for establishing a cluster peering connection consists of th

Cluster peering between services cannot be established until all four steps are complete.

For general guidance for establishing cluster peering connections, refer to [Establish cluster peering connections](/consul/docs/connect/cluster-peering/usage/establish-peering).

## Prerequisites

You must meet the following requirements to use Consul's cluster peering features with Kubernetes:
Expand All @@ -34,15 +36,15 @@ After you provision a Kubernetes cluster and set up your kubeconfig file to mana

1. Get the context names for your Kubernetes clusters using one of these methods:

- Run the `kubectl config current-context` command to get the context for the cluster you are currently in.
- Run the `kubectl config get-contexts` command to get all configured contexts in your kubeconfig file.
- Run the `kubectl config current-context` command to get the context for the cluster you are currently in.
- Run the `kubectl config get-contexts` command to get all configured contexts in your kubeconfig file.

1. Use the `kubectl` command to export the Kubernetes context names and then set them to variables. For more information on how to use kubeconfig and contexts, refer to the [Kubernetes docs on configuring access to multiple clusters](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/).

```shell-session
$ export CLUSTER1_CONTEXT=<CONTEXT for first Kubernetes cluster>
$ export CLUSTER2_CONTEXT=<CONTEXT for second Kubernetes cluster>
```
```shell-session
$ export CLUSTER1_CONTEXT=<CONTEXT for first Kubernetes cluster>
$ export CLUSTER2_CONTEXT=<CONTEXT for second Kubernetes cluster>
```

### Update the Helm chart

Expand All @@ -51,15 +53,21 @@ To use cluster peering with Consul on Kubernetes deployments, update the Helm ch
1. In `cluster-01`, run the following commands:

```shell-session
$ export HELM_RELEASE_NAME=cluster-01
$ helm install ${HELM_RELEASE_NAME} hashicorp/consul --create-namespace --namespace consul --version "1.0.1" --values values.yaml --set global.datacenter=dc1 --kube-context $CLUSTER1_CONTEXT
$ export HELM_RELEASE_NAME1=cluster-01
```

```shell-session
$ helm install ${HELM_RELEASE_NAME1} hashicorp/consul --create-namespace --namespace consul --version "1.0.1" --values values.yaml --set global.datacenter=dc1 --kube-context $CLUSTER1_CONTEXT
```

1. In `cluster-02`, run the following commands:

```shell-session
$ export HELM_RELEASE_NAME=cluster-02
$ helm install ${HELM_RELEASE_NAME} hashicorp/consul --create-namespace --namespace consul --version "1.0.1" --values values.yaml --set global.datacenter=dc2 --kube-context $CLUSTER2_CONTEXT
$ export HELM_RELEASE_NAME2=cluster-02
```

```shell-session
$ helm install ${HELM_RELEASE_NAME2} hashicorp/consul --create-namespace --namespace consul --version "1.0.1" --values values.yaml --set global.datacenter=dc2 --kube-context $CLUSTER2_CONTEXT
```

### Configure the mesh gateway mode for traffic between services
Expand All @@ -81,9 +89,9 @@ In Kubernetes deployments, you can configure mesh gateways to use `local` mode s
```
</CodeBlockConfig>
```shell-session
$ kubectl --context $CLUSTER1_CONTEXT apply -f proxy-defaults.yaml
$ kubectl --context $CLUSTER1_CONTEXT apply -f proxy-defaults.yaml
```

1. In `cluster-02` apply the following `ProxyDefaults` CRD to configure the mesh gateway mode.
Expand All @@ -101,9 +109,9 @@ In Kubernetes deployments, you can configure mesh gateways to use `local` mode s
```

</CodeBlockConfig>

```shell-session
$ kubectl --context $CLUSTER2_CONTEXT apply -f proxy-defaults.yaml
$ kubectl --context $CLUSTER2_CONTEXT apply -f proxy-defaults.yaml
```

## Create a peering token
Expand All @@ -117,17 +125,17 @@ Every time you generate a peering token, a single-use secret for establishing th
<CodeBlockConfig filename="acceptor.yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: PeeringAcceptor
metadata:
name: cluster-02 ## The name of the peer you want to connect to
spec:
peer:
secret:
name: "peering-token"
key: "data"
backend: "kubernetes"
```
apiVersion: consul.hashicorp.com/v1alpha1
kind: PeeringAcceptor
metadata:
name: cluster-02 ## The name of the peer you want to connect to
spec:
peer:
secret:
name: "peering-token"
key: "data"
backend: "kubernetes"
```

</CodeBlockConfig>

Expand Down Expand Up @@ -158,16 +166,16 @@ Next, use the peering token to establish a secure connection between the cluster
<CodeBlockConfig filename="dialer.yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: PeeringDialer
metadata:
name: cluster-01 ## The name of the peer you want to connect to
spec:
peer:
secret:
name: "peering-token"
key: "data"
backend: "kubernetes"
apiVersion: consul.hashicorp.com/v1alpha1
kind: PeeringDialer
metadata:
name: cluster-01 ## The name of the peer you want to connect to
spec:
peer:
secret:
name: "peering-token"
key: "data"
backend: "kubernetes"
```

</CodeBlockConfig>
Expand Down Expand Up @@ -385,11 +393,13 @@ Before you can call services from peered clusters, you must set service intentio

1. Run the following command in `frontend` and then check the output to confirm that you peered your clusters successfully.

<CodeBlockConfig highlight="31">

```shell-session
$ kubectl --context $CLUSTER1_CONTEXT exec -it $(kubectl --context $CLUSTER1_CONTEXT get pod -l app=frontend -o name) -- curl localhost:9090
```

<CodeBlockConfig highlight="29" hideClipboard>

```json
{
"name": "frontend",
"uri": "/",
Expand Down Expand Up @@ -425,7 +435,7 @@ Before you can call services from peered clusters, you must set service intentio
}
```

</CodeBlockConfig>
</CodeBlockConfig>

### Authorize service reads with ACLs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: >-

This usage topic describes how to configure the `service-resolver` custom resource definition (CRD) to set up and manage L7 traffic between services that have an existing cluster peering connection in Consul on Kubernetes deployments.

For general guidance for managing L7 traffic with cluster peering, refer to [Manage L7 traffic with cluster peering](/consul/docs/connect/cluster-peering/usage/peering-traffic-management).

## Service resolvers for redirects and failover

When you use cluster peering to connect datacenters through their admin partitions, you can use [dynamic traffic management](/consul/docs/connect/l7-traffic) to configure your service mesh so that services automatically forward traffic to services hosted on peer clusters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,32 @@ This usage topic describes how to manage cluster peering connections on Kubernet

After you establish a cluster peering connection, you can get a list of all active peering connections, read a specific peering connection's information, and delete peering connections.

For general guidance for managing cluster peering connections, refer to [Manage L7 traffic with cluster peering](/consul/docs/connect/cluster-peering/usage/peering-traffic-management).

## Reset a peering connection

To reset the cluster peering connection, you need to generate a new peering token from the cluster where you created the `PeeringAcceptor` CRD. The only way to create or set a new peering token is to manually adjust the value of the annotation `consul.hashicorp.com/peering-version`. Creating a new token causes the previous token to expire.

1. In the `PeeringAcceptor` CRD, add the annotation `consul.hashicorp.com/peering-version`. If the annotation already exists, update its value to a higher version.

<CodeBlockConfig filename="acceptor.yml" highlight="6" hideClipboard>

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: PeeringAcceptor
metadata:
name: cluster-02
annotations:
consul.hashicorp.com/peering-version: "1" ## The peering version you want to set, must be in quotes
spec:
peer:
secret:
name: "peering-token"
key: "data"
backend: "kubernetes"
```
</CodeBlockConfig>
<CodeBlockConfig filename="acceptor.yml" highlight="6" hideClipboard>

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
kind: PeeringAcceptor
metadata:
name: cluster-02
annotations:
consul.hashicorp.com/peering-version: "1" ## The peering version you want to set, must be in quotes
spec:
peer:
secret:
name: "peering-token"
key: "data"
backend: "kubernetes"
```
</CodeBlockConfig>
1. After updating `PeeringAcceptor`, repeat all of the steps to [establish a new peering connection](/consul/docs/k8s/connect/cluster-peering/usage/establish-peering).

Expand Down

0 comments on commit 6863c6e

Please sign in to comment.