K9s is the command-line lens into your Kubernetes clusters. Keycloak is the fortress standing guard over your authentication and identity. Put them together, and you get speed with security—if you configure them right. That’s the trick: right means no secret files floating around, no manual token juggling, no “why is this failing after 10 minutes?” moments.
K9s and Keycloak integrate cleanly when token-based authentication flows match Kubernetes’ expectations. Start with an OpenID Connect client in Keycloak. Give it the scopes Kubernetes needs: openid, profile, and email. Enable "service accounts"only if machine-to-machine access is part of your plan. Point Kubernetes’ API server to Keycloak’s discovery endpoint. Store your CA certificates in a secure location. Make sure kubectl works with your Keycloak user before even launching K9s.
The short path:
- Create a public client in Keycloak for CLI access.
- Map roles in Keycloak to Kubernetes RBAC groups.
- Use an OIDC plugin for
kubectlto retrieve tokens. - Launch K9s and watch it respect your Keycloak-backed session.
Session lifetimes are your bottleneck. Keycloak defaults will expire a token before a long troubleshooting session finishes. Adjust realm token lifespans to match operational needs, or enable refresh tokens that actually refresh without a full re-login.