Opstella Keycloak Installation
This content is not available in your language yet.
Opstella Keycloak is a Single-Sign On and User Identity and Access Management System for Opstella.
Installation
Section titled “Installation”The following steps describe how to install Opstella Keycloak on the 🟢 Management cluster, utilizing PostgreSQL (via CloudnativePG) for metadata and SeaweedFS HA for database backups.
-
Connect to
🟢 ManagementKubernetes Cluster ; _i.e w/ Kubeconfig File.Ensure you have defined and loaded your Global Shell Variables as described in Shell Variables.
Terminal window source $HOME/opstella-installation/shell-values/kubernetes/management_cluster.vars.shTerminal window export KUBECONFIG="$HOME/opstella-installation/kubeconfigs/management_cluster.yaml" -
Export Required Shell Variables
Ensure
KEYCLOAK_DOMAINandKEYCLOAK_ADMIN_PASSWORDare defined as per the Shell Variables guide. Additionally, export the following backend-related variables:Terminal window # PostgreSQL Backend Passwordsexport KEYCLOAK_POSTGRES_SUPERUSER_PASSWORD="CHANGEME"export KEYCLOAK_POSTGRES_USER_PASSWORD="CHANGEME"export SEAWEEDFS_HA_S3_POSTGRES_BACKUP_PASSWORD="CHANGEME" # Match cnpg-backup password from Bootstrap# Infrastructure Configuration# Ensure `K8S_INGRESS_TLS_CERTIFICATE_SECRET_NAME` and `K8S_STORAGECLASS_NAME` are defined as per the [Shell Variables](/install/preparations/setup/shell-variables#%F0%9F%9F%A2-management) guide. -
Create Namespace for Keycloak
Terminal window kubectl create namespace opstella-identity-system -
Install PostgreSQL Backend (CloudnativePG)
Apply the PostgreSQL cluster manifest. This instance will store Keycloak’s identity data and configurations.
Terminal window cat <<EOF > $HOME/opstella-installation/kubernetes-manifests/keycloak-postgres.yaml---# Postgres Superuser (root) CredentialsapiVersion: v1kind: Secrettype: kubernetes.io/basic-authmetadata:name: keycloak-postgres-superusernamespace: opstella-identity-systemstringData:username: postgrespassword: "${KEYCLOAK_POSTGRES_SUPERUSER_PASSWORD}"---# Keycloak Application User CredentialsapiVersion: v1kind: Secrettype: kubernetes.io/basic-authmetadata:name: keycloak-postgres-usernamespace: opstella-identity-systemstringData:username: keycloakpassword: "${KEYCLOAK_POSTGRES_USER_PASSWORD}"---# S3 Credentials for Postgres Backups (to SeaweedFS HA)apiVersion: v1kind: Secrettype: Opaquemetadata:name: keycloak-postgres-s3-secretnamespace: opstella-identity-systemstringData:S3_ACCESS_KEY: "postgres-backup"S3_SECRET_KEY: "${SEAWEEDFS_HA_S3_POSTGRES_BACKUP_PASSWORD}"---apiVersion: barmancloud.cnpg.io/v1kind: ObjectStoremetadata:name: keycloak-postgres-backupnamespace: opstella-identity-systemspec:# This resource defines the backup destination for the Barman Cloud Pluginconfiguration:destinationPath: s3://postgres-backups/endpointURL: http://seaweedfs-s3.apps-supporting-services.svc:9000s3Credentials:accessKeyId:name: keycloak-postgres-s3-secretkey: S3_ACCESS_KEYsecretAccessKey:name: keycloak-postgres-s3-secretkey: S3_SECRET_KEYwal:compression: gzipdata:compression: gzip# Retention policy for backups and WALs handled by the pluginretentionPolicy: "30d"---apiVersion: postgresql.cnpg.io/v1kind: Clustermetadata:name: keycloak-postgresnamespace: opstella-identity-systemlabels:app.kubernetes.io/name: keycloak-postgresapp.kubernetes.io/part-of: keycloakspec:instances: 1# Image configuration (Postgres 15)imageName: ghcr.io/cloudnative-pg/postgresql:15# Enable the Barman Cloud Plugin for backupsplugins:- name: barman-cloud.cloudnative-pg.ioisWALArchiver: trueparameters:serverName: "keycloak-postgres"barmanObjectName: "keycloak-postgres-backup"# Storage Configurationstorage:size: 1GistorageClass: "${K8S_STORAGECLASS_NAME}"walStorage:size: 1GistorageClass: "${K8S_STORAGECLASS_NAME}"# Bootstrap Configurationbootstrap:initdb:database: keycloakowner: keycloak# Secret containing password for the SeaweedFS application usersecret:name: keycloak-postgres-user# Superuser credentials (root/postgres)superuserSecret:name: keycloak-postgres-superuser# Backup Configuration (Barman Cloud Plugin will automatically detect matching ObjectStore)backup:{}# Monitoring (disabled for now)monitoring:enablePodMonitor: false# Resourcesresources:requests:memory: "256Mi"cpu: "200m"limits:memory: "1Gi"cpu: "1000m"EOFTerminal window kubectl apply -f keycloak-postgres.yaml -
Create Keycloak Application Credentials
Apply the secret containing the Keycloak initial admin password.
Terminal window cat <<EOF > $HOME/opstella-installation/kubernetes-manifests/keycloak.yaml---apiVersion: v1kind: Secrettype: Opaquemetadata:name: keycloak-credentialsnamespace: opstella-identity-systemstringData:kc-admin-password: "${KEYCLOAK_ADMIN_PASSWORD}"EOFTerminal window kubectl apply -f keycloak.yaml -
Install Opstella Keycloak Helm Release
Install Keycloak into the
opstella-identity-systemnamespace using the provided values.Terminal window cat <<EOF > $HOME/opstella-installation/helm-values/keycloak-values.yamlimage:## @param image.registry Keycloak image registryregistry: asia-southeast1-docker.pkg.dev## @param image.repository Keycloak image repositoryrepository: opstella/platform/opstella-keycloak## @param image.tag Keycloak image tag (immutable tags are recommended)tag: "24.0.5-otv5.1.0"## @param image.imagePullPolicy Keycloak image pull policycontainerSecurityContext:seccompProfile:type: RuntimeDefaultkeycloak:adminUser: adminexistingSecret: keycloak-credentialssecretKeys:adminPasswordKey: kc-admin-passwordproxyHeaders: xforwardedproduction: truehttpRelativePath: /extraEnvVars:- name: KEYCLOAK_ADMINvalue: admin- name: KEYCLOAK_ADMIN_PASSWORDvalueFrom:secretKeyRef:name: keycloak-credentialskey: kc-admin-passworddatabase:type: postgreshost: keycloak-postgres-rw.opstella-identity-system.svcport: "5432"name: keycloakexistingSecret: keycloak-postgres-usersecretKeys:passwordKey: passwordusernameKey: usernamepostgres:enabled: falseingress:enabled: trueclassName: nginxannotations:nginx.ingress.kubernetes.io/proxy-buffer-size: 128kingress.kubernetes.io/proxy-body-size: 128khosts:- host: "${KEYCLOAK_DOMAIN}"paths:- path: /pathType: Prefixtls:- hosts:- "${KEYCLOAK_DOMAIN}"secretName: "${K8S_INGRESS_TLS_CERTIFICATE_SECRET_NAME}"preserveProviders: trueEOFTerminal window helm upgrade --install keycloak oci://registry-1.docker.io/cloudpirates/keycloak \--version 0.13.6 \--namespace opstella-identity-system \-f $HOME/opstella-installation/helm-values/keycloak-values.yaml
Post-Installation
Section titled “Post-Installation”-
Verify Pod Status
Terminal window kubectl get pods -n opstella-identity-system💡 All Keycloak components and the PostgreSQL cluster should be
Running:NAME READY STATUS RESTARTS AGEkeycloak-0 1/1 Running 0 ...keycloak-postgres-1 1/1 Running 0 ... -
Verify Keycloak UI Access
- Access the Keycloak UI at
https://${KEYCLOAK_DOMAIN}. - Click on Administration Console.
- Login with the
adminaccount and the password defined in${KEYCLOAK_ADMIN_PASSWORD}.
- Access the Keycloak UI at
Finished?
Use the below navigation to proceed