Skip to content

Commit a26ab5f

Browse files
Merge pull request #17 from projectcapsule/feat/grq
feat: implement all quota features
2 parents 884835f + e01ad46 commit a26ab5f

129 files changed

Lines changed: 14105 additions & 1779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

AGENTS.md

Lines changed: 803 additions & 0 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
FROM scratch
2-
3-
COPY --from=stagex/core-busybox /bin/mkdir /bin/mkdir
4-
COPY --from=stagex/core-busybox /usr/bin/mkdir /usr/bin/mkdir
5-
6-
COPY --from=stagex/core-busybox /bin/cp /bin/cp
7-
COPY --from=stagex/core-busybox /usr/bin/cp /usr/bin/cp
8-
1+
FROM busybox:1.37.0
92

103
RUN ["/bin/mkdir", "-p", "/plugins/capsule"]
114

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.PHONY: \
2+
headlamp-deploy \
3+
headlamp-sync \
4+
headlamp-render \
5+
headlamp-status \
6+
headlamp-token \
7+
headlamp-port-forward \
8+
headlamp-logs \
9+
headlamp-undeploy
10+
11+
headlamp-deploy:
12+
./hack/headlamp-dev.sh deploy
13+
14+
headlamp-sync:
15+
./hack/headlamp-dev.sh sync
16+
17+
headlamp-render:
18+
./hack/headlamp-dev.sh render
19+
20+
headlamp-status:
21+
./hack/headlamp-dev.sh status
22+
23+
headlamp-token:
24+
./hack/headlamp-dev.sh token
25+
26+
headlamp-port-forward:
27+
./hack/headlamp-dev.sh port-forward
28+
29+
headlamp-logs:
30+
./hack/headlamp-dev.sh logs
31+
32+
headlamp-undeploy:
33+
./hack/headlamp-dev.sh undeploy
34+

README.md

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# headlamp-plugins
2+
23
Headlamp Plugins for Project Capsule
34

