Deploy multiple instances

This guide provides an example how to deploy multiple instances of this component.

Requirements

  • commodore

  • pwgen

  • vault

  1. Prepare catalog

    # Add the instances and give them a name.
    applications:
    - keycloak as keycloak-test
    - keycloak as keycloak-prod
    
    parameters:
      # Configure the test instance with defaults and built-in database
      keycloak_test:
        namespace: tenant-keycloak-test
    
      # Configure the production instance using an external database
      keycloak_prod:
        namespace: tenant-keycloak-prod
        database:
          provider: external
          external:
            host: my-postgres-db-server.tld

    By default, the component configures the namespace with syn-<instance-name>. Using the syn- prefix might not be what you want when using multiple instances or when deploying Keycloak for another tenant. Use the namespace parameter to customize the namespace, but be sure that each instance gets their own namespace.

  2. Set secrets (don’t forget to also store certificates for each Keycloak instance)

    parent="clusters/kv/${TENANT_ID}/${CLUSTER_ID}"
    
    vault kv put "${parent}/keycloak-test" admin-password=$(pwgen -s 32 1) db-password=$(pwgen -s 32 1)
    vault kv put "${parent}/keycloak-prod" admin-password=$(pwgen -s 32 1) db-password=<your-external-db-password>
  3. Compile and push the cluster catalog

  4. Wait until changes are applied

  5. Verify that the instances are up and configured correctly