Skip to content

Commit

Permalink
Add test and preprod aks environments
Browse files Browse the repository at this point in the history
Addition of terraform tfvars for test and preprod aswell as updating
the makefile with the aks-test and aks-preprod targets, update the
config file and the gha workflows to set the deployment for these
environments as a matrix.
  • Loading branch information
shaheislamdfe committed Sep 25, 2024
1 parent 02dc1d3 commit c17d598
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 29 deletions.
9 changes: 7 additions & 2 deletions .github/actions/deploy-environment-aks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ inputs:
description: The pull request number which triggered this deploy.
required: false

outputs:
environment_url:
description: The base URL for the deployed environment
value: ${{ steps.set_outputs.outputs.ACCESS_URL }}

runs:
using: composite

Expand All @@ -40,8 +45,8 @@ runs:
shell: bash
id: set_outputs
run: |
output=$(terraform -chdir=terraform/application output -json urls)
echo "HOSTNAMES=$output" >> $GITHUB_ENV
access_url=$(terraform -chdir=terraform/application output -json urls | jq -r '.[0]')
echo "ACCESS_URL=$access_url" >> $GITHUB_OUTPUT
- name: Run smoke tests
shell: bash
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,31 @@ jobs:
| Access Your Teaching Qualifications | <https://access-your-teaching-qualifications-pr-${{ github.event.number }}.test.teacherservices.cloud> |
| Check A Teacher's Record | <https://check-a-teachers-record-pr-${{ github.event.number }}.test.teacherservices.cloud> |
deploy_aks:
name: Deploy to ${{ matrix.environment }} environment for AKS
runs-on: ubuntu-latest
if: github.event_name == 'push'
concurrency: deploy_${{ matrix.environment }}
needs: [build_image]
strategy:
max-parallel: 1
matrix:
environment: [aks-test, aks-preprod]
environment:
name: ${{ matrix.environment }}
url: ${{ steps.deploy.outputs.environment_url }}

steps:
- uses: actions/checkout@v4

- name: Deploy to AKS
uses: ./.github/actions/deploy-environment-aks
id: deploy
with:
environment: ${{ matrix.environment }}
image-tag: ${{ github.sha }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

set_matrix:
name: Set deployment matrix
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ aks-review: test-cluster ## Setup review environment for AKS
$(eval ENVIRONMENT=pr-${PR_NUMBER})
$(eval include global_config/review.sh)

.PHONY: aks-test
aks-test: test-cluster
$(eval include global_config/test.sh)

.PHONY: aks-preprod
aks-preprod: test-cluster
$(eval include global_config/preprod.sh)

composed-variables: ## Compose variables needed for deployments
$(eval RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg)
$(eval KEYVAULT_NAMES='("${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-app-kv", "${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-inf-kv")')
Expand Down
6 changes: 6 additions & 0 deletions global_config/preprod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG=preprod
ENVIRONMENT=preprod
CONFIG_SHORT=pp
AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test
AZURE_RESOURCE_PREFIX=s189t01
KV_PURGE_PROTECTION=false
6 changes: 6 additions & 0 deletions global_config/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG=test
ENVIRONMENT=test
CONFIG_SHORT=ts
AZURE_SUBSCRIPTION=s189-teacher-services-cloud-test
AZURE_RESOURCE_PREFIX=s189t01
KV_PURGE_PROTECTION=false
54 changes: 27 additions & 27 deletions terraform/application/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions terraform/application/config/preprod.tfvars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cluster": "test",
"namespace": "tra-test",
"evidence_container_retention_in_days": 1
}
1 change: 1 addition & 0 deletions terraform/application/config/preprod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions terraform/application/config/preprod_Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
aks:
source: "https://github.com/DFE-Digital/terraform-modules"
version: "testing"
5 changes: 5 additions & 0 deletions terraform/application/config/test.tfvars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cluster": "test",
"namespace": "tra-test",
"evidence_container_retention_in_days": 1
}
1 change: 1 addition & 0 deletions terraform/application/config/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions terraform/application/config/test_Terrafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
aks:
source: "https://github.com/DFE-Digital/terraform-modules"
version: "testing"

0 comments on commit c17d598

Please sign in to comment.