|
| 1 | +--- |
| 2 | +title: 'Federate a zone control plane' |
| 3 | +description: 'Learn how to federate a {{site.base_product}} zone control plane into a multi-zone deployment. This guide walks through setting up a global control plane, copying resources, connecting zones, and verifying policy synchronization.' |
| 4 | + |
| 5 | +content_type: how_to |
| 6 | +permalink: /mesh/federate/ |
| 7 | +bread-crumbs: |
| 8 | + - /mesh/ |
| 9 | +related_resources: |
| 10 | + - text: Add a builtin gateway |
| 11 | + url: '/mesh/add-builtin-gateway/' |
| 12 | + - text: 'Producer and Consumer policies' |
| 13 | + url: /mesh/consumer-producer-policies/ |
| 14 | + - text: 'Multi-zone deployment' |
| 15 | + url: '/mesh/mesh-multizone-service-deployment/' |
| 16 | + |
| 17 | +min_version: |
| 18 | + mesh: '2.6' |
| 19 | + |
| 20 | +products: |
| 21 | + - mesh |
| 22 | + |
| 23 | +tldr: |
| 24 | + q: How can I federate a zone control plane in a multi-zone deployment? |
| 25 | + a: | |
| 26 | + 1. Create a zone control plane and a global control plane in separate Kubernetes clusters. |
| 27 | + 1. Copy resources from the zone control plane to the global control plane. |
| 28 | + 1. Connect the two control planes by updating the zone control plane's Helm deployment. |
| 29 | +
|
| 30 | +prereqs: |
| 31 | + inline: |
| 32 | + - title: Helm |
| 33 | + include_content: prereqs/helm |
| 34 | + - title: Install kumactl |
| 35 | + include_content: prereqs/tools/kumactl |
| 36 | + - title: A running Kubernetes cluster |
| 37 | + include_content: prereqs/kubernetes/mesh-cluster |
| 38 | + - title: Install {{site.mesh_product_name}} with demo configuration |
| 39 | + include_content: prereqs/kubernetes/mesh-quickstart |
| 40 | + |
| 41 | +cleanup: |
| 42 | + inline: |
| 43 | + - title: Clean up kumactl control plane |
| 44 | + include_content: cleanup/products/kumactl |
| 45 | + - title: Clean up {{site.mesh_product_name}} resources |
| 46 | + content: | |
| 47 | + To clean up your environment, remove the Docker containers, network, temporary directory, and the control plane configuration. Run the following command: |
| 48 | +
|
| 49 | + ```sh |
| 50 | + minikube delete --profile mesh-zone |
| 51 | + minikube delete --profile mesh-global |
| 52 | + ``` |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## Start a new Kubernetes cluster for the global control plane |
| 57 | + |
| 58 | +We've created a zone control plane in the [prerequisites](#install-kong-mesh-with-demo-configuration), now we need a global control plane. The zone a global control planes can't be in the same Kubernetes cluster, so we must start by creating a new cluster: |
| 59 | +```sh |
| 60 | +minikube start -p mesh-global |
| 61 | +``` |
| 62 | + |
| 63 | +Use the minikube tunnel feature to provision local load balancer addresses: |
| 64 | +```sh |
| 65 | +nohup minikube tunnel -p mesh-global & |
| 66 | +``` |
| 67 | + |
| 68 | +## Deploy the global control plane |
| 69 | + |
| 70 | +Run the following command to deploy a global control plane: |
| 71 | + |
| 72 | +```sh |
| 73 | +helm install --kube-context mesh-global --create-namespace --namespace kong-mesh-system \ |
| 74 | +--set kuma.controlPlane.mode=global \ |
| 75 | +--set kuma.controlPlane.defaults.skipMeshCreation=true \ |
| 76 | +kong-mesh kong-mesh/kong-mesh |
| 77 | +``` |
| 78 | + |
| 79 | +We'll skip the default mesh creation since we'll bring the mesh from the zone control plane in the next steps. |
| 80 | + |
| 81 | +## Set up kumactl |
| 82 | + |
| 83 | +Before we start migrating, we need to set up kumactl, which we'll use to export resources. |
| 84 | + |
| 85 | +1. Run the following command to expose the control plane's API server. We'll need this to access kumactl: |
| 86 | + |
| 87 | + ```sh |
| 88 | + kubectl --context mesh-zone port-forward svc/kong-mesh-control-plane -n kong-mesh-system 5681:5681 |
| 89 | + ``` |
| 90 | + |
| 91 | +1. In a new terminal, check that kumactl is installed and that its directory is in your path: |
| 92 | + |
| 93 | + ```sh |
| 94 | + kumactl |
| 95 | + ``` |
| 96 | + |
| 97 | + If the command is not found: |
| 98 | + |
| 99 | + 1. Make sure that kumactl is [installed](#install-kumactl) |
| 100 | + 1. Add the {{site.mesh_product_name}} binaries directory to your path: |
| 101 | + |
| 102 | + ```sh |
| 103 | + export PATH=$PATH:$(pwd)/{{site.mesh_product_name_path}}-{{site.data.mesh_latest.version}}/bin |
| 104 | + ``` |
| 105 | + |
| 106 | +1. Export your admin token and add your control plane: |
| 107 | + |
| 108 | + ```sh |
| 109 | + export ZONE_USER_ADMIN_TOKEN=$(kubectl --context mesh-zone get secrets -n kong-mesh-system admin-user-token -o json | jq -r .data.value | base64 -d) |
| 110 | + kumactl config control-planes add \ |
| 111 | + --address http://localhost:5681 \ |
| 112 | + --headers "authorization=Bearer $ZONE_USER_ADMIN_TOKEN" \ |
| 113 | + --name "my-cp" \ |
| 114 | + --overwrite |
| 115 | + ``` |
| 116 | + |
| 117 | +## Copy resources from the zone control plane to the global control plane |
| 118 | + |
| 119 | +1. Export the external IP to use to access the global control plane: |
| 120 | + ```sh |
| 121 | + export EXTERNAL_IP=host.minikube.internal |
| 122 | + ``` |
| 123 | + |
| 124 | + {:.info} |
| 125 | + > If you're not using minikube, you can find your external IP with this command: |
| 126 | + > ```sh |
| 127 | + > export EXTERNAL_IP=$(kubectl --context mesh-global get svc -n kong-mesh-system kong-mesh-global-zone-sync -o jsonpath='{.status.loadBalancer.ingress[0].ip}') |
| 128 | + > ``` |
| 129 | +
|
| 130 | +1. Export the zone control plane resources: |
| 131 | +
|
| 132 | + ```sh |
| 133 | + kumactl export --profile federation-with-policies --format kubernetes > resources.yaml |
| 134 | + ``` |
| 135 | +
|
| 136 | +1. Apply the resources to the global control plane: |
| 137 | +
|
| 138 | + ```sh |
| 139 | + kubectl apply --context mesh-global -f resources.yaml |
| 140 | + ``` |
| 141 | +
|
| 142 | +## Connect the control planes |
| 143 | +
|
| 144 | +Update the zone control plane's Helm deployment to configure the connection to the global control plane: |
| 145 | + |
| 146 | +```sh |
| 147 | +helm upgrade --kube-context mesh-zone --namespace kong-mesh-system \ |
| 148 | +--set kuma.controlPlane.mode=zone \ |
| 149 | +--set kuma.controlPlane.zone=zone-1 \ |
| 150 | +--set kuma.ingress.enabled=true \ |
| 151 | +--set kuma.controlPlane.kdsGlobalAddress=grpcs://$EXTERNAL_IP:5685 \ |
| 152 | +--set kuma.controlPlane.tls.kdsZoneClient.skipVerify=true \ |
| 153 | +kong-mesh kong-mesh/kong-mesh |
| 154 | +``` |
| 155 | + |
| 156 | +## Validate |
| 157 | + |
| 158 | +1. To validate the federation, start by port-forwarding the API service from the global control plane to port 15681 to avoid collision with previous port-forward: |
| 159 | + |
| 160 | + ```sh |
| 161 | + kubectl --context mesh-global port-forward svc/kong-mesh-control-plane -n kong-mesh-system 15681:5681 |
| 162 | + ``` |
| 163 | + |
| 164 | +1. In a browser, go to [http://127.0.0.1:15681/gui/](http://127.0.0.1:15681/gui/) to see the GUI. |
| 165 | + |
| 166 | + You should see: |
| 167 | + |
| 168 | + * A zone in list of zones |
| 169 | + * Policies, including the `MeshTrafficPermission` that we applied in the [prerequisites](#install-kong-mesh-with-demo-configuration) |
| 170 | + * Data plane proxies for the demo application that we installed in the [prerequisites](#install-kong-mesh-with-demo-configuration) |
| 171 | + |
| 172 | + It can take some time for these to appear, if you don't see them immediately, wait a few minutes and try again. |
| 173 | +
|
| 174 | +1. Create the `kong-mesh-demo` namespace in the global control plane: |
| 175 | +
|
| 176 | + ```sh |
| 177 | + kubectl --context mesh-global create namespace kong-mesh-demo |
| 178 | + ``` |
| 179 | +
|
| 180 | +1. Apply a policy on the global control plane: |
| 181 | +
|
| 182 | + ```sh |
| 183 | + echo "apiVersion: kuma.io/v1alpha1 |
| 184 | + kind: MeshCircuitBreaker |
| 185 | + metadata: |
| 186 | + name: demo-app-to-redis |
| 187 | + namespace: kong-mesh-demo |
| 188 | + labels: |
| 189 | + kuma.io/mesh: default |
| 190 | + spec: |
| 191 | + targetRef: |
| 192 | + kind: Dataplane |
| 193 | + labels: |
| 194 | + app: demo-app |
| 195 | + to: |
| 196 | + - targetRef: |
| 197 | + kind: MeshService |
| 198 | + name: kv |
| 199 | + default: |
| 200 | + connectionLimits: |
| 201 | + maxConnections: 2 |
| 202 | + maxPendingRequests: 8 |
| 203 | + maxRetries: 2 |
| 204 | + maxRequests: 2" | kubectl --context mesh-global apply -f - |
| 205 | + ``` |
| 206 | +
|
| 207 | +1. Check that the policy is applied on the zone control plane: |
| 208 | + ```sh |
| 209 | + kubectl get --context mesh-zone meshcircuitbreakers -A |
| 210 | + ``` |
| 211 | +
|
| 212 | + You should get the following result: |
| 213 | + ```sh |
| 214 | + NAMESPACE NAME TARGETREF KIND TARGETREF NAME |
| 215 | + kong-mesh-system demo-app-to-redis-65xb45x2xfd5bf7f Dataplane |
| 216 | + kong-mesh-system mesh-circuit-breaker-all-default Mesh |
| 217 | + kong-mesh-system mesh-circuit-breaker-all-default-d6zfxc24v7449xfv Mesh |
| 218 | + ``` |
| 219 | + {:.no-copy-code} |
0 commit comments