📚 Navigation: Main README | Documentation Index | Vault
This directory contains scripts and configuration files for setting up Keycloak as a Single Sign-On (SSO) provider for applications in the Kubernetes cluster.
Related Documentation:
- Main README - Platform capabilities
- Vault Setup - Secrets management
- Grafana SSO - Grafana integration
The setup consists of:
- Keycloak deployment in its own namespace
- Integration with the following applications:
- Grafana
- n8n
- WordPress
- Kubernetes cluster with kubectl access
- Keycloak installed and accessible at https://login.gray-beard.com
- Applications (Grafana, n8n, WordPress) installed and running
- Vault (optional) for secure credential storage
The initial Keycloak deployment was set up using the deploy-keycloak.sh script which:
- Creates a dedicated namespace
- Deploys PostgreSQL database
- Deploys Keycloak server
- Sets up TLS using Let's Encrypt certificates
- Configures Ingress for external access
The SSO configuration is handled by three separate scripts:
./configure-grafana-sso.shThis script:
- Creates a Keycloak realm (
xalg-apps) if it doesn't exist - Creates/updates a Keycloak client for Grafana
- Configures Grafana to use Keycloak for authentication
- Restarts the Grafana deployment to apply changes
./configure-n8n-sso.shThis script:
- Creates a Keycloak realm (
xalg-apps) if it doesn't exist - Creates/updates a Keycloak client for n8n
- Creates a Kubernetes secret with OIDC configuration
- Updates the n8n deployment to use the OIDC configuration
- Restarts the n8n deployment to apply changes
./configure-wordpress-sso.shThis script:
- Creates a Keycloak realm (
xalg-apps) if it doesn't exist - Creates/updates a Keycloak client for WordPress
- Creates a Kubernetes secret with OIDC configuration
- Creates a ConfigMap with plugin installation instructions
- Note: Requires manual installation of the OpenID Connect Generic plugin in WordPress
All SSO client secrets are stored in:
- Kubernetes secrets in each application's namespace
- HashiCorp Vault (if available) under
secret/[app-name]-sso
A test user with the following credentials is created:
- Username: testuser
- Password: testpassword
- Email: testuser@example.com
- Keycloak: https://login.gray-beard.com
- Grafana: https://grafana.gray-beard.com
- n8n: https://automate.gray-beard.com
- WordPress: https://blog.gray-beard.com
If you encounter issues with the SSO setup:
-
Check that Keycloak is running:
kubectl get pods -n keycloak
-
Verify that the applications are running:
kubectl get pods -n monitoring # For Grafana kubectl get pods -n n8n # For n8n kubectl get pods -n wordpress # For WordPress
-
Check the Keycloak logs:
kubectl logs -n keycloak deployment/keycloak
-
Check application logs for SSO-related errors:
kubectl logs -n monitoring deployment/[grafana-deployment-name] kubectl logs -n n8n deployment/n8n kubectl logs -n wordpress deployment/wordpress
-
Verify that the SSO client configurations exist in Keycloak:
- Open https://login.gray-beard.com
- Log in with admin credentials
- Navigate to "Clients" in the left sidebar
- Check that clients for Grafana, n8n, and WordPress exist
To remove the SSO configuration:
- Delete the Keycloak clients
- Remove the SSO configuration from each application
- Restart the applications