Signed-off-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>
6.8 KiB
title, description, summary, date, draft, images, weight, toc, aliases, support, seo
| title | description | summary | date | draft | images | weight | toc | aliases | support | seo | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Kube Login | Integrating Kube Login with the Authelia OpenID Connect 1.0 Provider. | 2025-07-11T12:25:57+00:00 | false | 620 | true |
|
|
|
Tested Versions
{{% oidc-common %}}
Assumptions
This example makes the following assumptions:
- Authelia Root URL:
https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}/ - Client ID:
kube_login - Client Secret:
insecure_secret
Some of the values presented in this guide can automatically be replaced with documentation variables.
{{< sitevar-preferences >}}
Configuration
Authelia
The following YAML configuration is an example Authelia client configuration for use with Kube Login which will operate with the application example:
identity_providers:
oidc:
## The other portions of the mandatory OpenID Connect 1.0 configuration go here.
## See: https://www.authelia.com/c/oidc
clients:
- client_id: 'kube_login'
client_name: 'Kubernetes Cluster Access'
client_secret: 'insecure_secret'
public: false
authorization_policy: 'two_factor'
redirect_uris:
- 'http://localhost:8000'
- 'http://localhost:18000'
scopes:
- 'openid'
- 'groups'
- 'email'
- 'profile'
userinfo_signed_response_alg: 'none'
token_endpoint_auth_method: 'client_secret_basic'
{{< callout context="note" title="Token Authentication" icon="outline/info-circle" >}} Kubernetes uses OIDC ID tokens (JWTs) for user authentication. While Kube Login supports access tokens (opaque) per the OAuth2 specification, Kubernetes has minimal support for this method. {{< /callout >}}
Kubernetes API Server Configuration
Configure your Kubernetes API server to trust Authelia as an OIDC provider by adding these arguments:
--oidc-issuer-url=https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}
--oidc-client-id=kube_login
--oidc-groups-claim=groups
See the Kubernetes Flags Documentation for more information on these options.
How to Apply These Arguments
The method for configuring API server arguments varies by Kubernetes distribution. Consult the Kubernetes OIDC Authentication documentation for detailed instructions on applying these arguments to your specific setup.
Common distributions:
- K3s: Add to
/etc/rancher/k3s/config.yamlunderkube-apiserver-arg: - kubeadm: Edit
/etc/kubernetes/manifests/kube-apiserver.yaml - Managed services: Use provider-specific tools (AWS CLI, gcloud, az cli)
RBAC Configuration
After configuring OIDC authentication, create RBAC rules to authorize your users. Choose the approach that fits your needs:
Group-Based Access
# Admins group - full cluster access
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: 'authelia-admins'
subjects:
- kind: Group
name: 'admins'
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: 'cluster-admin' # NOTE this role gives COMPLETE access to the kubernetes api
apiGroup: rbac.authorization.k8s.io
---
# Developers group - namespace-specific access
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: 'authelia-developers'
namespace: development
subjects:
- kind: Group
name: 'developers'
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: 'edit'
apiGroup: rbac.authorization.k8s.io
Per User Access
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: 'authelia-user-admin'
subjects:
- kind: User
name: 'https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}}#your-user-sub-claim'
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: 'cluster-admin' # NOTE this role gives COMPLETE access to the kubernetes api
apiGroup: rbac.authorization.k8s.io
Note: You can obtain all user sub identifiers using the following command: authelia storage user identifiers export
Client Configuration (kubectl + kubelogin)
Install Required Tools
- Install kubectl (if not already installed) - Installation Guide
- Install krew (kubectl plugin manager): - Installation Guide
- Install kubelogin -
kubectl krew install oidc-login
Configure kubeconfig
Use kubectl commands to set up the OIDC user on your local machine:
kubectl config set-credentials authelia \
--exec-api-version=client.authentication.k8s.io/v1beta1 \
--exec-command=kubectl \
--exec-arg=oidc-login \
--exec-arg=get-token \
--exec-arg=--oidc-issuer-url=https://{{< sitevar name="subdomain-authelia" nojs="auth" >}}.{{< sitevar name="domain" nojs="example.com" >}} \
--exec-arg=--oidc-client-id=kube_login \
--exec-arg=--oidc-client-secret=insecure_secret \
--exec-arg=--oidc-extra-scope=groups
Setup Context
Create and use a context with the OIDC user:
# Create context (replace 'your-cluster' with your actual cluster name)
kubectl config set-context authelia \
--cluster=your-cluster \
--user=authelia
# Switch to the new context
kubectl config use-context authelia
Testing the Configuration
# This should start the OIDC authentication flow in your browser.
kubectl get nodes