This page is for the main branch. It can describe changes that are not in a release. Open the v0.1.2 documentation

Multi-cluster quickstart

Source: docs/quickstart-multicluster.md · Edit on GitHub

This demo shows multi-cluster enforcement on one laptop, with one hub and two spoke kind clusters.

In short:

  • The hub has the backends, Keycloak, Grafana and Querdian. The two spokes run only the Querdian agent, and they send their telemetry to the hub.
  • All three clusters have a namespace with the same name, order-service. A different team owns it in each cluster, and each team sees only the data of its own cluster.
  • up.sh follows the ordered migration steps. It tests the ingest gateway with forged cluster labels before it activates a spoke.
  • verify.sh checks the isolation and the suspension of a spoke through the Querdian proxy.
  • The container VM needs about 8 GiB of memory, and up.sh needs about 8 to 20 minutes. These values are estimates.

Demo only. Keycloak runs in dev mode over plain HTTP with known passwords. All CA keys are in one directory on the laptop. The ingest gateway is a demo pattern, not a part of Querdian. The pods of the spokes can get access to Keycloak, Grafana and the dashboard of the hub (see limits of the gateway). Do not use any of it in production. The multi-cluster feature is alpha.

This demo uses the stack of the single-cluster quickstart: read it first. The multi-cluster quickstart reference gives the details: options, topology, certificates, the ingest gateway, the ordered setup and the checks.

Run#

hack/quickstart-multicluster/up.sh       # three clusters and the ordered setup, ends with the URLs
hack/quickstart-multicluster/verify.sh   # automatic checks through the Querdian proxy
hack/quickstart-multicluster/down.sh     # removes the clusters, the certs and the built image

up.sh sets the current kubectl context to the hub. For the environment variables, see Options.

Requirements#

  • The tools of the single-cluster quickstart: kind, kubectl, helm, make, curl, jq, and Docker or Podman with the docker shim.
  • openssl (OpenSSL 1.1 or later; LibreSSL was not tested).
  • Bash 3.2 or later. The scripts do not use features of later versions.
  • A container VM with 8 GiB of memory and 4 CPUs or more, and about 6 GiB of disk space (estimates, see resources).
  • Free host ports 8080 (Keycloak), 3000 (Grafana) and 8081 (policy dashboard). The single-cluster quickstart uses the same three ports, so remove it first (hack/quickstart/down.sh). KEYCLOAK_PORT changes only the port of Keycloak.
  • Free local ports 18080, 19090, 13100 and 13200 for the port-forwards of the scripts.
  • Internet access. up.sh pulls the images from Docker Hub and quay.io one time on the host, and loads them into the kind nodes. The images stay on the host after down.sh, so the next run does not download them again. To remove them, run bash -c 'source hack/quickstart-multicluster/lib.sh; docker rmi $(hub_images)'. This command also removes common images such as busybox, which other projects on the host can use.

Users#

UserPasswordGroupData that the user sees
alicealice-demoteam-aorder-service of spoke-a
bobbob-demoteam-border-service of spoke-b
hanahana-demoteam-huborder-service of the hub
samsam-demosreall namespaces of both spokes, not the hub
carolcarol-demoplatform-adminseverything in tenant demo

alice and bob get their access from an AccessPolicy in their spoke. The other users get it from hub policies. See Policies.

Try it#

See the isolation in Grafana#

  1. Open http://localhost:3000.
  2. Select Sign in with Keycloak and log in as alice.
  3. In Explore, select Prometheus (via Querdian).
  4. Run count by (cluster, namespace) (demo_requests_total). The result shows only spoke-a, order-service.
  5. Log in as bob, hana and sam in private windows, and compare.

The four dashboards of the single-cluster quickstart are also available. They have no cluster variable. Thus a user with grants in several clusters sees the sum of those clusters. Each cluster has 24 hours of demo history (DEMO_HISTORY_HOURS), so the dashboards show data immediately. The pods of the history have the names <service>-history-<cluster>.

See the origin of the policies#

  1. Open the policy dashboard on http://localhost:8081.
  2. Open Policies. It shows the origin of each policy: hub, or the spoke cluster with the kind, namespace and name of the source object.
  3. Open Access and enter the group team-a, team-b, team-hub or sre.

Suspend a spoke#

  1. On the hub, suspend spoke-a:

    kubectl --context kind-querdian-hub patch spokecluster spoke-a --type merge -p '{"spec":{"suspended":true}}'
    
  2. Query as alice. The queries of alice now get 403 with the message the policy source of this grant has expired. The dashboard shows the spoke policy as expired. bob, sam and carol are not affected.

  3. Set "suspended":false again. The grants return after the next sync of the agent. The heartbeat of the demo is 15 seconds.

See the state on the hub and in the spokes#

kubectl --context kind-querdian-hub get spokeclusters,spokepolicies
kubectl --context kind-querdian-spoke-a -n order-service get accesspolicy   # Ready, written by the agent

Verify#

hack/quickstart-multicluster/verify.sh gets tokens for the five users and queries the Querdian proxy of the hub directly. It stops with a non-zero exit code if a check fails. It checks:

  • the isolation on all three backends;
  • the access of sam and carol;
  • the state of the SpokeCluster and SpokePolicy objects;
  • the suspension and the unsuspension of spoke-a;
  • Grafana and its data sources.

See Automatic verification for the full list.

If a step fails#

SymptomCause and correction
up.sh shows a WARNING for an image (“cannot pull”, “cannot save” or “cannot load”)The host could not pull the image, or could not load it into kind. An example is a multi-platform image with the containerd image store of Docker Desktop. The kind nodes pull that image themselves, one at a time, which is slower. The script continues.
up.sh failsThe script keeps the clusters and prints the pods that do not run in each cluster. CLEANUP_ON_FAILURE=1 deletes the clusters after a failure.
A collector or a kubelet fails with “too many open files” (Linux)Three kind clusters can reach the inotify limits of the host. Increase fs.inotify.max_user_instances and fs.inotify.max_user_watches as the kind known issues describe.
A spoke does not syncExamine the agent log (kubectl --context kind-querdian-spoke-a -n querdian logs deploy/querdian-agent) and the receiver log on the hub. 403 while the spoke is suspended is correct. See receiver HTTP statuses.
No spoke dataExamine the collector log in the spoke and the gateway log on the hub (kubectl --context kind-querdian-hub -n observability logs deploy/ingest-gateway). A TLS handshake error there shows a wrong cert or CA.
The hub node has a new address, for example after a restart of DockerThe address of the hub node is in the server certs. Run down.sh, then up.sh again.

Type to search the documentation for main.