Skip to content

Commit

Permalink
Backport of docs: Clean up k8s cluster peering instructions into rele…
Browse files Browse the repository at this point in the history
…ase/1.14.x (#15601)



Co-authored-by: David Yu <dyu@hashicorp.com>
  • Loading branch information
hc-github-team-consul-core and David Yu authored Nov 29, 2022
1 parent e7f8505 commit 9a235cb
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions website/content/docs/connect/cluster-peering/k8s.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,20 @@ Complete the following procedure after you have provisioned a Kubernetes cluster
$ export CLUSTER2_CONTEXT=<CONTEXT for second Kubernetes cluster>
```

1. To establish cluster peering through Kubernetes, create a `values.yaml` file with the following Helm values.
1. To establish cluster peering through Kubernetes, create a `values.yaml` file with the following Helm values. **NOTE:** Mesh Gateway replicas are defaulted to 1 replica, and could be adjusted using the `meshGateway.replicas` value for higher availaibity.

<CodeBlockConfig filename="values.yaml">

```yaml
global:
name: consul
image: "hashicorp/consul:1.14.0"
image: "hashicorp/consul:1.14.1"
peering:
enabled: true
tls:
enabled: true
connectInject:
enabled: true
dns:
enabled: true
enableRedirection: true
meshGateway:
enabled: true
replicas: 1
```
</CodeBlockConfig>
Expand All @@ -82,7 +76,7 @@ Install Consul on Kubernetes by using the CLI to apply `values.yaml` to each clu
```

```shell-session
$ helm install ${HELM_RELEASE_NAME} hashicorp/consul --create-namespace --namespace consul --version "1.0.0" --values values.yaml --kube-context $CLUSTER1_CONTEXT
$ 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
```

1. In `cluster-02`, run the following commands:
Expand All @@ -92,7 +86,7 @@ Install Consul on Kubernetes by using the CLI to apply `values.yaml` to each clu
```

```shell-session
$ helm install ${HELM_RELEASE_NAME} hashicorp/consul --create-namespace --namespace consul --version "1.0.0" --values values.yaml --set global.datacenter=dc2 --kube-context $CLUSTER2_CONTEXT
$ 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
```

## Create a peering connection for Consul on Kubernetes
Expand Down Expand Up @@ -120,6 +114,10 @@ If the servers in `cluster-01` are not directly routable from the dialing cluste
```

</CodeBlockConfig>

```shell-session
$ kubectl --context $CLUSTER1_CONTEXT apply -f mesh.yaml
```

1. In `cluster-02` apply the `Mesh` custom resource so that the servers for `cluster-02` will use their local mesh gateway to dial the servers for `cluster-01`.

Expand All @@ -136,6 +134,10 @@ If the servers in `cluster-01` are not directly routable from the dialing cluste
```

</CodeBlockConfig>

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

### Create a peering token

Expand Down Expand Up @@ -212,7 +214,7 @@ like to configure the mesh gateway mode such that this traffic always leaves thr

1. In `cluster-01` apply the following `ProxyDefaults` CRD to configure the mesh gateway mode.

<CodeBlockConfig filename="proxydefaults.yaml">
<CodeBlockConfig filename="proxy-defaults.yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
Expand All @@ -225,10 +227,14 @@ like to configure the mesh gateway mode such that this traffic always leaves thr
```

</CodeBlockConfig>

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

1. In `cluster-02` apply the following `ProxyDefaults` CRD to configure the mesh gateway mode.

<CodeBlockConfig filename="proxydefaults.yaml">
<CodeBlockConfig filename="proxy-defaults.yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
Expand All @@ -241,6 +247,10 @@ like to configure the mesh gateway mode such that this traffic always leaves thr
```

</CodeBlockConfig>

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

### Export services between clusters

Expand Down Expand Up @@ -309,12 +319,12 @@ The examples described in this section demonstrate how to export a service named
1. Deploy the `backend` service to the second cluster.

```shell-session
$ kubectl apply --context $CLUSTER2_CONTEXT --filename backend.yaml
$ kubectl --context $CLUSTER2_CONTEXT apply --filename backend.yaml
```

1. In `cluster-02`, create an `ExportedServices` custom resource.

<CodeBlockConfig filename="exportedsvc.yaml">
<CodeBlockConfig filename="exported-service.yaml">

```yaml
apiVersion: consul.hashicorp.com/v1alpha1
Expand All @@ -333,7 +343,7 @@ The examples described in this section demonstrate how to export a service named
1. Apply the `ExportedServices` resource to the second cluster.

```shell-session
$ kubectl apply --context $CLUSTER2_CONTEXT --filename exportedsvc.yaml
$ kubectl --context $CLUSTER2_CONTEXT apply --filename exported-service.yaml
```

### Authorize services for peers
Expand Down

0 comments on commit 9a235cb

Please sign in to comment.