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
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.shfollows the ordered migration steps. It tests the ingest gateway with forged cluster labels before it activates a spoke.verify.shchecks the isolation and the suspension of a spoke through the Querdian proxy.- The container VM needs about 8 GiB of memory, and
up.shneeds 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 thedockershim. 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) and8081(policy dashboard). The single-cluster quickstart uses the same three ports, so remove it first (hack/quickstart/down.sh).KEYCLOAK_PORTchanges only the port of Keycloak. - Free local ports
18080,19090,13100and13200for the port-forwards of the scripts. - Internet access.
up.shpulls 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 afterdown.sh, so the next run does not download them again. To remove them, runbash -c 'source hack/quickstart-multicluster/lib.sh; docker rmi $(hub_images)'. This command also removes common images such asbusybox, which other projects on the host can use.
Users#
| User | Password | Group | Data that the user sees |
|---|---|---|---|
| alice | alice-demo | team-a | order-service of spoke-a |
| bob | bob-demo | team-b | order-service of spoke-b |
| hana | hana-demo | team-hub | order-service of the hub |
| sam | sam-demo | sre | all namespaces of both spokes, not the hub |
| carol | carol-demo | platform-admins | everything 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#
- Open http://localhost:3000.
- Select Sign in with Keycloak and log in as alice.
- In Explore, select Prometheus (via Querdian).
- Run
count by (cluster, namespace) (demo_requests_total). The result shows onlyspoke-a,order-service. - 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#
- Open the policy dashboard on http://localhost:8081.
- Open Policies. It shows the origin of each policy:
hub, or the spoke cluster with the kind, namespace and name of the source object. - Open Access and enter the group
team-a,team-b,team-huborsre.
Suspend a spoke#
On the hub, suspend spoke-a:
kubectl --context kind-querdian-hub patch spokecluster spoke-a --type merge -p '{"spec":{"suspended":true}}'Query as alice. The queries of alice now get
403with the messagethe policy source of this grant has expired. The dashboard shows the spoke policy as expired. bob, sam and carol are not affected.Set
"suspended":falseagain. 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
SpokeClusterandSpokePolicyobjects; - the suspension and the unsuspension of spoke-a;
- Grafana and its data sources.
See Automatic verification for the full list.
If a step fails#
| Symptom | Cause 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 fails | The 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 sync | Examine 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 data | Examine 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 Docker | The address of the hub node is in the server certs. Run down.sh, then up.sh again. |