23 Tenant

Tenant

What a person may do on Klok follows their groups in Keycloak (KlokAuth): which tenant they work in, which domains, and whether they own, administer or develop. Tenant is where a tenant's owners and admins manage those groups without the Keycloak admin console, divide the tenant into domains, appoint each domain's owner, and check what the tenant's environment has and lacks. Every change of a person's roles goes straight to Keycloak and sets their GitLab access to match. The tenant's own owners and admins are not made here: they are listed in Git, because making someone the admin of a tenant is the strongest grant a tenant has, and it gets a review and a record.

  • In the menu: Manage → Tenant (/tenant-admin/people), with the tabs People, Domains and Environment doctor, and All tenants for platform staff; My Profile is in the menu under your avatar (/account/home/user-profile)
  • For: the tenant's owners and admins: a Tenant Owner or Tenant Admin manages the whole tenant, a Domain Owner or Domain Admin the developers of their own domains. Developers do not see the Tenant section. All tenants is for platform staff. My Profile is for everyone.
  • Reads: Keycloak (the people and their groups, the owners of the tenant and of each domain, every time a page opens), GitLab (the domains' groups and everyone's memberships), klok.dev's database (the domains and their provisioning runs), and for the doctor GitLab, Vault, Keycloak, the broker and the cluster

What You See

Tab What it shows What you may do there
People Everyone with a role in the tenant: name, username and e-mail, their roles (Tenant Owner, Tenant Admin, Tenant Developer, Domain Owner · hr, Domain Admin · hr, Domain Developer · finance), whether the account is Active or Invited, and when it was created. Owners are shown in green; pointing at the tag says Main contact of … Add person, Sync GitLab, and on each row ⋮ → Change and ⋮ → Remove from <tenant>
Domains The tenant's owners above the list, then the domains with their slug, their Owners, their two GitLab groups (datamodels and integrations) and when they last changed. A domain without an owner says None yet: appoint one on People; common and public say The tenant's. A domain's page has its groups, its latest provisioning run, its datamodels and integrations New domain and Sync now; Delete domain on a domain's Settings tab
Environment doctor What the tenant's environment has and lacks after Check now: To do, worst first, each with who fixes it, and In place, folded Check now, then hand each item to whoever fixes it
All tenants (platform staff) Every tenant with its GitLab root group, its last Ensure report in a word and its latest provisioning run Create tenant, Ensure all tenants, and on each row Ensure missing, Onboard in Git and Show steps

What the roles give in general is on Access: Roles, Groups, And Tenants. The notice above the People list says why Tenant Owner and Tenant Admin are shown there but never given: they are set in Git by a platform admin.

Owners Are The Main Contact

Every tenant and every domain should have one or more owners: the people a reader of its documentation, a requester of its broker topics and the platform itself turn to. An owner is always an admin of the same scope too, so an owner may do everything an admin may.

Owner of Appointed by Where it is recorded
The tenant (Tenant Owner) a platform admin, with Onboard in Git on All tenants owners in the tenant's entry of tenants.yml in klok/environment/klok-environment-setup, applied to Keycloak by Ansible
A domain (Domain Owner) the tenant's owners and admins (and platform admins) on People; a domain admin cannot the domain's owners group in Keycloak, /tenants/<tenant>/domains/<domain>/owners

The owners are named where people look for a contact: on Domains, in the Contact row of an integration project's and a datamodel's Overview, and under Main contact of on their own My Profile. They also hear what concerns their tenant or domain, as messages from klok.dev in their owners mailbox in Secure Mail: someone asking for access, role changes on People made by someone else, broker access requests for their namespaces, documentation visibility changes made by someone else, and findings of Ensure that a person has to fix. A scope without an owner gets these in its admins mailbox instead.

Walkthrough: Give Someone A Role

  1. Tenant → People → Add person.

  2. Write their Username. It becomes both their KlokAuth login and their GitLab username. For someone new, also write their e-mail address and names; someone who already has an account, in this or another tenant, is added by username alone and keeps their account.

  3. Tick at least one role, for example Domain Developer on the finance line, and choose Add person.

  4. klok.dev creates the account in Keycloak with its groups. KlokAuth mails a new person a link to choose a password, valid for a week, and the list shows them as Invited until they have confirmed their address. Their GitLab access follows at once; a person without a GitLab user gets one, linked to their KlokAuth login.

  5. To change someone's roles later, use ⋮ → Change on their row; ⋮ → Remove from <tenant> takes away the roles you may take away, with their GitLab access in the tenant. With Delete their KlokAuth account ticked, the default, an account left with no access anywhere is deleted, and its GitLab user is blocked, not deleted.

If someone changed a group in the Keycloak console, or a membership directly in GitLab, Sync GitLab sets everyone's GitLab access from their roles again and says whose it changed.

Walkthrough: Appoint A Domain Owner

A tenant owner or tenant admin appoints the owner of a domain, for example when a new domain has none yet:

  1. Tenant → People, and ⋮ → Change on the person's row.
  2. Tick Domain Owner on the domain's line. Domain Admin is ticked with it, because an owner is always an admin of their domain; unticking Domain Admin unticks Domain Owner as well.
  3. Save. The person's row shows Domain Owner · <domain> in green, Domains names them as the domain's owner, and in GitLab they become Maintainer in the domain's two groups.

A change that takes away the last owner of a domain warns before you save, and the page says so after: appoint another owner, so that someone stays the domain's main contact. When someone who is not one of its owners changes roles in a domain, the domain's owners get a message about it.

Walkthrough: Add A Domain

