Test AKS Configuration #2
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: Test AKS Configuration | |
on: workflow_dispatch | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: aaf6ee.azurecr.io | |
username: ${{ secrets.ACR_LOGIN }} | |
password: ${{ secrets.ACR_SECRET }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v4 | |
with: | |
push: true # Will only build if this is not here | |
context: azure-vote | |
tags: | | |
aaf6ee.azurecr.io/${{ github.repository }}:${{ github.sha }} | |
aaf6ee.azurecr.io/${{ github.repository }}:latest | |
load-test: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
frontend_replicas: [3, 5] | |
frontend_cpu_limit: [250m, 500m] | |
frontend_mem_limit: [256Mi, 512Mi] | |
max-parallel: 1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Azure authentication (load testing) | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Get AKS Credentials | |
run: | | |
az aks get-credentials --resource-group ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} --name ${{ secrets.AKS_NAME }} | |
- name: Apply Kubernetes Configuration | |
run: | | |
envsubst < app.yaml | kubectl apply -f - | |
env: | |
FRONTEND_REPLICAS: ${{ matrix.frontend_replicas }} | |
FRONTEND_CPU_LIMIT: ${{ matrix.frontend_cpu_limit }} | |
FRONTEND_MEM_LIMIT: ${{ matrix.frontend_mem_limit }} | |
FRONTEND_IMAGE: aksloadtestdemo.azurecr.io/${{ github.repository }}:${{ github.sha }} | |
- name: Create version ID | |
id: version | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
echo "FRONTEND_HOST=$(kubectl get service azure-vote-front -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" >> $GITHUB_OUTPUT | |
- name: 'Azure Load Testing' | |
uses: azure/load-testing@v1.1.14 | |
with: | |
loadTestConfigFile: 'loadtests/configuration-test.yaml' | |
loadTestResource: ${{ secrets.AZURE_LOAD_TEST_NAME }} | |
loadTestRunName: "Automated Test Run ${{ steps.version.outputs.sha_short }}" | |
loadTestRunDescription: "frontend (${{ matrix.frontend_replicas }}, ${{ matrix.frontend_cpu_limit }}, ${{ matrix.frontend_mem_limit }})" | |
resourceGroup: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }} | |
env: | | |
[ | |
{ | |
"name": "host", | |
"value": "${{ steps.version.outputs.FRONTEND_HOST }}" | |
} | |
] | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: loadTestResults | |
path: ${{ github.workspace }}/loadTest |