Admin Console API and request handling
The Admin Console API is the backend surface through which the web console and trusted clients manage KOTS applications and their target clusters. It starts the local service environment, applies request-wide controls, and maps versioned HTTP routes to application, cluster, configuration, delivery, and operational actions. See the Admin Console service architecture for the wider service view and Admin Console access control and state for authentication, sessions, RBAC, and stored state.
Server bootstrap
The API server starts only after its local state and required control services are ready. Startup therefore prepares the store, restores the context needed to read existing application data, starts control loops, and then exposes the HTTP server.
Startup contract
The api command is the process entry point. It supplies the build version and cluster bootstrap token to apiserver.Start, while the server reads its namespace context from the process environment. The server waits for the store, migrates legacy persistent data when needed, runs current data migrations, creates the initial cluster record when needed, and loads application encryption keys before it accepts requests.
References: cmd/…/api.go• L15-39 pkg/…/server.go• L39-81 pkg/…/bootstrap.go• L14-30
Runtime composition
After state setup, the server creates Kubernetes and operator access for the Admin Console namespace. It starts the operator and supporting workers for support bundles, resource watches, update checks, snapshots, session cleanup, pruning, and automated installs. These workers keep request results current while handlers remain focused on translating client actions into service calls.
References: pkg/…/server.go• L83-166
HTTP surface
The server listens on port 3000 and uses one router for API and browser traffic. API paths that do not match a registered endpoint return a plain not-found response instead of the single-page application. The upgrade-service UI uses an explicit proxy route so the Admin Console can present that service without changing its older client contract.
References: pkg/…/server.go• L168-252 pkg/…/static.go• L7-13
Request boundary
Every request passes through a small set of shared controls before a handler runs. The route group determines which client trust model applies, and the handler then reads request values, checks current state, calls the owning service, and returns a JSON or streamed result.
The request path below shows the normal management flow from a browser action to stored state or a cluster-side operation.
flowchart LR
Client[Admin Console or trusted client] --> Router[HTTP router]
Router --> Controls[Headers, CORS, logging]
Controls --> Auth[Route trust and session checks]
Auth --> Policy[Operation policy]
Policy --> Handler[Capability handler]
Handler --> Store[Persistent Admin Console state]
Handler --> Cluster[Kubernetes or target-cluster service]
Handler --> Task[Async task or worker]
Store --> Response[JSON, file, stream, or status response]
Cluster --> Response
Task --> Response
Cross-request controls
Security headers and CORS handling apply at the router level. CORS also answers preflight OPTIONS requests and allows credentialed browser calls. Logging records failed requests in normal operation and records all requests when debug logging is enabled.
References: pkg/…/server.go• L168-179 pkg/…/middleware.go• L29-77 pkg/…/cors.go• L7-24
Route trust classes
The API has three route classes. Unauthenticated routes support health checks, login, identity callbacks, application callbacks, and artifact delivery. Token-authenticated routes support trusted KOTS or application clients. Session-authenticated routes cover the management console and are also checked against an operation policy.
| Route class | Main client | Capability shape |
|---|---|---|
| Unauthenticated | Probes, login flows, applications, and cluster join clients | Health, login, callbacks, preflight results, and selected artifacts |
| KOTS token auth | Trusted KOTS or application clients | Upload, download, air-gap install, branding, and port discovery |
| Session auth | Admin Console users | Application, cluster, configuration, update, backup, and support actions |
References: pkg/…/handlers.go• L362-402 pkg/…/handlers.go• L40-57 pkg/…/server.go• L182-205
Request processing
Session routes accept a token from the Authorization header or the signed-token cookie. Session middleware validates the token against stored session state, rejects expired sessions and sessions issued before a password change, and extends active sessions when they approach expiry. An unavailable session store returns a server error instead of an unauthorized response, so clients can distinguish a backend outage from invalid credentials. OPTIONS requests bypass session validation for preflight handling.
After validation, the middleware attaches the session to the request for policy evaluation. A policy turns the route and its path values into an action on a resource, such as an application or cluster. The handler runs only after that check succeeds. Handlers use shared JSON response helpers and return client errors for invalid input or unsupported state while reserving server errors for failed service or state operations.
References: pkg/…/session.go• L50-135 pkg/…/middleware.go• L80-109 pkg/…/middleware.go• L31-75 pkg/…/handlers.go• L349-360
Application capabilities
Application routes expose the main lifecycle of an installed application. An application is represented by stored metadata and one or more downstream records, where a downstream is the application’s delivery target cluster. Clients use these routes to inspect state, choose a release, configure it, and start delivery.
Application state
The application endpoints provide lists and summaries that combine stored application data with release, license, downstream, GitOps, and feature support state. A response can therefore tell the console what is installed, what release is current, which updates are pending, and which capabilities the license and cluster type allow.
References: pkg/…/handlers.go• L107-123 pkg/…/app.go• L88-132 pkg/…/app.go• L156-336
Release delivery
Release routes coordinate update checks, upstream downloads, air-gap uploads, preflight checks, deployment, redeployment, and removal. The API accepts both online release requests and multipart air-gap data. Long work is represented by task or version status so a client can start an action and then poll its progress instead of holding one request open.
References: pkg/…/handlers.go• L125-177 pkg/…/update.go• L53-145 pkg/…/update.go• L379-514 pkg/…/deploy.go• L35-167 pkg/…/status.go• L19-64
Application configuration
Configuration routes let a client read or change the values for an application release. The API validates configuration groups, renders a preview for live changes, and creates or updates a release archive when a saved change affects delivery. Required values and validation errors return as part of the response so the client can correct the input before deployment.
References: pkg/…/handlers.go• L202-211 pkg/…/config.go• L139-231 pkg/…/config.go• L234-358 pkg/…/config.go• L407-549
Application integrations
The API also manages application-scoped registry settings, identity-service settings, GitOps links, licenses, automatic updates, rendered content, and downstream output. License routes expose the current license and support license sync, license changes, initial license upload, and service-account token upload. These operations connect the application record to external delivery systems or to the target cluster, so a successful response often means that a later worker or deployment step will complete the change.
References: pkg/…/handlers.go• L193-227 pkg/…/handlers.go• L319-331 pkg/…/license.go• L110-216 pkg/…/license.go• L255-420 pkg/…/license.go• L633-745 pkg/…/serviceaccount.go• L26-100 pkg/…/registry.go• L122-280 pkg/…/identity.go• L234-492 pkg/…/gitops.go• L41-181 pkg/…/downstream.go• L25-62
Cluster capabilities
Cluster routes expose operations that maintain the environment in which applications run. The API supports both legacy KURL-managed clusters and embedded clusters, while each handler checks whether the current installation supports the requested operation.
Cluster management
Cluster endpoints return node and role information and provide node join, drain, and delete actions. Embedded-cluster handlers use Kubernetes state and embedded-cluster services to carry out these actions. A drain may continue after the HTTP response because the serving pod can be evicted during the operation.
References: pkg/…/handlers.go• L281-313 pkg/…/embedded_cluster_get.go• L14-81 pkg/…/embedded_cluster_drain_node.go• L16-51 pkg/…/kurl_get.go• L1-120
Cluster-aware behavior
Some capabilities depend on the installation mode or on cluster resources. For example, automatic Admin Console updates are not available for KURL or air-gapped installations, and embedded-cluster application backups are not supported. Handlers report these limits before starting work so the client can choose a supported path.
References: pkg/…/update.go• L216-301 pkg/…/backup.go• L32-66 pkg/…/embedded_cluster_get.go• L14-19
Operational capabilities
Operational routes help users preserve state, diagnose applications, and observe work that does not finish in one request. They connect the HTTP surface to snapshot providers, support-bundle storage, preflight execution, task state, and service proxies.
Snapshot operations
Snapshot routes cover application backups, instance backups, restore requests, retention and schedule settings, storage-provider settings, and Velero status. The API checks provider presence and required Admin Console access before it changes snapshot settings. Restore requests also verify that the selected backup belongs to the intended application or instance before recording restore work.
References: pkg/…/handlers.go• L231-279 pkg/…/snapshots.go• L99-280 pkg/…/backup.go• L32-109 pkg/…/restore.go• L33-124
Support and preflight operations
Support-bundle routes expose bundle status, analysis, files, redactions, sharing, deletion, and collection. Preflight routes let the console start or rerun checks for a downloaded application release, read stored results with progress, and request a command for cluster-side execution. The cluster-side command posts its result through an unauthenticated callback, while a separate reporting path sends preflight data when the application has the needed license and downstream context. This flow lets the console turn cluster evidence into a user-facing diagnosis without keeping the initiating request open.
References: pkg/…/handlers.go• L57-77 pkg/…/troubleshoot.go• L103-214 pkg/…/handlers.go• L148-159 pkg/…/preflight.go• L34-99 pkg/…/preflight.go• L102-167 pkg/…/preflight.go• L169-233 pkg/…/preflight.go• L236-345 pkg/…/preflight.go• L348-393
Status and proxy operations
Task status endpoints give clients a stable way to observe downloads, automated installs, Admin Console updates, and upgrade-service work. The upgrade-service route can start the service and proxy compatible UI requests to it. This keeps the API as the control point while the long-running or specialized service owns its own work.
References: pkg/…/status.go• L14-64 pkg/…/handlers.go• L337-346 pkg/…/upgrade_service.go• L43-105 pkg/…/server.go• L214-225
Change checklist
When these files or sections are changed, remember to consider these:
- A route path or method change must stay aligned with the handler interface, client callers, and its session, token, or unauthenticated route class.
- A policy change must preserve the resource mapping for path values such as
appSlug,appId,clusterId, andsequence. - A response field or status-code change must stay aligned with the web console’s polling and error behavior, especially for asynchronous tasks.
- A task name change must be propagated to the worker that writes status and to every endpoint that reads that status.
- A license response or entitlement change must stay aligned with license sync, license change, initial install, and service-account token flows.
- Service-account token validation must remain tied to the current application license before upstream license sync is allowed.
- A new platform-specific capability must define its behavior for online, air-gapped, KURL, and embedded-cluster installations before route exposure.
- Changes to the upgrade-service proxy paths require a compatibility review because older Admin Console clients depend on those paths.
- Bootstrap ordering changes must preserve store readiness, data migration, key loading, operator startup, and worker startup dependencies.
- Preflight changes must keep the release-availability check, stored progress and result contract, rendered command inputs, and unauthenticated cluster callback aligned.
- Session authentication changes must preserve the distinction between invalid credentials and unavailable session storage, including the session cookie and authorization-header paths.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The store is not ready or bootstrap migration fails | The API process stops before it serves requests | Keep readiness checks and migration steps before router startup |
| A management route is registered without the intended policy or trust class | A client can receive an unexpected denial or an unprotected management surface | Review route registration with the matching middleware and policy |
| Session storage is unavailable during request authentication | The API returns a server error instead of treating the user as logged out | Preserve the distinction between session lookup failure and invalid credentials |
| A client requests configuration or content for a release still pending download | The API rejects the request because the release is not readable yet | Poll release status and request content only after download completes |
| A client starts work while its task is already running | The API rejects or ignores the duplicate operation, or the UI can show stale progress | Use the matching task-status endpoint before starting another operation |
| A preflight start or RBAC-error override targets a release still pending download | The API rejects the request and does not run the checks | Wait for the release archive to become available before starting or overriding preflight checks |
| A license upload has an invalid signature, expired data, or an unavailable channel | The application is not created or the license change is rejected | Validate the license and its requested channel before storing or using it |
| A service-account token is empty or does not match the current license | License sync does not start and the client receives a bad-request error | Require a token and validate it against the application’s current license |
| A snapshot request runs without Velero access or required provider support | The API returns a conflict or unsupported-operation error and no snapshot change occurs | Check the capability and RBAC state before changing snapshot settings |
| A cluster-only action runs on the wrong installation type | The API returns a platform error instead of performing the action | Check embedded-cluster, KURL, and air-gap capability flags in the handler path |
| The health handler's placeholder checks remain unchanged | Health responses can report healthy state without checking the real database or storage | Treat health status as incomplete until its dependency checks are connected |
Key files
| File | Why to read it |
|---|---|
| cmd/…/api.go | Shows the process command that supplies runtime context and starts the API. |
| pkg/…/server.go | Shows startup ordering, shared middleware, route groups, static serving, and the HTTP listener. |
| pkg/…/bootstrap.go | Explains the state preparation needed before request handling begins. |
| pkg/…/handlers.go | Defines the API route map and the broad capability groups. |
| pkg/…/middleware.go and pkg/…/middleware.go | Explain request logging, session attachment, and operation-level access checks. |
| pkg/…/session.go and pkg/…/session_test.go | Explain session token sources, session validity checks, session renewal, and the distinction between invalid credentials and session-store failure. |
| pkg/…/app.go and pkg/…/config.go | Show how application summaries and configuration changes connect client requests to release state. |
| pkg/…/license.go and pkg/…/serviceaccount.go | Show how the API reads and changes application license state and validates service-account tokens before syncing license data. |
| pkg/…/update.go and pkg/…/deploy.go | Show the online, air-gap, preflight, and deployment control paths. |
| pkg/…/snapshots.go, pkg/…/backup.go, and pkg/…/restore.go | Show how the API presents backup, provider, schedule, and restore operations. |
| pkg/…/troubleshoot.go and pkg/…/preflight.go | Show the diagnostic and preflight result flows, including the cluster callback and reporting path. |
| pkg/…/embedded_cluster_get.go and pkg/…/embedded_cluster_drain_node.go | Show the cluster-specific inspection and node operation boundary. |
| pkg/…/handlers_test.go | Shows the route policy contract that the API expects for handler access. |