A domain divides the tenant, such as hr or finance: its own datamodels, integration projects and people, and its own part of the broker. A tenant owner or admin adds one:

  1. Tenant → Domains → New domain. Give it a name, such as Purchasing, and a line about what it owns, then Create domain.

  2. klok.dev creates the domain's two GitLab groups, klok/datamodel/domain/purchasing and klok/integration/domain/purchasing, and opens the domain's page, where the Latest provisioning run lists the rest: the domain's owners, admins and developers groups in Keycloak, its Vault policy and path, its OpenSearch role and role mapping, and its broker namespace.

  3. What klok.dev may not do itself becomes a task for a person, with written instructions and an Open task link. The broker namespace klok/purchasing is always one: klok.dev opens a merge request that adds it to the tenant's Pulsar file in klok/environment/klok-environment-setup, and a person merges it and applies it with Ansible. In production today the Vault and OpenSearch steps are tasks for a person too, since klok.dev holds no credentials for them.

  4. The new domain has no owner yet: Domains says None yet: appoint one on People, and Ensure reports it until a tenant owner or admin appoints one (Appoint A Domain Owner above).

Broker shows the namespace as on broker once the playbook has made it. A domain made by hand, as the two groups in GitLab, is registered by Sync now.

Walkthrough: Check The Tenant's Environment

  1. Tenant → Environment doctor → Check now. The check reads GitLab, Vault, Keycloak, the broker and the cluster, takes up to a minute and changes nothing.
  2. To do lists what is not in place, and Fix says who fixes each item: klok.dev, which makes it the next time a platform admin runs Ensure missing for the tenant, or A person, with the command to run, dry run first, and a How link to the runbook step.
  3. Not checked means klok.dev could not look, for example because it has no rights in the cluster. It is never counted as done.

The doctor also names a tenant or a domain without an owner, and a tenant owner who is not an admin. A platform admin fixes the tenant's in tenants.yml, a tenant owner or admin a domain's on People. The owners hear of these findings in their owners mailbox when the set of findings changes.

The last report stays in klok.dev's memory until klok.dev restarts; it is not stored anywhere else yet (frontend-klok-dev#69).

All Tenants And My Profile

All tenants is for platform staff. It lists every tenant, every GitLab root group counts as one, with its last Ensure report and its latest provisioning run. A row's menu has Ensure missing, which makes what the tenant lacks and is not a check only, Onboard in Git, which is also where someone is made a tenant admin and, with Owner ticked, a tenant owner, and Show steps. Not checked in the Ensure column means klok.dev holds no Ensure report for the tenant, for example since it restarted.

My Profile shows who you are, your working tenant and your roles by name, the way every page of klok.dev reads them from your Keycloak groups, what you are the main contact of when you are an owner, and your sessions. Nothing on it is edited in klok.dev: Keycloak account and the links in each part open the Keycloak account console.

What Happens In Git

In klok.dev What it writes, and where Merged or approved by By hand
Add person, ⋮ → Change, ⋮ → Remove from <tenant>, appointing a domain owner included The person's groups under /tenants/<tenant>/… in Keycloak (realm klok), an account when they are new, and their direct memberships in the tenant's GitLab groups; nothing in Git. The owners of each scope the change touched get a message when someone else made it Nobody: it takes effect at once Keycloak's admin console (Users → the person → Groups), the groups' Members pages in GitLab, then Sync GitLab
Sync GitLab Everyone's direct memberships in the tenant's managed GitLab groups, set from their roles — The groups' Members pages in GitLab
Making someone a tenant owner or admin (All tenants → ⋮ → Onboard in Git, platform staff) A merge request in klok/environment/klok-environment-setup that adds the username to the tenant's admins in tenants.yml, and to owners as well when Owner is ticked, and someone new to keycloak_people in keycloak.yml A person merges it and runs ansible-playbook playbooks/keycloak.yml --check --diff, then without --check; then Sync GitLab The same lines in a merge request of your own
New domain The two GitLab groups at once; a provisioning run in klok.dev's database for the owners, admins and developers groups in Keycloak, the Vault policy and path and the OpenSearch role; a merge request that adds the namespace to the tenant's Pulsar file The namespace: a person merges it and runs ansible-playbook playbooks/pulsar.yml --check --diff, then without --check The two groups in GitLab and Sync now; the namespace in the Pulsar file in a merge request
Check now Nothing: it only reads — Each item's fix names the playbook to run
My Profile Nothing — —

See What klok.dev Does In Git for every page.

Who Does What

Automation Kloker You
klok.dev sets everyone's GitLab access from their roles, creates a new domain's groups in GitLab and Keycloak, opens the namespace merge request, and checks the environment; Ensure missing, run by a platform admin, makes what a tenant lacks and tells the owners what only a person can fix Nothing on these pages; Ask Kloker beside the page answers questions about it A tenant owner or admin gives and takes roles, appoints the domains' owners and creates domains. Platform staff make someone a tenant owner or admin in Git, merge the merge requests in klok-environment-setup and run the playbooks, and fix what the doctor gives to a person

See You, The Automation And Kloker.

How It Connects

The other pages follow the same groups: a domain role sees its own domains and the shared common and public, a tenant role sees the whole tenant. A new domain is where new Datamodels and Integration Projects of that domain are created, and its namespace is where their topics go on the Broker, whose access requests reach the domain's owners. The tenant's environment, which the doctor checks, is what the Repositories of the tenant are built and deployed with. This is the last page of the chapter; Why Klok Is Built This Way starts it.

Read More