docs: Clean up k8s cluster peering instructions (#15592)

This commit is contained in:
David Yu 2022-11-29 12:58:13 -06:00 committed by GitHub
parent 95dc0c7b30
commit 54a3714543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,26 +47,20 @@ Complete the following procedure after you have provisioned a Kubernetes cluster
$ export CLUSTER2_CONTEXT=<CONTEXT for second 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"> <CodeBlockConfig filename="values.yaml">
```yaml ```yaml
global: global:
name: consul name: consul
image: "hashicorp/consul:1.14.0" image: "hashicorp/consul:1.14.1"
peering: peering:
enabled: true enabled: true
tls: tls:
enabled: true enabled: true
connectInject:
enabled: true
dns:
enabled: true
enableRedirection: true
meshGateway: meshGateway:
enabled: true enabled: true
replicas: 1
``` ```
</CodeBlockConfig> </CodeBlockConfig>
@ -82,7 +76,7 @@ Install Consul on Kubernetes by using the CLI to apply `values.yaml` to each clu
``` ```
```shell-session ```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: 1. In `cluster-02`, run the following commands:
@ -92,7 +86,7 @@ Install Consul on Kubernetes by using the CLI to apply `values.yaml` to each clu
``` ```
```shell-session ```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 ## Create a peering connection for Consul on Kubernetes
@ -121,6 +115,10 @@ If the servers in `cluster-01` are not directly routable from the dialing cluste
</CodeBlockConfig> </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`. 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`.
<CodeBlockConfig filename="mesh.yaml"> <CodeBlockConfig filename="mesh.yaml">
@ -137,6 +135,10 @@ If the servers in `cluster-01` are not directly routable from the dialing cluste
</CodeBlockConfig> </CodeBlockConfig>
```shell-session
$ kubectl --context $CLUSTER2_CONTEXT apply -f mesh.yaml
```
### Create a peering token ### Create a peering token
Peers identify each other using the `metadata.name` values you establish when creating the `PeeringAcceptor` and `PeeringDialer` CRDs. Peers identify each other using the `metadata.name` values you establish when creating the `PeeringAcceptor` and `PeeringDialer` CRDs.
@ -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. 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 ```yaml
apiVersion: consul.hashicorp.com/v1alpha1 apiVersion: consul.hashicorp.com/v1alpha1
@ -226,9 +228,13 @@ like to configure the mesh gateway mode such that this traffic always leaves thr
</CodeBlockConfig> </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. 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 ```yaml
apiVersion: consul.hashicorp.com/v1alpha1 apiVersion: consul.hashicorp.com/v1alpha1
@ -242,6 +248,10 @@ like to configure the mesh gateway mode such that this traffic always leaves thr
</CodeBlockConfig> </CodeBlockConfig>
```shell-session
$ kubectl --context $CLUSTER1_CONTEXT apply -f proxy-defaults.yaml
```
### Export services between clusters ### Export services between clusters
The examples described in this section demonstrate how to export a service named `backend`. You should change instances of `backend` in the example code to the name of the service you want to export. The examples described in this section demonstrate how to export a service named `backend`. You should change instances of `backend` in the example code to the name of the service you want to export.
@ -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. 1. Deploy the `backend` service to the second cluster.
```shell-session ```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. 1. In `cluster-02`, create an `ExportedServices` custom resource.
<CodeBlockConfig filename="exportedsvc.yaml"> <CodeBlockConfig filename="exported-service.yaml">
```yaml ```yaml
apiVersion: consul.hashicorp.com/v1alpha1 apiVersion: consul.hashicorp.com/v1alpha1
@ -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. 1. Apply the `ExportedServices` resource to the second cluster.
```shell-session ```shell-session
$ kubectl apply --context $CLUSTER2_CONTEXT --filename exportedsvc.yaml $ kubectl --context $CLUSTER2_CONTEXT apply --filename exported-service.yaml
``` ```
### Authorize services for peers ### Authorize services for peers