45
[![GitHub Release](https://img.shields.io/github/v/release/projectcapsule/headlamp-plugin?include_prereleases&sort=semver)](https://github.com/projectcapsule/headlamp-plugin/releases)
@@ -12,12 +13,19 @@ The plugin brings first-class multi-tenancy awareness to the Headlamp UI, includ
1213

1314
- **Tenant Switcher** — Multi-select tenant chooser in the app bar that scopes the entire UI to the selected tenants' namespaces.
1415
- **Tenant Views** — Full list and detail pages for Tenants, including owners, state, namespace lists, and rich metadata (icon, description, links, banner) via annotations.
15-
- **Capsule Overview** — At-a-glance dashboard with tenant activity, readiness of managed namespaces, Global Quotas, TenantResources, and replicated objects.
16+
- **Capsule Overview** — Responsive Tenant, Quotas, and Replications rows for
17+
Tenants, managed namespaces, TenantOwners, ResourcePools, CustomQuotas,
18+
GlobalCustomQuotas, GlobalResourceQuotas, TenantResources,
19+
GlobalTenantResources, and replicated objects.
1620
- **Custom Quotas** — Dedicated list and detail views for both `CustomQuota` and `GlobalCustomQuota`, with usage pies, claims breakdown, and source definitions.
21+
- **Global Resource Quotas** — Dedicated cluster-wide quota list with per-resource capacity health, plus aggregate and per-namespace consumption details in an animated relationship graph.
22+
- **Native CRD Integration** — Opening supported Capsule objects from Headlamp's Custom Resources navigation uses the same rich plugin overviews and details, with canonical CR instance URLs rather than parallel pages.
23+
- **Contextual Documentation** — Tenant, quota, ResourcePool, and replication detail headers include a documentation action directly beside Edit.
1724
- **Tenant Resources** — Powerful support for `TenantResource` and `GlobalTenantResource`:
25+
- Animated replication diagrams linking each TR/GTR to its managed objects
1826
- Grouped tables of managed objects
1927
- "Defined Resources" view (supports legacy + modern `namespacedItems` / `rawItems` / `generators`)
20-
- Server-Side Apply (SSA) managed fields inspection
28+
- Click-through, theme-aware Server-Side Apply (SSA) ownership diffs
2129
- One-click force reconcile action
2230
- **Readiness Visualization** — Consistent use of colored status indicators and small pie charts for readiness of namespaces, quotas, and managed objects.
2331
- **Scoped Filtering** — Automatic namespace filter updates when navigating from tenant-owned resources.
@@ -48,20 +56,27 @@ pluginsManager:
4856
3. Go to **Settings → Plugins → Load plugin from file** and select the downloaded archive.
4957
4. The **Capsule** section will appear in the sidebar.
5058

51-
### Development / Hot Reload
59+
### Development environment
60+
61+
See the [Development](#development) section below for the in-cluster workflow.
62+
63+
### Documentation URL
5264

53-
See the [Development](#development) section below.
65+
Documentation actions use `https://projectcapsule.dev` by default. To use a
66+
mirror or another documentation host, open **Settings → Plugins → capsule**, set
67+
**Documentation base URL**, and save. The resource-specific `/docs/...` path and
68+
anchor are appended to the configured base URL.
5469

5570
## Tenant Metadata Annotations
5671

5772
You can enrich how Tenants appear in the plugin by adding annotations to your `Tenant` resources.
5873

59-
| Annotation | Purpose | Example Value |
60-
|-------------------------------------|----------------------------------------------|----------------------------------------------------|
61-
| `info.projectcapsule.dev/icon` | Avatar/icon for the tenant | `https://example.com/my-tenant-icon.png` |
62-
| `info.projectcapsule.dev/description` | Short description shown in lists and chooser | `Production tenant for the payments team` |
63-
| `info.projectcapsule.dev/links` | JSON array of quick links | `'[{"title":"Dashboard","url":"https://..."}]'` |
64-
| `info.projectcapsule.dev/banner` | Banner image at the top of the tenant detail | `https://example.com/tenant-banner.jpg` |
74+
| Annotation | Purpose | Example Value |
75+
| ------------------------------------- | -------------------------------------------- | ----------------------------------------------- |
76+
| `info.projectcapsule.dev/icon` | Avatar/icon for the tenant | `https://example.com/my-tenant-icon.png` |
77+
| `info.projectcapsule.dev/description` | Short description shown in lists and chooser | `Production tenant for the payments team` |
78+
| `info.projectcapsule.dev/links` | JSON array of quick links | `'[{"title":"Dashboard","url":"https://..."}]'` |
79+
| `info.projectcapsule.dev/banner` | Banner image at the top of the tenant detail | `https://example.com/tenant-banner.jpg` |
6580

6681
**Example:**
6782

@@ -82,6 +97,10 @@ spec:
8297
```
8398

8499
These annotations are used in the tenant chooser, tenant lists, tenant details, and the Capsule overview.
100+
When one or more specific Tenants are selected, Headlamp also shows a secondary
101+
context-tab row below the app bar. Each selected Tenant gets a tab (including
102+
its configured icon), and the active tab exposes that Tenant's quick links. The
103+
row is hidden for the unscoped **All Tenants** selection.
85104

86105
> **Note:** The `links` annotation must be a valid JSON array of objects containing at least `title` and `url`.
87106

@@ -90,17 +109,25 @@ These annotations are used in the tenant chooser, tenant lists, tenant details,
90109
The plugin provides rich support for Capsule's replication resources:
91110

92111
- Visual breakdown of what each `TenantResource` / `GlobalTenantResource` is configured to replicate.
112+
- Animated flow from each replication resource to its live managed objects.
113+
- Inline SSA ownership diff when a managed object is selected in the flow or inventory.
93114
- Live view of the actual objects that have been applied (with SSA ownership information).
94115
- Ability to trigger reconciliation directly from the UI.
95116
- Support for both the modern `resources` array format and older flat resource definitions.
96117

97118
## Development
98119

99-
### Prerequisites
120+
### In-cluster development (recommended)
121+
122+
The repository includes a repeatable environment that deploys Headlamp and the
123+
locally built plugin into Kubernetes. It is optimized for kind and uses the
124+
current kube context by default.
125+
126+
Prerequisites:
100127

101-
- Node.js (v20+ recommended)
128+
- Node.js 22 or 24 (pinned by `.nvmrc`/`.node-version`) and npm 11+
129+
- Docker, kubectl, Helm, and kind
102130
- A Kubernetes cluster with Capsule CRDs installed
103-
- Headlamp (desktop app or from source) connected to that cluster
104131
- At least one `Tenant` that your user can list
105132

106133
### Getting Started
@@ -111,17 +138,41 @@ cd headlamp-plugin
111138
npm install
112139
```
113140

114-
### Running in Development Mode
141+
Deploy or update Headlamp and the plugin:
142+
143+
```bash
144+
make headlamp-deploy
145+
```
146+
147+
Keep the port-forward running, then open <http://127.0.0.1:8081>:
148+
149+
```bash
150+
make headlamp-port-forward
151+
```
152+
153+
Generate a temporary token in another terminal and use it on Headlamp's login
154+
screen:
155+
156+
```bash
157+
make headlamp-token
158+
```
159+
160+
For the normal edit/build/reload loop, change files under `src/` and run:
115161

116162
```bash
117-
npm start
163+
make headlamp-sync
118164
```
119165

120-
This starts the development server on port `4466` by default.
166+
Headlamp remains in-cluster while the rebuilt bundle is copied into its watched
167+
plugin directory. See [`deploy/headlamp/README.md`](deploy/headlamp/README.md)
168+
for configuration overrides, diagnostics, remote-cluster usage, and the local
169+
development RBAC warning.
121170

122-
Then load the plugin in Headlamp using the **"Load plugin from URL"** feature (point it at `http://localhost:4466`).
171+
### Standalone plugin server
123172

124-
> **Important:** The dev server only serves the plugin JavaScript. You must run it against a real Headlamp instance that is connected to a cluster with Capsule.
173+
`npm start` still starts the plugin development server on port `4466`. Use this
174+
when running Headlamp Desktop or Headlamp from source and load the plugin from
175+
`http://localhost:4466`.
125176

126177
### Build & Package
127178

@@ -140,13 +191,13 @@ npm test
140191

141192
### Other useful commands
142193

143-
| Command | Description |
144-
|----------------------|--------------------------------------|
145-
| `npm run build` | Production build |
146-
| `npm run lint` | Lint the project |
147-
| `npm run lint-fix` | Auto-fix lint issues |
148-
| `npm run tsc` | Type check |
149-
| `npm run storybook` | Run Storybook (if stories are added) |
194+
| Command | Description |
195+
| ------------------- | ------------------------------------ |
196+
| `npm run build` | Production build |
197+
| `npm run lint` | Lint the project |
198+
| `npm run lint-fix` | Auto-fix lint issues |
199+
| `npm run tsc` | Type check |
200+
| `npm run storybook` | Run Storybook (if stories are added) |
150201

151202
## Related Projects
152203

@@ -170,4 +221,3 @@ Apache-2.0
170221
---
171222

172223
Made with ❤️ for the Capsule and Headlamp communities.
173-
>>>>>>> dbeffcd3 (feat: first commit)

deploy/headlamp/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# In-cluster development environment
2+
3+
This environment runs Headlamp in Kubernetes and mounts the locally built
4+
Capsule plugin into its plugin directory. It is optimized for kind but can use a
5+
remote cluster when the plugin image is pushed to a registry.
6+
7+
The chart is pinned to Headlamp `0.44.0`. The initial plugin bundle comes from
8+
the repository's `Dockerfile`. After deployment, `make headlamp-sync` rebuilds
9+
the bundle and copies it through the `plugin-sync` sidecar. Headlamp watches the
10+
shared plugin directory and reloads changed bundles.
11+
12+
## Deploy to kind
13+
14+
Prerequisites are npm 11+, Docker, kind, kubectl, Helm, and an existing kind
15+
cluster. Node.js 22 or 24 is supported; `.nvmrc` and `.node-version` both pin
16+
Node 24 for common version managers. If the active Node is unsupported, the
17+
script automatically uses an ephemeral Node 24 runtime through `npx`.
18+
19+
```sh
20+
make headlamp-deploy
21+
```
22+
23+
For a context that is not named `kind-<cluster name>`, provide both names:
24+
25+
```sh
26+
KUBE_CONTEXT=my-context KIND_CLUSTER=my-kind-cluster make headlamp-deploy
27+
```
28+
29+
The command installs dependencies when needed, builds the plugin, builds and
30+
loads its image, installs or upgrades Headlamp, and waits for the deployment to
31+
become ready. It normally uses `kind load docker-image`; if the installed kind
32+
CLI cannot read a newer containerd configuration, it automatically imports the
33+
same image through `ctr` on each kind node.
34+
35+
## Open Headlamp
36+
37+
In one terminal, keep the port-forward running:
38+
39+
```sh
40+
make headlamp-port-forward
41+
```
42+
43+
Open <http://127.0.0.1:8081>. In another terminal, generate a temporary login
44+
token and paste it into Headlamp:
45+
46+
```sh
47+
make headlamp-token
48+
```
49+
50+
## Iterate on the plugin
51+
52+
After changing plugin source, run:
53+
54+
```sh
55+
make headlamp-sync
56+
```
57+
58+
This is the normal fast feedback loop. A full `make headlamp-deploy` is only
59+
needed after changing the plugin image, chart values, or deployment tooling.
60+
The fast sync writes into the current pod's `EmptyDir`, so it is intentionally
61+
ephemeral. Run `make headlamp-deploy` before handing off a feature batch; that
62+
rebuilds the plugin image and prevents a later pod recreation from restoring an
63+
older bundle. A running port-forward is attached to the selected backing pod
64+
and must also be restarted after a rollout or pod replacement.
65+
66+
Useful diagnostics:
67+
68+
```sh
69+
make headlamp-status
70+
make headlamp-logs
71+
make headlamp-render
72+
```
73+
74+
## Configuration overrides
75+
76+
The scripts accept these environment variables:
77+
78+
| Variable | Default | Purpose |
79+
|---|---|---|
80+
| `KUBE_CONTEXT` | current context | Target Kubernetes context |
81+
| `HEADLAMP_NAMESPACE` | `capsule-system` | Deployment namespace |
82+
| `HEADLAMP_CHART_VERSION` | `0.44.0` | Pinned chart version |
83+
| `HEADLAMP_PORT` | `8081` | Local port-forward port |
84+
| `PLUGIN_IMAGE` | `capsule-headlamp-plugin:dev` | Development image reference |
85+
| `PLUGIN_PULL_POLICY` | `Never` on kind | Init-container pull policy |
86+
| `KIND_CLUSTER` | inferred from context | kind cluster name |
87+
| `PUSH_PLUGIN_IMAGE` | `0` | Push the image for a non-kind cluster |
88+
| `NODE_BIN` | automatic | Explicit Node 22/24 executable |
89+
90+
For a non-kind cluster, use a registry reference and explicitly allow the push:
91+
92+
```sh
93+
KUBE_CONTEXT=my-cluster \
94+
PLUGIN_IMAGE=registry.example.com/capsule-headlamp-plugin:dev \
95+
PUSH_PLUGIN_IMAGE=1 \
96+
make headlamp-deploy
97+
```
98+
99+
## Security boundary
100+
101+
The development service account is bound to Kubernetes' built-in
102+
`cluster-admin` role. This intentionally allows every cluster-scoped and
103+
namespaced action so the complete Headlamp and Capsule UI can be exercised in
104+
the disposable development cluster. Do not reuse this binding in a shared or
105+
production cluster; replace it with roles scoped to the APIs and verbs that the
106+
installation actually needs. Headlamp still requires a login token, the service
107+
is only a `ClusterIP`, and the documented port-forward binds to localhost.
108+
109+
Remove the Helm release with `make headlamp-undeploy`. The namespace is kept so
110+
other development resources in it are not deleted unexpectedly.

0 commit comments

Comments
 (0)