Admin Console service architecture
The Admin Console is a Go service that gives operators one place to manage KOTS applications and the cluster that runs them. Its command starts a server inside the Admin Console workload. The server joins HTTP routes with a shared store, Kubernetes clients, an operator, and background services so browser and CLI actions can change and observe cluster state.
Service composition
The service has a central API process and supporting services that share the same installation context. The API process owns request routing. The operator and background jobs keep application and cluster state current while the store provides the shared record of that state.
flowchart TD
Command["kotsadm api command"] --> Bootstrap["API server bootstrap"]
Bootstrap --> Router["HTTP router"]
Bootstrap --> Store["Shared state store"]
Bootstrap --> Clients["Kubernetes and operator clients"]
Bootstrap --> Jobs["Watchers and background jobs"]
Router --> Handlers["HTTP handlers"]
Handlers --> Store
Handlers --> Clients
Handlers --> Jobs
Router --> UI["Admin Console UI"]
The main service listens on port 3000. It serves the web application and API from the same HTTP boundary. The upgrade service is reached through a proxy route, while support-bundle diagnostics use a small local service on port 3030. References: pkg/…/server.go• L44-51, pkg/…/server.go• L128-159, pkg/…/server.go• L236-243, pkg/…/server.go• L13-29
Command entrypoint
The kotsadm command is the process entrypoint for the Admin Console. The api subcommand sets the runtime namespace values and passes the build version and cluster bootstrap token to the server bootstrap. References: cmd/…/main.go• L10-13, cmd/…/root.go• L14-41, cmd/…/api.go• L15-39
The command selects the state store before a subcommand runs. It also maps command flags and environment variables into the process configuration. This keeps process setup outside the HTTP layer and lets the server receive the small set of values it needs to start. References: cmd/…/root.go• L20-23, cmd/…/root.go• L31-40, cmd/…/api.go• L20-35
Server bootstrap
Server bootstrap prepares the Admin Console's state and cluster links before it accepts requests. It waits for the store, runs state migrations, starts the application operator, initializes required tools, and starts services that monitor updates, snapshots, sessions, and cleanup. References: pkg/…/server.go• L44-75, pkg/…/server.go• L82-147
The operator is the service's active link to application resources. It uses the shared store and Kubernetes clients to find the target cluster, resume application work, watch deployment signals, and coordinate deployment and restore work. This allows HTTP requests to start work without owning the full life of that work. References: pkg/…/operator.go• L65-112, pkg/…/operator.go• L134-170, pkg/…/operator.go• L971-1005
When the service is installed or refreshed, the generated Admin Console resources define its workload, network service, service account, and access grants. The workload may use a Deployment or StatefulSet based on the storage choice. Access can be cluster-wide or limited to the Admin Console namespace and declared application namespaces. References: pkg/…/admin-console.go• L45-69, pkg/…/admin-console.go• L165-215, pkg/…/kotsadm.go• L23-82, pkg/…/kotsadm.go• L119-153
HTTP route surface
The HTTP router is the boundary between clients and Admin Console capabilities. It applies common response protections and request handling, then divides routes into unauthenticated routes, token-authenticated routes, session-authenticated routes, and static or proxied content. References: pkg/…/server.go• L159-199, pkg/…/server.go• L201-234, pkg/…/handlers.go• L362-402
Session-authenticated routes expose the operator workflows for applications, configuration, releases, registries, snapshots, cluster nodes, GitOps, upgrades, license management, and preflight checks. Each route maps a client request to the shared handler contract. The access policy attached to the route determines which protected operation the caller may perform; detailed request behavior belongs in Admin Console API and request handling, and the access and state model belongs in Admin Console access control and state. References: pkg/…/handlers.go• L40-45, pkg/…/handlers.go• L107-123, pkg/…/handlers.go• L161-180, pkg/…/handlers.go• L213-229, pkg/…/handlers.go• L231-279, pkg/…/handlers.go• L298-347, pkg/…/preflight.go• L34-294
Preflight routes connect application checks to the shared state model. The service can return stored results and progress, start or repeat checks for a version, generate a client command, accept results from the kubectl preflight command, and submit report data when a license and downstream cluster are available. References: pkg/…/preflight.go• L34-99, pkg/…/preflight.go• L102-234, pkg/…/preflight.go• L236-294, pkg/…/preflight.go• L297-392
The service-account token route is part of the application license workflow. A protected request identifies an application, validates the supplied token against its current license, and synchronizes the license before returning the application and sync result. This connects an HTTP action to both shared application state and the upstream license service. References: pkg/…/handlers.go• L213-220, pkg/…/serviceaccount.go• L14-24, pkg/…/serviceaccount.go• L26-99
The handler interface is the stable shape of the HTTP capability set. It groups operations by product concern rather than by transport detail. The concrete handler uses Kubernetes client builders and shared services to turn those operations into changes or reads. References: pkg/…/interface.go• L5-13, pkg/…/interface.go• L44-108, pkg/…/interface.go• L110-172, pkg/…/handlers.go• L20-32
Request boundary
Every request first passes through shared router controls. Security headers protect browser responses. CORS handling answers preflight requests. Logging records failures by default and can record all requests in debug mode. References: pkg/…/server.go• L159-171, pkg/…/middleware.go• L29-77, pkg/…/middleware.go• L112-119
The route groups reflect who may call an operation and why. Login, health, metadata, identity callbacks, selected application callbacks, and the preflight status callback are public. CLI and application upload paths use token-based access. The main operator surface requires a valid session and then applies a policy for the requested resource, including the policy that protects service-account token uploads. References: pkg/…/handlers.go• L370-402, pkg/…/handlers.go• L362-368, pkg/…/handlers.go• L40-45, pkg/…/handlers.go• L213-220, pkg/…/handlers.go• L297-305, pkg/…/middleware.go• L80-109
Configuration flow
Configuration enters the service from process settings, Kubernetes resources, and application configuration objects. Process settings identify the Admin Console namespace, target application namespace, build version, and cluster bootstrap token. Installation settings also carry credentials, storage choices, proxy values, registry data, identity settings, and access scope into the generated workload. References: cmd/…/api.go• L30-38, pkg/…/admin-console.go• L19-43, pkg/…/deployoptions.go• L12-70
Application configuration is treated as an input to application work rather than as a fixed server setting. The service combines a configuration specification with stored values and context such as the license, application, registry, identity, version, and namespace. It can then detect missing required values and pass the resolved result to later application actions. References: pkg/…/config.go• L51-98, pkg/…/config.go• L36-92
When the service is regenerated from an existing installation, it preserves key settings from existing Kubernetes Secrets and workload environment values. This keeps credentials and cluster identity stable across an Admin Console refresh while allowing current deployment choices to be applied. References: pkg/…/admin-console.go• L72-99, pkg/…/admin-console.go• L102-163
Shared service dependencies
The shared store is the common state boundary for handlers, the operator, sessions, and background jobs. The command initializes it before the API starts. Code that needs the store expects this process-wide dependency to exist. Admin Console access control and state describes the protected state and persistence model in more detail. References: cmd/…/root.go• L20-23, pkg/…/store.go• L13-33, pkg/…/server.go• L47-67
The Kubernetes client supplies access to resources in the Admin Console environment and in application namespaces covered by its permissions. The operator client adds event and deployment coordination. Together they connect API actions to live cluster resources instead of limiting the service to database records. References: pkg/…/server.go• L84-103, pkg/…/operator.go• L65-112, pkg/…/kotsadm.go• L156-224
Background services extend the API with work that must continue after a request ends. Watchers observe application state. The update checker finds available updates. The snapshot scheduler manages scheduled backup work. Session purge and prune jobs remove stale data. Automation can complete required installation work when the service is ready. References: pkg/…/server.go• L124-157
Admin Console access path
The access path begins at a local port-forward or another route to the Admin Console service. The kots admin-console command waits for the kotsadm pod and forwards a local port to the service's port 3000. If the preferred local port is busy, the command reports the selected port to the operator. References: cmd/…/admin-console.go• L16-22, cmd/…/admin-console.go• L31-68, cmd/…/admin-console.go• L82-98
The request then reaches the router. The router selects the route group, applies its authentication and policy controls, and invokes a handler. The handler reads or changes shared state through the store, Kubernetes clients, or an active background service. This separation lets the browser API describe an operation while the operator and jobs manage work that spans time. References: pkg/…/server.go• L161-199, pkg/…/handlers.go• L40-45, pkg/…/operator.go• L187-210
sequenceDiagram
participant User as Operator or client
participant CLI as kots admin-console
participant API as Admin Console API
participant Auth as Session or token boundary
participant Handler as HTTP handler
participant Services as Store, Kubernetes, operator
User->>CLI: Request local access
CLI->>API: Forward request to port 3000
API->>Auth: Classify and validate access
Auth->>Handler: Pass an allowed request
Handler->>Services: Read or start work
Services-->>Handler: State or operation result
Handler-->>User: HTTP response
Change checklist
When these files or sections are changed, remember to consider these:
- Route registration, the
KOTSHandlerinterface, and the matching handler must stay aligned. A route can compile yet fail at runtime if its handler contract or policy changes separately. - Changes to preflight route access must stay aligned with the
kubectl preflightcallback contract. The status callback is unauthenticated because the external command sends its result directly. - Changes to preflight result storage or version status checks must preserve the link between application slug, version sequence, stored progress, and the archive used to run checks.
- Changes to the API port or the
kotsadmService must stay aligned with the CLI port-forward target and the upgrade-service proxy path. - Changes to store initialization or migration order must preserve the startup requirement that handlers and background jobs see a ready store.
- Changes to generated workload settings must preserve the names used to recover secrets and environment values during Admin Console refresh.
- Changes to RBAC scope must cover both the Admin Console service account and every declared application namespace.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The store is not ready during startup | The API process stops before it serves requests | Bootstrap waits for store readiness and fails fast on error |
| The cluster bootstrap token does not map to a cluster | The operator cannot establish the active cluster context | Operator startup resolves the cluster ID before starting watches and work loops |
| A preflight request uses a version that is still pending download | The check or permission-error override is rejected | The handlers check downstream version status before starting the work |
| A preflight archive cannot be read | The service cannot start checks or create a client command | The handler returns an error before launching background work |
| The unauthenticated preflight callback contains invalid result data | The result is not stored and the caller receives an error | The callback validates the payload before saving it |
| A request reaches an API path with no matching route | The API returns a not-found response instead of the web UI | The router sends unmatched /api paths to the API not-found handler |
| The Admin Console service account lacks required namespace access | Application reads or changes fail even when the HTTP request is allowed | Installation creates cluster-scoped or minimal namespace-scoped RBAC from deployment settings |
| The preferred local port is already in use | The CLI cannot use the expected URL | Port-forward selects another port and reports it to the operator |
| A required application configuration value is unset | Installation or application work cannot proceed with a complete configuration | Configuration evaluation checks active required items before later actions |
Key files
| File | Why to read it |
|---|---|
| cmd/…/main.go | Shows the process entrypoint. |
| cmd/…/root.go | Shows command setup, store initialization, and environment mapping. |
| cmd/…/api.go | Shows how the API command passes runtime values into bootstrap. |
| pkg/…/server.go | Shows startup order, shared services, route groups, and the HTTP server boundary. |
| pkg/…/handlers.go | Shows route registration and the product capability groups exposed by HTTP. |
| pkg/…/preflight.go | Shows how preflight checks move between stored state, background work, and client callbacks. |
| pkg/…/serviceaccount.go | Shows the application service-account token and license synchronization flow. |
| pkg/…/interface.go | Shows the handler contract behind the route surface. |
| pkg/…/operator.go | Shows how long-running application and cluster work connects to shared state and Kubernetes. |
| pkg/…/store.go | Shows the process-wide state dependency used by the service. |
| pkg/…/admin-console.go | Shows how Admin Console installation settings are preserved and turned into workload resources. |
| pkg/…/kotsadm.go | Shows the high-level workload, Service, service account, and RBAC resource shape. |
| pkg/…/config.go | Shows how application configuration is checked and read from the cluster. |
| cmd/…/admin-console.go | Shows the operator-facing local access path to the in-cluster service. |