Multi-AZ Clusters - Create and Deploy Keycloak #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Multi-AZ Clusters - Create and Deploy Keycloak | |
on: | |
workflow_dispatch: | |
inputs: | |
clusterPrefix: | |
description: 'The prefix to be used when creating the clusters' | |
type: string | |
region: | |
description: 'The AWS region to create both clusters in. Defaults to "vars.AWS_DEFAULT_REGION" if omitted.' | |
type: string | |
createCluster: | |
description: 'Check to Create Cluster.' | |
type: boolean | |
default: true | |
keycloakRepository: | |
description: 'The repository to deploy Keycloak from. If not set nightly image is used' | |
type: string | |
keycloakBranch: | |
description: 'The branch to deploy Keycloak from. If not set nightly image is used' | |
type: string | |
workflow_call: | |
inputs: | |
clusterPrefix: | |
description: 'The prefix to be used when creating the clusters' | |
type: string | |
region: | |
description: 'The AWS region to create both clusters in. Defaults to "vars.AWS_DEFAULT_REGION" if omitted.' | |
type: string | |
createCluster: | |
description: 'Check to Create Cluster' | |
type: boolean | |
default: true | |
keycloakRepository: | |
description: 'The repository to deploy Keycloak from. If not set nightly image is used' | |
type: string | |
keycloakBranch: | |
description: 'The branch to deploy Keycloak from. If not set nightly image is used' | |
type: string | |
env: | |
CLUSTER_PREFIX: ${{ inputs.clusterPrefix || format('gh-{0}', github.repository_owner) }} | |
REGION: ${{ inputs.region || vars.AWS_DEFAULT_REGION }} | |
jobs: | |
# Workaround required for passing env variables to reusable workflow declarations as ${{ env.* }} is not available | |
meta: | |
runs-on: ubuntu-latest | |
outputs: | |
clusterPrefix: ${{ env.CLUSTER_PREFIX }} | |
region: ${{ env.REGION }} | |
steps: | |
- run: echo "" | |
cluster: | |
if: ${{ inputs.createCluster }} | |
needs: meta | |
strategy: | |
matrix: | |
availabilityZone: [ a, b ] | |
# It is currently not safe to run the cluster creation in parallel, as both might pick the same CIDR, which then leads to conflicts | |
max-parallel: 1 | |
uses: ./.github/workflows/rosa-cluster-create.yml | |
with: | |
clusterName: ${{ needs.meta.outputs.clusterPrefix }}-${{ matrix.availabilityZone }} | |
region: ${{ needs.meta.outputs.region }} | |
availabilityZones: ${{ needs.meta.outputs.region }}${{ matrix.availabilityZone }} | |
secrets: inherit | |
deploy-keycloak: | |
runs-on: ubuntu-latest | |
if: ${{ (always() && needs.cluster.result == 'skipped' && !inputs.createCluster) || success()}} | |
needs: [cluster] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup ROSA CLI | |
uses: ./.github/actions/rosa-cli-setup | |
with: | |
aws-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-default-region: ${{ vars.AWS_DEFAULT_REGION }} | |
rosa-token: ${{ secrets.ROSA_TOKEN }} | |
- name: Scale ROSA clusters | |
run: | | |
rosa edit machinepool -c ${{ env.CLUSTER_PREFIX }}-a --min-replicas 3 scaling | |
rosa edit machinepool -c ${{ env.CLUSTER_PREFIX }}-b --min-replicas 3 scaling | |
- name: Setup Go Task | |
uses: ./.github/actions/task-setup | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Monitoring | |
working-directory: provision/rosa-cross-dc | |
run: task monitoring | |
env: | |
ROSA_CLUSTER_NAME_1: ${{ env.CLUSTER_PREFIX }}-a | |
ROSA_CLUSTER_NAME_2: ${{ env.CLUSTER_PREFIX }}-b | |
- name: Create Route53 Loadbalancer | |
working-directory: provision/rosa-cross-dc | |
run: | | |
task route53 > route53 | |
echo "KC_CLIENT_URL=$(grep -Po 'Client Site URL: \K.*' route53)" >> $GITHUB_ENV | |
echo "KC_HEALTH_URL_CLUSTER_1=$(grep -Po 'Primary Site URL: \K.*' route53)" >> $GITHUB_ENV | |
echo "KC_HEALTH_URL_CLUSTER_2=$(grep -Po 'Backup Site URL: \K.*' route53)" >> $GITHUB_ENV | |
env: | |
ROSA_CLUSTER_NAME_1: ${{ env.CLUSTER_PREFIX }}-a | |
ROSA_CLUSTER_NAME_2: ${{ env.CLUSTER_PREFIX }}-b | |
- name: Deploy | |
working-directory: provision/rosa-cross-dc | |
run: task | |
env: | |
AURORA_CLUSTER: ${{ env.CLUSTER_PREFIX }} | |
AURORA_REGION: ${{ env.REGION }} | |
ROSA_CLUSTER_NAME_1: ${{ env.CLUSTER_PREFIX }}-a | |
ROSA_CLUSTER_NAME_2: ${{ env.CLUSTER_PREFIX }}-b | |
KC_CPU_REQUESTS: 6 | |
KC_INSTANCES: 3 | |
KC_DISABLE_STICKY_SESSION: true | |
KC_MEMORY_REQUESTS_MB: 4000 | |
KC_MEMORY_LIMITS_MB: 4000 | |
KC_HEAP_MAX_MB: 2048 | |
KC_DB_POOL_INITIAL_SIZE: 30 | |
KC_DB_POOL_MAX_SIZE: 30 | |
KC_DB_POOL_MIN_SIZE: 30 | |
KC_DATABASE: "aurora-postgres" | |
MULTI_AZ: "true" | |
KC_REPOSITORY: ${{ inputs.keycloakRepository }} | |
KC_BRANCH: ${{ inputs.keycloakBranch }} |