Skip to content

feat(ui): manage EgressPolicies from the UI - #3542

Merged
Charlesthebird merged 6 commits into
kagent-dev:mainfrom
alan-bentley-pgh:alan-bentley-pgh/egressPoliciesUI
Nov 5, 2026
Merged

Charlesthebird merged 6 commits into
kagent-dev:mainfrom
alan-bentley-pgh:alan-bentley-pgh/egressPoliciesUI

Conversation

@alan-bentley-pgh

@alan-bentley-pgh alan-bentley-pgh commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🤖 written by Claude (start)

Closes #3526

Summary

  • Adds a Policies page with an Egress Policies tab: search, a namespace filter and a details page with a "Used by" table.
  • Adds a create and edit form that checks the CRD's rules before saving.
  • The agent form now picks policies from its namespace, and agent details link to them.
  • Adds EgressPolicyService (list, get, create, update, delete) and gives the management role write access to egresspolicies.
  • A stale update now returns Aborted from the shared kubecrud path, so the form can ask for a reload.
  • An agent whose EgressPoliciesApplied condition is false no longer shows as failed.

Testing

  1. In ui/, set ENABLE_MOCK_UI=true in .env, then run yarn dev. Mock mode serves fixtures, not real data.
  2. Open /policies. Search, filter by namespace, and open a policy.
  3. Create a policy with a wildcard origin and authentication. The form blocks the save.
  4. Edit an agent and select the policy. The policy's page lists the agent under "Used by".
  5. Delete the policy.

For a real cluster, run scripts/setup-cluster/setup-cluster.sh and repeat with policies applied through kubectl.


🤖 written by Claude (end)

Add an EgressPolicyService (list, get, create, update, delete) and a
Policies section in the UI: list, details with a "Used by" table, a
create and edit form, and egress policy selection on the agent form.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 5, 2026
alan-bentley-pgh

This comment was marked as resolved.

Show a policy as not applied only when the agent's condition names it,
and show no "Used by" count for namespaces whose agents could not be read.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
alan-bentley-pgh

This comment was marked as resolved.

Name the policy by namespace in the list confirm, label the destination
inputs, and move focus after adding or removing a destination.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
alan-bentley-pgh

This comment was marked as resolved.

Report a policy as not yet evaluated when the agent's condition is older
than its generation, and say "Used by" counts only what the user can see.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
alan-bentley-pgh

This comment was marked as resolved.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
alan-bentley-pgh

This comment was marked as resolved.

@alan-bentley-pgh

This comment has been minimized.

@alan-bentley-pgh
alan-bentley-pgh marked this pull request as ready for review November 5, 2026 19:39
@alan-bentley-pgh
alan-bentley-pgh requested a review from a team as a code owner November 5, 2026 19:39
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 5, 2026

@Charlesthebird Charlesthebird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This automated review is a first pass. A manual review will follow once the blockers are addressed.


The name check rejects dotted names, so a policy created with kubectl as api.github.com can't be saved from the edit page. The sidebar label and not-found page asks are inline.

⚠️ What I checked
  • ✅ Form rules vs the CRD in egresspolicy_types.go: origin pattern, length caps, blocked headers, one of secretKeyRef/actorJwt, audiences, token lifetime, wildcard without auth, 1–64 destinations.
  • ✅ Stale save: kubecrud returns Aborted, the form shows the reload prompt, and the mock does the same.
  • ✅ Status: EgressPoliciesApplied=False no longer marks an agent failed; old observedGeneration reads as not reported.
  • ✅ Agent form caps refs at 16 and drops the field when cleared.
  • ✅ RBAC: method policy covers all five RPCs, management role adds write verbs, kubecrud checks auth per call.
  • Resource name validation on create and edit.

Written by 🤖

Comment thread ui/src/components/Structure/navItems.ts Resolved
Comment thread ui/src/router/routes.ts Resolved

