Dashboard authentication using Keycloak ¶
Steps to install OIDC authenticator and setup authentication ¶
- install keycloak
curl -LO https://raw.githubusercontent.com/keycloak/keycloak-quickstarts/latest/kubernetes-examples/keycloak.yaml
# above file has keycloak service as LoadBalancer. Please change the same to ClusterIP
kubectl apply -f keycloak.yaml
- create realm, client, users and group in keycloak. Optionally, you can also connect to another OIDC server to delegate authentication.
- Assign custom mappers for client scope "email" to add a) groups of type "Group membership" for "groups" claim a) audience for "aud" claim
- Enable OIDC authentication in KOPS
kops edit cluster ${NAME}
# add below
spec:
kubeAPIServer:
oidcClientID: k8s-dashboard
oidcGroupsClaim: groups
oidcIssuerURL: https://keycloak.kops.dh4r4pvj.ga/auth/realms/k8s-user
oidcUsernameClaim: email
# save the changes
kops update cluster ${NAME} --yes
kops rolling-update cluster --cloudonly --yes
- deploy kubernetes dashboard and keycloak-proxy, clusterroles and clusterrolebinding
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
kubectl apply -f dashboard-proxy.yaml # this file is present in same directory in github
- Login as adm and regular user (no good way to logout)
- Profit!!
References: ¶
- https://itnext.io/protect-kubernetes-dashboard-with-openid-connect-104b9e75e39c
- https://medium.com/@int128/kubectl-with-openid-connect-43120b451672
- https://devopstales.github.io/sso/k8s-dasboard-auth/
Categories
- Keycloak
- authentication
- dashboard
- oidc
- authorization