Skip to main content

OIDC API Proxy

Some organisations front their Kubernetes API server with an OIDC-aware reverse proxy (for example kube-oidc-proxy or a custom gateway) that validates bearer tokens centrally before forwarding requests to the kube-apiserver. Headlamp's OIDC API proxy feature lets you point Headlamp at that gateway instead of the kube-apiserver directly, so that the existing OIDC token issued to the browser is used end-to-end.

How it works​

When an API proxy is configured, every Kubernetes client Headlamp builds for the cluster gets the proxy URL as its server and the proxy's TLS settings instead of cluster.server and the cluster CA / client certificates. This covers:

  • the reverse proxy that serves the browser's REST requests,
  • WebSocket watches (per-request connections and the WebSocket multiplexer),
  • the Helm, port-forward and service-proxy handlers,
  • the authorization checks performed by the backend response cache.

The OIDC bearer token that is already stored in the per-cluster session cookie is forwarded in the Authorization: Bearer <token> header — exactly what the proxy expects. No additional credentials or client certificates are required.

When APIProxy is not set the behaviour is byte-identical to the default: the feature is strictly opt-in and additive.

The configuration keys intentionally mirror the auth.openid.api_proxy, api_proxy_ca_data and insecure_skip_verify_tls settings of Kiali, so a proxy that already serves Kiali can be reused for Headlamp as-is.

Requirements​

  • The proxy URL must be an absolute http:// or https:// URL. Headlamp refuses to start (or to load the kubeconfig context) otherwise.
  • The in-cluster flag --oidc-api-proxy only has an effect together with --oidc-client-id and --oidc-idp-issuer-url; setting it without them is a startup error.
  • --oidc-api-proxy cannot be combined with --unsafe-use-service-account-token: the proxy transport only ever carries the user's OIDC token, never the service account token.

Configuration​

Option A — CLI flags (in-cluster deployment)​

Use these flags when running Headlamp in-cluster and you want every request for the in-cluster context to go through the proxy.

FlagEnvironment variableDefaultDescription
--oidc-api-proxyHEADLAMP_CONFIG_OIDC_API_PROXY(empty)URL of the external Kubernetes API proxy.
--oidc-api-proxy-ca-fileHEADLAMP_CONFIG_OIDC_API_PROXY_CA_FILE(empty)Path to a PEM-encoded CA bundle used to verify the proxy's TLS certificate.
--oidc-api-proxy-skip-tls-verifyHEADLAMP_CONFIG_OIDC_API_PROXY_SKIP_TLS_VERIFYfalseDisable TLS verification for the proxy connection. Testing only.

Example:

headlamp-server \
--in-cluster \
--oidc-client-id=my-client \
--oidc-idp-issuer-url=https://dex.example.com \
--oidc-api-proxy=https://api-proxy.example.com/kubernetes \
--oidc-api-proxy-ca-file=/etc/headlamp/proxy-ca.pem

Helm​

Pass the flags via config.extraArgs and mount the CA file with volumes / volumeMounts in your values.yaml:

config:
extraArgs:
- --oidc-api-proxy=https://api-proxy.example.com/kubernetes
- --oidc-api-proxy-ca-file=/etc/headlamp/proxy-ca.pem

volumes:
- name: proxy-ca
secret:
secretName: headlamp-proxy-ca

volumeMounts:
- name: proxy-ca
mountPath: /etc/headlamp
readOnly: true

Option B — kubeconfig auth-provider (per-cluster)​

Use this approach when you manage multiple clusters via a kubeconfig file and only specific clusters should use a proxy.

users:
- name: my-user
user:
auth-provider:
name: oidc
config:
client-id: my-client
client-secret: my-secret
idp-issuer-url: https://dex.example.com
scope: "profile,email"
# api-proxy fields
api-proxy: https://api-proxy.example.com/kubernetes
api-proxy-ca-data: <base64-encoded PEM CA bundle>
api-proxy-skip-tls-verify: "false"
KeyRequiredDescription
api-proxyyes (to enable)URL of the external Kubernetes API proxy.
api-proxy-ca-datanoBase64-encoded PEM CA bundle for the proxy TLS certificate.
api-proxy-skip-tls-verifyno"true" to skip TLS verification. Testing only.

To base64-encode your CA file:

base64 -w 0 /path/to/proxy-ca.pem

TLS configuration​

Connections to the proxy use the proxy's own TLS settings, completely independent of the kube-apiserver client certificate or CA:

  • If api-proxy-ca-file / api-proxy-ca-data is provided, only that CA bundle is used to verify the proxy's certificate (instead of the system roots).
  • If neither is provided, the system CA pool is used.
  • api-proxy-ca-file is validated at startup and api-proxy-ca-data when the kubeconfig is loaded; an invalid CA bundle is reported as a configuration error instead of silently falling back to the system roots.

HTTP/2 note​

HTTP/2 is intentionally disabled towards the proxy. External proxies frequently send GOAWAY frames to rebalance connections; once the request body has been written the Go HTTP/2 client cannot retry and surfaces:

http2: Transport received Server's graceful shutdown GOAWAY

HTTP/1.1 retries this transparently. Headlamp restricts the TLS ALPN negotiation to http/1.1 for proxy connections.

Security considerations​

  • --oidc-api-proxy-skip-tls-verify / api-proxy-skip-tls-verify: "true" are intended for local testing only. A WARN log is emitted at startup when this option is set.
  • The proxy must be deployed so that it cannot be bypassed (e.g., via network policy) and must strip or reject any pre-existing Authorization headers from untrusted sources before forwarding to the kube-apiserver.
  • The OIDC bearer token is forwarded as-is; ensure your proxy validates it against the correct OIDC issuer and audience.