@Charlesthebird Charlesthebird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a couple of notes here:

Could the code around “EgressPoliciesPage” and text for that page also be updated to make it match up with the idea that this is a “Policies” page, with a list of "Egress Policies" and then specify that it’s “Create Egress Policy” at the top?

You could use the structure from the agents page to explain the egress policy and what it is, and then include one tab for "Egress Policies". This could be a small simple diagram, and the text here could be concise and match the style from the agents page.

Add a Policies page with an Egress Policies tab and a short overview,
allow DNS subdomain policy names on create and edit, and list Policies
on the Not Found page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
@alan-bentley-pgh

Copy link
Copy Markdown
Contributor Author

The section is now a Policies page with one Egress Policies tab, a "Create egress policy" button and a short overview with a diagram, in 7bf0fa82. The tab follows the agents page's ?tab= pattern, and policy pages live under /policies/egress/.


🤖 written by Claude

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 5, 2026
@alan-bentley-pgh

alan-bentley-pgh commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Re-recorded on a real kind cluster at 7bf0fa82, with real policies, agents and a sandbox template. "Before" is the base UI on the same cluster and data.

  • Policies page: sidebar entry, overview diagram, Egress Policies tab, search and namespace filter
  • Policy details: Secret name only, and applied state per policy
  • Form: a wildcard origin with auth and a Cookie header are rejected, and a dotted-name policy is edited and saved
  • Agent form and agent details: the policy select and the policy list
  • Delete warning, Not Found entry, and a dotted URL loaded through the image's nginx
  • A missing policy no longer marks an agent "Update failed"
reel-full.mp4
Screenshots
Before After
Before: no Policies page in the sidebar
before-no-policies-nav
After: overview with a diagram
after-policies-page-overview
— After: every policy, with origins, auth and Used by
after-policies-page
— After: search by origin finds package-mirrors
after-policies-search-origin
— After: namespace filter shows platform only
after-policies-namespace-filter
Before: no policy details page
before-no-policy-details
After: destinations, Secret name and key only
after-policy-details-destinations
— After: Used by, with type, links and applied state
after-policy-details-used-by
— After: Applied here, though release-notes also lists a missing policy
after-policy-details-release-notes-applied
Before: no egress policy form
before-no-policy-form
After: a wildcard origin can't use authentication
after-policy-form-wildcard-no-auth
— After: Cookie can't carry a credential
after-policy-form-cookie-rejected
— After: ci-artifacts created and read back
after-policy-form-created
— After: api.github.com saved with the new destination
after-policy-form-dotted-edit-saved
Before: no egress policies field on the agent form
before-no-agent-egress-field
After: only kagent policies are offered
after-agent-form-kagent-policies
— After: switching to platform offers only warehouse
after-agent-form-platform-policies
Before: Details lists no egress policies
before-no-agent-details-policies
After: Details lists the agent's egress policies
after-agent-details-policies
Before: no policy to delete
before-no-policy-delete
After: deleting an in-use policy warns first
after-delete-confirm-in-use
Before: no Policies entry
before-not-found-no-policies
After: Policies listed on the Not Found page
after-not-found-policies
Before: a dotted policy URL has no page
before-dotted-url-no-page
After: full load of a dotted URL through the image's nginx
after-dotted-url-full-load
Before: a missing egress policy shows as Update failed
before-agent-status-update-failed
After: a missing egress policy no longer marks the agent failed
after-agent-status-ready

🤖 written by Claude

@Charlesthebird
Charlesthebird added this pull request to the merge queue Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@Charlesthebird
Charlesthebird added this pull request to the merge queue Nov 5, 2026
Merged via the queue into kagent-dev:main with commit 16f98ca Nov 5, 2026
32 checks passed
@alan-bentley-pgh
alan-bentley-pgh deleted the alan-bentley-pgh/egressPoliciesUI branch November 5, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] UI: Policies page for EgressPolicy

2 participants

⌂ 换网址