Kubernetes
Authentication
Desktop UI
Configuration
Login System

How to config simple login/pass authentication for kubernetes desktop UI

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Teams often ask for simple username and password access to a Kubernetes desktop UI, but modern Kubernetes Dashboard authentication is primarily token-based. The practical approach is to keep Kubernetes-native RBAC and place a password gate in front of the UI if needed. That gives familiar desktop login behavior without discarding cluster security controls.

Core Sections

Understand the authentication model first

Kubernetes Dashboard does not rely on legacy basic auth built into the API server in most current environments. The supported path is a service account token with RBAC permissions. If your requirement says "login and password," treat that as an outer access layer, then keep token authorization inside the cluster.

A secure design for desktop usage usually has three layers. First, least-privilege RBAC controls what the account can do. Second, network controls limit where the dashboard is reachable. Third, short-lived credentials reduce the blast radius if a token leaks.

Create a least-privilege dashboard account

Start by creating a dedicated service account and bind it to a narrow role. For read-only usage, the built-in view role is a good baseline.

yaml
1apiVersion: v1
2kind: ServiceAccount
3metadata:
4  name: dashboard-viewer
5  namespace: kubernetes-dashboard
6---
7apiVersion: rbac.authorization.k8s.io/v1
8kind: ClusterRoleBinding
9metadata:
10  name: dashboard-viewer-binding
11subjects:
12  - kind: ServiceAccount
13    name: dashboard-viewer
14    namespace: kubernetes-dashboard
15roleRef:
16  kind: ClusterRole
17  name: view
18  apiGroup: rbac.authorization.k8s.io

Apply this once, then generate a token when needed.

bash
kubectl apply -f dashboard-viewer.yaml
kubectl -n kubernetes-dashboard create token dashboard-viewer

Avoid binding cluster-admin unless the person truly needs full control. Even in internal environments, broad permissions turn minor mistakes into cluster-wide incidents.

Add username and password at the ingress layer

If you need a literal username and password prompt, add HTTP basic auth in front of the dashboard endpoint using ingress-nginx. This gives a desktop-friendly gate while preserving Kubernetes token login downstream.

bash
htpasswd -c auth dashboard-user
kubectl -n kubernetes-dashboard create secret generic dashboard-basic-auth   --from-file=auth
yaml
1apiVersion: networking.k8s.io/v1
2kind: Ingress
3metadata:
4  name: dashboard-ingress
5  namespace: kubernetes-dashboard
6  annotations:
7    nginx.ingress.kubernetes.io/auth-type: basic
8    nginx.ingress.kubernetes.io/auth-secret: dashboard-basic-auth
9    nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - Dashboard'
10spec:
11  ingressClassName: nginx
12  rules:
13    - host: dashboard.local
14      http:
15        paths:
16          - path: /
17            pathType: Prefix
18            backend:
19              service:
20                name: kubernetes-dashboard-kong-proxy
21                port:
22                  number: 443

Use TLS for this endpoint, even on internal networks. Password prompts over plain HTTP are easy to intercept.

Establish an operational login workflow

For daily use, document a repeatable flow: connect to the trusted network, pass ingress basic auth, then paste a short-lived dashboard token. Automate token minting in a script if your team logs in frequently.

bash
1#!/usr/bin/env bash
2set -euo pipefail
3
4NAMESPACE="kubernetes-dashboard"
5SERVICE_ACCOUNT="dashboard-viewer"
6
7echo "Token for ${SERVICE_ACCOUNT}:"
8kubectl -n "$NAMESPACE" create token "$SERVICE_ACCOUNT" --duration=2h

This workflow keeps the user experience simple while maintaining clear boundaries between transport security, edge authentication, and Kubernetes authorization.

In larger organizations, approval and audit requirements often matter as much as the login prompt itself. Track who can request dashboard access, how long access stays active, and how revocation is performed during offboarding. Even a short checklist in your team runbook makes day-to-day operations safer. It also helps incident response because responders can quickly verify expected access paths without reverse engineering cluster policy during an outage.

Common Pitfalls

  • Treating deprecated API server basic auth as the default modern approach.
  • Exposing the dashboard publicly without an IP allowlist or VPN boundary.
  • Granting cluster-admin to every desktop user for convenience.
  • Using long-lived static tokens with no rotation process.
  • Forgetting TLS on ingress and sending credentials in clear text.

Summary

  • Keep Kubernetes authorization token-based with explicit RBAC.
  • Add username and password at ingress only if desktop UX requires it.
  • Prefer least-privilege roles such as view for routine access.
  • Use short-lived tokens and automate token issuance safely.
  • Protect the dashboard endpoint with TLS and network restrictions.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.