# Placement delegation

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> A namespace administrator can let members set placement keys on cloud workstations, or refuse keys for everyone.


A namespace member sets only the keys of a cloud workstation that size it, label it or ask for a public address. The keys that place it and
shape its network come from the CloudIdentity. Placement delegation is how an administrator changes
that: let members set named keys, refuse keys for everyone, or let one person place one workstation.

[Keys you set and keys an administrator sets](https://docs-stg.ringleader.dev/workstations/providers/cloud/#keys-you-set-and-keys-an-administrator-sets)
explains the rule from a member's side.
[Keys a namespace member may set](https://docs-stg.ringleader.dev/reference/providers/images-keys/#keys-a-namespace-member-may-set)
lists the keys a member may set on each cloud. If you need no exception to that list, you are done.

## Three ways to change who may set a key

- **The `cloudconfig` right.** A writer who holds it sets any of these keys on the workstation in front
  of them. It comes in two forms. The `cloudconfig` verb on `workstations` is one, which `namespace-admin`
  holds, and `org-admin` holds in every namespace of the organization. `namespace-member` and
  `namespace-reader` do not. A `cloudconfig` Grant on one workstation is the other, and it lets its
  beneficiary place that workstation and no other.
- **The CloudIdentity's `allow` list.** It lets members set named keys of its own cloud on the workstations
  it selects.
- **The CloudIdentity's `deny` list.** It refuses named keys for everyone, a holder of the `cloudconfig`
  right included, and it wins over `allow`.

The key that names a workstation's runtime identity is the one exception to all three. Nobody sets it on a
workstation, and the CloudIdentity sets it. [Cloud runtime identities](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/runtime-identities/)
covers it.

## Allow and deny lists

`spec.providerConfigKeys` holds two lists of keys of the identity's own provider. Spell each key as
[Provider images and keys](https://docs-stg.ringleader.dev/reference/providers/images-keys/) does.

- **`allow`** lets a member set a key that is otherwise yours alone. It matches the key exactly as
  written, so `Zone` stays admin-only when you allow `zone`.
- **`deny`** refuses a key for every writer, and it works on a key a member may always set too. A key in
  both lists is denied. It matches without regard to capitals, and it covers a setting's other spelling:
  denying `region` also denies `location`, and denying `zone` also denies `availabilityZone`.

Applying a CloudIdentity refuses a key its provider does not have, and names the keys it does. A typo
in `deny` therefore cannot leave a key open. It also refuses a runtime-identity key in `allow`, because no one sets
those on a workstation: `serviceAccount` on `gcp`, `managedIdentity` on `azure` and `iamInstanceProfile`
on `aws`. The CloudIdentity sets them.

**A zone that a member may set through `allow` has to stay in the identity's region.** The
CloudIdentity's own `defaultProviderConfig` and `overrideProviderConfig` name that region, through a
region, a zone, or a full `gcp` subnetwork or `spec.subnet`. Ringleader refuses a zone outside it, and the
message names both regions. An identity that names no region refuses every zone, and so does any `azure` zone,
because Ringleader cannot read a region from one. A holder of the `cloudconfig` right sets any zone.
Allowing `region`, `location` or a subnet key lets the member choose the region too, so this check covers
`zone` alone.

## Scope of the lists

The lists apply to a write that adds or changes a key. Tightening `deny` leaves workstations that already
carry the key as they are, and a stop, start or restart is not judged at all.

A write that changes a workstation's labels is the exception. If the new labels select a different
CloudIdentity, Ringleader judges every key the workstation carries again under that identity's lists. A
workstation cannot move into an identity that denies a key it holds, or out of the identity whose `allow`
opened one. The refusal says the write changes which CloudIdentity selects the workstation.

Ringleader judges a WorkstationPool template the same way
(the fields are in [WorkstationPool and WorkstationPoolLease](https://docs-stg.ringleader.dev/reference/resources/workstationpool/)),
as a workstation carrying the label that names the pool. A write that carries a block for more than one
cloud meets the CloudIdentity that would serve each cloud. A cloud with no CloudIdentity or no lists is
judged by the fixed list alone.

<div class="callout callout-note">
  <p class="callout-title">Deny does not stop a member from relabeling</p>
  <div class="callout-body">
    A member who may relabel a workstation can choose which CloudIdentity selects it, and so which lists
apply. <code>deny</code> rules the workstations an identity selects, and it does not bound which identity a member
picks.
  </div>
</div>


## The cloudconfig Grant

A `cloudconfig` Grant lets someone place one workstation without holding the verb. Four rules bound it:

- **It names one workstation.** A target that uses `matchLabels` or `matchName: "*"` is refused, and so is
  adding `cloudconfig` to an existing `ssh` Grant that selects by label. A label selector would reach every
  workstation that the beneficiary labels into it. To let someone place several workstations, write one
  Grant for each.
- **Only an administrator writes it.** Ringleader refuses a writer who does not hold the `cloudconfig` verb, so
  a member cannot grant it to anyone, themselves included. Its Grant has administrator scope. It reaches the
  named workstation whoever owns it.
- **It does not cover a pool.** A Grant names a workstation, so Ringleader judges a WorkstationPool's
  template by the verb alone.
- **It does not cover the runtime identity, and a `deny` list still applies.** Neither the verb nor a
  Grant lets anyone set `serviceAccount`, `managedIdentity` or `iamInstanceProfile` on a workstation.
  A key that the CloudIdentity denies stays refused.

A Grant that names a workstation not yet created applies to a new workstation of the same name, as any
Grant does. It keeps the scope it was written with, so an administrator who is later demoted leaves the
Grant working until someone deletes it.

## Allow or deny a key

To let members set a key, add it to `allow` on the CloudIdentity that selects their workstations. To
refuse a key for everyone, add it to `deny`. This identity lets members choose the zone and stops anyone
changing `assignPublicIp`:

```yaml
spec:
  provider: gcp
  providerConfigKeys:
    allow: [zone]
    deny: [assignPublicIp]
```

Nobody can then change `assignPublicIp` on a workstation, so it stays whatever the CloudIdentity gives it.

## Let one person place one workstation

Write a Grant for the workstation and apply it with `rl apply`. `rl workstation share` never writes
one, so the `ssh` Grants it makes are unchanged.

```yaml
apiVersion: core.ringleader.dev/v1
kind: Grant
metadata:
  name: build-box-placement-to-alice
  namespace: dev
spec:
  target:
    kind: Workstation
    matchName: build-box
  subjects:
    - user:alice@acme.com
  rights:
    - cloudconfig
```

Alice may then set any placement or network key on `build-box`, when she creates it and when she updates
it, and on no other workstation.

## Next steps

- [Grant](https://docs-stg.ringleader.dev/reference/resources/grant/): the fields of a Grant.
- [Subnet claims](https://docs-stg.ringleader.dev/cloud-accounts/cloud-identities/subnet-claims/):
  give a subnet to one namespace, which also places its workstations.

