agentleFS
kubetail-orgkubetail-org/kubetail/dashboard/CLAUDE.md

kubetail / dashboard

CLAUDE.md1.8k starsChanged 3 days agoApache-2.0View on GitHub

A Go/Gin HTTP server: the built UI, a GraphQL API over the Kubernetes API (gqlgen), REST routes for sessions and downloads, and the proxy to the Cluster API. It runs as its own binary in the cluster (cmd/main.go) and inside the CLI for kubetail serve. The root guide's Go modules › Checks holds the commands every Go module shares. Keep this section in step with the one in README.md. While working: After editing libs/graphql/dashboard/schema.graphqls: Before you push: CI also runs…

Trending

Quiet since October.about the whole repository

Jan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 3 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentionsDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the kubetail-org/kubetail repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about kubetail-org/kubetail

The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 27

Talked about on GitHub, Bluesky and Hacker News (27 times).

On GitHub · 20

15 more on GitHub

On Bluesky · 5

On Hacker News · 2

The file

Files
CLAUDE.md

dashboard — Dashboard backend

A Go/Gin HTTP server: the built UI, a GraphQL API over the Kubernetes API (gqlgen), REST routes for sessions and downloads, and the proxy to the Cluster API. It runs as its own binary in the cluster (cmd/main.go) and inside the CLI for kubetail serve.

  • pkg/app and pkg/config are the CLI's API. cli/cmd/serve.go calls config.DefaultConfig, app.NewApp, NotifyShutdown, DrainWithContext and Close. A change to those signatures, or to a default in DefaultConfig, changes kubetail serve.
  • pkg/app/app.go is the composition root and holds every route. internal/cluster-api/ is package clusterapi. Hand-written GraphQL code sits in graph/schema.helpers.go and graph/model/models_custom.go.
  • A schema or resolver change follows libs/graphql/CLAUDE.md.
  • website/ is the built UI, copied in by make build-dashboard-ui; git tracks only .gitkeep. Without it every page route answers 404 website not found, and the API still works.

Checks

The root guide's Go modules › Checks holds the commands every Go module shares. Keep this section in step with the one in README.md.

While working:

make vet-cli test-cli   # from the repo root: what the change reaches, with cli/

After editing libs/graphql/dashboard/schema.graphqls:

go generate ./...                        # gqlgen
cd ../apps/web && pnpm graphql-codegen   # the UI's types

Before you push:

make lint-cli vet-cli test-cli cover-cli   # from the repo root, with cli/

CI also runs make staticcheck-cli.

The CLI and the Dashboard share a coverage area, as CI measures them: FULL=1 runs the CLI's tests too, which reach Dashboard lines of their own.

Config

pkg/config.NewConfig reads the file, expands ${VAR} from the environment (the only way an environment variable reaches the config), and unmarshals over DefaultConfig(), the truth for defaults: the cluster environment on :8080. Keys are flat and top-level. A new key gets a mapstructure tag, a default there, a validation tag where it can be wrong, and an entry in config/default/dashboard.yaml.

Routes

Routes mount under cfg.BasePath. NewApp builds three nested groups, and which group a route joins decides what protects it:

GroupMiddleware it adds, in orderRoutes
rootnonehealth, static assets, /graphiql, and the SPA shell on / and every unmatched path
dynamicRoutessession cookie, security headers, csrfProtectionMiddleware, authenticationMiddleware/api/auth/*
protectedRoutesk8sAuthenticationMiddleware, websocketCSRFContextMiddleware/graphql, /cluster-api-proxy/*path, POST /api/v1/download
  • authenticationMiddleware finds the token: the session cookie in auth-mode: token, or an Authorization: Bearer header in either mode, which wins. k8sAuthenticationMiddleware enforces it: 401 in token mode without one, and it puts the token on the request context under k8shelpers.K8STokenCtxKey.
  • In auth-mode: auto a request with no token runs as the process: the kubeconfig user in desktop, the Dashboard's ServiceAccount in cluster.

Kubernetes access

  • Kubernetes clients come from the App's one k8shelpers.ConnectionManager, with three exceptions that use credentials of their own: the Helm client (desktop only), the health monitor's aggregator clientset, and the authorizer's review client.
  • A resolver that takes kubeContext starts with r.cm.DerefKubeContext(kubeContext) and passes the result down. In cluster the result is always ""; a non-empty kube context handed to the connection manager directly is an error.
  • Namespaces go through the allow-list. A get calls k8shelpers.DerefNamespace(r.allowedNamespaces, namespace, default). A list or a watch goes through r.listResource or r.watchResourceMulti. An omitted namespace is the context's default; the empty string means all, which with an allow-list fans out across the allowed namespaces. Anything built from source paths passes logs.WithAllowedNamespaces(r.allowedNamespaces).
  • cm.NewInformer always gets the request's token: its access review is the only thing between a caller and a shared informer's data. → ADR: share informers and gate each caller with an access review
  • Logs are read from the Kubernetes API here (KubeLogFetcher, the default of logs.NewStream). This module never speaks gRPC; the agent-backed path is the Cluster API's, which the browser reaches through the proxy.
  • An operation that exists in desktop alone returns ErrForbidden in cluster (kubeConfigGet, helmListReleases…). A new one does the same.

The Cluster API proxy

/cluster-api-proxy/* forwards to /apis/api.kubetail.com/v1 on the kube-apiserver, never to the Cluster API's Service. DesktopProxy takes the kube context from the first path segment and authenticates with that context's kubeconfig credentials. InClusterProxy sends the session's token as Authorization, or falls back to the Dashboard's ServiceAccount. With cluster-api-enabled: false in cluster the route is a 503 stub. HealthMonitor maps the Available condition of the APIService v1.api.kubetail.com to the status the UI shows.

Security invariants

What an ordinary change here can break, beside the root guide's list:

  • A route on root has no session, no CSRF check and no authentication. Anything that reads or changes a user's data joins dynamicRoutes or protectedRoutes. The tests in pkg/app/app_test.go find the middleware by function name, so renaming one fails them.
  • CSRF is two layers (csrfProtectionMiddleware): a request whose Sec-Fetch-Site is cross-site or same-site is refused, then X-CSRF-Token, or a form post's csrfToken field, must equal the session's token, compared in constant time. GET, HEAD and OPTIONS are skipped, so the GraphQL server has no GET transport and no GET route changes state. → ADR: defend against CSRF in two layers
  • A WebSocket is gated twice: CheckOrigin (same origin, or allowed-origins; a missing Origin is refused) and the connection_init payload's csrfToken. The same-origin check ignores X-Forwarded-*; a deployment behind a proxy sets allowed-origins.
  • The proxies strip what the caller must not choose: Origin, Authorization, X-Forwarded-Authorization and every Impersonate-* header are deleted before forwarding, a path with a .. segment is refused before it is joined, and an upgrade is refused unless its origin is allowed and it carries the forwarded CSRF token. The Cluster API relies on each of these. → ADR: reach the Cluster API through the aggregation layer
  • websocketCSRFContextMiddleware deletes a client's own X-Forwarded-CSRF-Token before it sets the real one.
  • The token is trimmed before it is checked, so a whitespace-only bearer does not pass for one.

Tests

  • pkg/app/testutils_test.go gives newTestConfig() and newTestApp(cfg), which builds the app with no connection manager and no proxy (app.cm is nil, the proxy route is the 503 stub) and a mockQueryHelpers with no expectations. A test sets its expectations on app.queryHelpers or mounts its own handler on app.dynamicRoutes or app.protectedRoutes.
  • The GraphQL server is stood up with graph.NewServer(cfg, nil, clusterapi.NewHealthMonitor(cfg, nil)) behind withSessionCSRFToken and dialled with a graphql-transport-ws WebSocket (graph/server_test.go). A resolver is called directly on &queryResolver{&Resolver{…}} with the fakes it needs.
  • Seams are fields and parameters: the dependencies newApp takes, the health monitor graph.NewServer takes (internal/cluster-api/mock.MockHealthMonitor), downloadHandlers.newLogStream, Resolver.helmReleaseLister, the transport newInClusterProxy takes.
  • The tests to extend for a boundary: pkg/app/middleware_test.go (CSRF), pkg/app/websocket_test.go (WebSocket CSRF end to end), internal/cluster-api/proxy_test.go (header stripping, path traversal), TestAllowedNamespacesGetQueries in graph/schema.resolvers_test.go.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.