Skip to content

Commit

Permalink
add dispatch workflow to deploy load balancer
Browse files Browse the repository at this point in the history
As the Kubernetes load balancer service for the mongo-express application
does not require redeployment on every application change, add a dispatch
workflow to perform the deployment of the load balancer service only
when triggered by an administrative dispatch event.

This GitHub Actions workflow expects an Azure Kubernetes Service cluster
to exist and for its name and resource group to be configured as
GitHub Actions secrets, as well as the Azure login credentials.

After deployment of the persistent volumes manifest, the workflow
uses kubectl to wait for the service's ingress IP to be assigned.
Unfortunately this can not be done exclusively with the "kubectl wait"
command as its JSON condition matching requires a fixed string, and
the IP address cannot be known in advance.  Instead, use "kubectl get"
in a loop and wait for the load balancer's status to contain an
"ingress" key, as suggested in:

kubernetes/kubernetes#80828 (comment)

See also this concern regarding how JSON condition matching was
implemented for "kubectl wait":

kubernetes/kubernetes#83094 (comment)
  • Loading branch information
chrisd8088 committed Mar 15, 2023
1 parent 6a4d482 commit 926853c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/deploy-app-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy Application Load Balancer

on:
workflow_dispatch:

jobs:
deploy:
name: Load Balancer Service Deployment
runs-on: ubuntu-latest

steps:
- name: Checkout Git branch
uses: actions/checkout@v3

- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Set Azure Kubernetes Service configuration
uses: azure/aks-set-context@v3
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
cluster-name: ${{ secrets.CLUSTER_NAME }}

- name: Deploy application load balancer service
uses: Azure/k8s-deploy@v4
with:
action: deploy
manifests: |
manifests/app-service.yml
- name: Setup kubectl
uses: azure/setup-kubectl@v3

- name: Wait for service ingress IP assignment
run: |
timeout 300s sh \
-c 'until kubectl get service frontend --output=jsonpath='{.status.loadBalancer}' | grep ingress; do : ; done'

0 comments on commit 926853c

Please sign in to comment.