> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formae.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy a Crossplane control plane

> A Kubernetes infrastructure pattern, deployed with formae.

Crossplane core installed into its own namespace, with the RBAC it needs to
manage cluster resources. One forma provisions the `crossplane-system` namespace,
a ServiceAccount, a ClusterRole and ClusterRoleBinding, a leader-election Role
and RoleBinding, the Crossplane Deployment, and its Service. Crossplane's own init
container installs its CRDs at first start, so those are not managed by formae.

```mermaid theme={"languages":{"custom":["/languages/pkl.json"]}}
flowchart LR
  target["k8s-target-local-crossplane"]:::tgt

  subgraph stack["k8s-crossplane-local"]
    direction LR
    ns["Namespace (crossplane-system)"]:::res
    sa["ServiceAccount"]:::res
    clusterRole["ClusterRole"]:::res
    clusterRoleBinding["ClusterRoleBinding"]:::res
    role["Role (leader election)"]:::res
    roleBinding["RoleBinding (leader election)"]:::res
    deploy["Deployment"]:::res
    svc["Service"]:::res

    ns --> sa
    ns --> role
    ns --> roleBinding
    ns --> deploy
    ns --> svc
    sa --> clusterRoleBinding
    clusterRole --> clusterRoleBinding
    sa --> roleBinding
    role --> roleBinding
    sa --> deploy
    deploy --> svc
  end

  target --> stack

  classDef tgt fill:#FF8201,stroke:#B25900,color:#ffffff
  classDef res fill:#FFF3E6,stroke:#FF8201,color:#02024B
  style stack fill:#ffffff,stroke:#02024B,stroke-width:2px,stroke-dasharray:6 4,color:#02024B
```

**Deploy.** Apply the example forma. formae orders the resources by their
dependencies automatically, so the namespace and ServiceAccount come up before
the RBAC bindings and the Deployment that relies on them:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae apply --mode reconcile \
  /opt/pel/formae/examples/formae-plugin-kubernetes/crossplane/local.pkl
```

**Verify.** Once the command completes, the stack's resources are under
management:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae inventory resources --query="type:K8S::Apps::Deployment"
```

**Tear down.** Remove everything the forma created:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae destroy \
  /opt/pel/formae/examples/formae-plugin-kubernetes/crossplane/local.pkl
```

The full forma is in the
[crossplane example](https://github.com/platform-engineering-labs/formae-plugin-kubernetes/tree/main/examples/crossplane).
