aksd: identify backend as aks-desktop in k8s API User-Agent#694
Closed
gambtho wants to merge 4 commits into
Closed
aksd: identify backend as aks-desktop in k8s API User-Agent#694gambtho wants to merge 4 commits into
gambtho wants to merge 4 commits into
Conversation
The User-Agent attached to Kubernetes API server requests is built from the package-level AppName variable in pkg/kubeconfig. Allow downstream embedders (such as AKS Desktop) to white-label this identifier by setting HEADLAMP_APP_NAME in the backend process environment. When unset or empty, the default "Headlamp" is preserved.
Set HEADLAMP_APP_NAME=aks-desktop when spawning the bundled Headlamp backend from the Electron shell. The backend uses this value as the product name in the User-Agent header it attaches to all Kubernetes API server requests, so Azure-side audit logs and telemetry attribute traffic to AKS Desktop rather than upstream Headlamp.
Have applyAppNameOverride return only the env value (or "") so the "Headlamp" default lives in exactly one place — the AppName var declaration. init() now updates AppName only when an override is present. Tests updated to match the new contract.
The pointer in the comment used the outer aks-desktop submodule path (headlamp/backend/...) rather than the path inside the Headlamp repository (backend/...).
4 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR lets AKS Desktop identify its bundled Headlamp backend as aks-desktop in Kubernetes API User-Agent strings by adding a backend app-name override and setting it from the Electron launcher.
Changes:
- Adds
HEADLAMP_APP_NAMEoverride plumbing in kubeconfig initialization. - Exposes the override helper for tests and adds unit coverage for helper behavior.
- Sets
HEADLAMP_APP_NAME=aks-desktopbefore spawning the bundled backend.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
backend/pkg/kubeconfig/kubeconfig.go |
Adds app-name override helper and initialization hook. |
backend/pkg/kubeconfig/export_test.go |
Exposes the helper to external package tests. |
backend/pkg/kubeconfig/appname_override_test.go |
Adds unit tests for env override helper behavior. |
app/electron/main.ts |
Sets backend app name to aks-desktop from the Electron process. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+869
to
+870
| // User-Agent for all proxied k8s requests. See | ||
| // backend/pkg/kubeconfig/kubeconfig.go (applyAppNameOverride). |
| // The backend reads HEADLAMP_APP_NAME at startup and uses it in the | ||
| // User-Agent for all proxied k8s requests. See | ||
| // backend/pkg/kubeconfig/kubeconfig.go (applyAppNameOverride). | ||
| process.env.HEADLAMP_APP_NAME = 'aks-desktop'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
applyAppNameOverridehelper +init()inbackend/pkg/kubeconfig/kubeconfig.gothat readsHEADLAMP_APP_NAMEfrom the process environment and overrides the package-levelAppName(default stillHeadlamp). Unit-tested via an injected env getter.HEADLAMP_APP_NAME=aks-desktopwhen the Electron shell spawns the bundled backend, so all proxied Kubernetes API requests carry `User-Agent: aks-desktop (/)` instead of `Headlamp ...`. Azure-side audit logs and telemetry can now attribute traffic to AKS Desktop.Two commits:
The submodule pointer bump in `Azure/aks-desktop` is a separate PR.
Test plan