Skip to content

Commit 764f17e

Browse files
authored
Merge pull request #140 from adamrushuk/develop
v1.1.0 release
2 parents 2f58880 + 93c126a commit 764f17e

28 files changed

+353
-227
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
2-
name: Build env
2+
name: Build environment
33

44
# name of GitHub event that triggers workflow
55
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#watch-event-watch
@@ -44,7 +44,6 @@ env:
4444
EMAIL_ADDRESS: [email protected]
4545
ENABLE_TLS_INGRESS: true
4646
FORCE_TEST_FAIL: false
47-
HAS_SUBDOMAIN: true
4847
K8S_TLS_SECRET_NAME: tls-secret
4948
KEY_VAULT_NAME: kv-rush-iz6y
5049
KEY_VAULT_CERT_NAME: wildcard-thehypepipe-co-uk
@@ -107,6 +106,12 @@ jobs:
107106
- name: Login to Azure
108107
run: ./scripts/azure_login.sh
109108

109+
# This is required when developing after the initial build, and the AKS cluster may have been stopped
110+
# Ensure AKS cluster is running, else timeouts will occur on k8s Terraform apply tasks
111+
- name: Start AKS Cluster
112+
continue-on-error: true
113+
run: ./scripts/start_aks_cluster.sh
114+
110115

111116
# Prereqs
112117
- name: Create Storage Account for Terraform state
@@ -209,15 +214,23 @@ jobs:
209214
run: ./scripts/push_docker_images.sh
210215

211216

217+
# TODO: Remove once issue has been fixed
218+
# https://github.com/terraform-providers/terraform-provider-azurerm/issues/8546
219+
- name: Restart Function App
220+
run: az functionapp restart --name "${{ env.PREFIX }}-funcapp" --resource-group "${{ env.PREFIX }}-rg-function-app"
221+
222+
212223
# Pester tests
213224
- name: Run Pester tests
225+
continue-on-error: true
214226
run: pwsh -command "./scripts/Start-Test.ps1"
215227

216228
- name: Archive test artifacts
217229
uses: actions/upload-artifact@v1
218230
with:
219231
name: test results
220232
path: test/pester-test-results.xml
233+
# TODO: only run when previous task (Pester tests) has been successful
221234
if: always()
222235

223236
# remove NuGet proxy repo so pester report step doesnt fail
@@ -226,6 +239,8 @@ jobs:
226239

227240
# Shows at the bottom of a run: https://github.com/adamrushuk/aks-nexus-velero/runs/1035347513?check_suite_focus=true
228241
- name: Pester report
242+
# TODO: remove continue-on-error once bug is fixed
243+
continue-on-error: true
229244
uses: zyborg/[email protected]
230245
with:
231246
test_results_path: test/pester-test-results.xml
@@ -237,11 +252,9 @@ jobs:
237252
# Notify
238253
- name: Notify slack
239254
env:
255+
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
240256
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
241-
uses: pullreminders/[email protected]
242-
with:
243-
# env var concatenation not supported atm, so hard-code messages
244-
args: '{\"channel\":\"C012ZQHT9A4\",\"text\":\"[aks-nexus-velero] Build complete\"}'
257+
run: ./scripts/send_slack_message.sh "[aks-nexus-velero] Build complete"
245258

246259

247260
# used for any windows-only tasks

.github/workflows/destroy.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ env:
3737
EMAIL_ADDRESS: [email protected]
3838
ENABLE_TLS_INGRESS: true
3939
FORCE_TEST_FAIL: false
40-
HAS_SUBDOMAIN: true
4140
K8S_TLS_SECRET_NAME: tls-secret
4241
KEY_VAULT_NAME: kv-rush-iz6y
4342
KEY_VAULT_CERT_NAME: wildcard-thehypepipe-co-uk
@@ -68,6 +67,8 @@ jobs:
6867

6968
steps:
7069
# Checkout
70+
# Reference the major version of a release
71+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#example-using-versioned-actions
7172
- uses: actions/checkout@v2
7273
# specify different branch
7374
# NOT required as I've changed the default branch to develop
@@ -92,23 +93,13 @@ jobs:
9293
env:
9394
GITHUB_CONTEXT: ${{ toJson(github) }}
9495

95-
# # Trigger workflow via Repository Dispatch
96-
# - name: Trigger start_aks_vmss Workflow
97-
# uses: peter-evans/repository-dispatch@v1
98-
# with:
99-
# token: ${{ secrets.REPO_ACCESS_TOKEN }}
100-
# repository: adamrushuk/aks-nexus-velero
101-
# event-type: start_vmss
102-
# client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
103-
10496
# Login
10597
- name: Login to Azure
10698
run: ./scripts/azure_login.sh
10799

108-
# Ensure VMSS is started, else timeouts will occur on k8s Terraform resource destroy tasks
109-
- name: Start AKS VMSS
110-
run: ./scripts/start_aks_vmss.sh
111-
100+
# Ensure AKS cluster is running, else timeouts will occur on k8s Terraform resource destroy tasks
101+
- name: Start AKS Cluster
102+
run: ./scripts/start_aks_cluster.sh
112103

113104
# Prereqs
114105
- name: Lookup Storage Key
@@ -122,28 +113,24 @@ jobs:
122113
- name: Create zip file of Function App
123114
run: pwsh -command "./function_app/CreateFunctionAppZip.ps1"
124115

125-
126116
# Terraform
127117
- uses: hashicorp/setup-terraform@v1
128118
with:
129119
terraform_version: ${{ env.TF_VERSION }}
120+
130121
- name: Terraform destroy
131122
run: |
132123
terraform init
133124
terraform destroy -no-color -auto-approve
134125
working-directory: ${{ env.TF_WORKING_DIR }}
135126

136-
137127
# Cleanup
138128
- name: Delete Storage
139129
run: ./scripts/storage_delete.sh
140130

141-
142131
# Notify
143132
- name: Notify slack
144133
env:
134+
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
145135
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
146-
uses: pullreminders/[email protected]
147-
with:
148-
# env var concatenation not supported atm, so hard-code messages
149-
args: '{\"channel\":\"C012ZQHT9A4\",\"text\":\"[aks-nexus-velero] Destroy complete\"}'
136+
run: ./scripts/send_slack_message.sh "[aks-nexus-velero] Destroy complete"
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Start AKS VMSS
1+
name: Start AKS Cluster
22

33
on:
44
repository_dispatch:
55
# name of GitHub event that triggers workflow
6-
types: [start_vmss]
6+
types: [start_aks_cluster]
77

88
# enable manual workflow
99
# https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#manually-running-a-workflow
@@ -25,7 +25,7 @@ env:
2525
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
2626

2727
jobs:
28-
start_vmss:
28+
start_aks_cluster:
2929
runs-on: ubuntu-18.04
3030

3131
# only run if owner triggered action
@@ -46,25 +46,18 @@ jobs:
4646
echo "AKS_RG_NAME=${{ env.PREFIX }}-rg-aks-dev-001" >> $GITHUB_ENV
4747
echo "AKS_CLUSTER_NAME=${{ env.PREFIX }}-aks-001" >> $GITHUB_ENV
4848
49-
# Show event info
50-
- name: Show triggered event data
51-
run: pwsh -command "./scripts/Get-EventData.ps1"
52-
env:
53-
GITHUB_CONTEXT: ${{ toJson(github) }}
54-
5549
# Login
5650
- name: Login to Azure
5751
run: ./scripts/azure_login.sh
5852

5953
# Start
60-
- name: Start AKS VMSS
61-
run: ./scripts/start_aks_vmss.sh
54+
# Prereqs: https://docs.microsoft.com/en-us/azure/aks/start-stop-cluster
55+
- name: Start AKS Cluster
56+
run: ./scripts/start_aks_cluster.sh
6257

6358
# Notify
6459
- name: Notify slack
6560
env:
61+
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
6662
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
67-
uses: pullreminders/[email protected]
68-
with:
69-
# env var concatenation not supported atm, so hard-code messages
70-
args: '{\"channel\":\"C012ZQHT9A4\",\"text\":\"[aks-nexus-velero] Start AKS VMSS complete\"}'
63+
run: ./scripts/send_slack_message.sh "[aks-nexus-velero] Start AKS Cluster complete"
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Deallocate AKS VMSS
1+
name: Stop AKS Cluster
22

33
on:
44
repository_dispatch:
55
# name of GitHub event that triggers workflow
6-
types: [deallocate_vmss]
6+
types: [stop_aks_cluster]
77

88
# enable manual workflow
99
# https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#manually-running-a-workflow
@@ -25,7 +25,7 @@ env:
2525
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
2626

2727
jobs:
28-
deallocate_vmss:
28+
stop_aks_cluster:
2929
runs-on: ubuntu-18.04
3030

3131
# only run if owner triggered action
@@ -45,25 +45,19 @@ jobs:
4545
chmod -R +x ./scripts/
4646
echo "AKS_RG_NAME=${{ env.PREFIX }}-rg-aks-dev-001" >> $GITHUB_ENV
4747
echo "AKS_CLUSTER_NAME=${{ env.PREFIX }}-aks-001" >> $GITHUB_ENV
48-
# Show event info
49-
- name: Show triggered event data
50-
run: pwsh -command "./scripts/Get-EventData.ps1"
51-
env:
52-
GITHUB_CONTEXT: ${{ toJson(github) }}
5348
5449
# Login
5550
- name: Login to Azure
5651
run: ./scripts/azure_login.sh
5752

58-
# Deallocate
59-
- name: Deallocate AKS VMSS
60-
run: ./scripts/deallocate_aks_vmss.sh
53+
# Stop
54+
# Prereqs: https://docs.microsoft.com/en-us/azure/aks/start-stop-cluster
55+
- name: Stop AKS Cluster
56+
run: ./scripts/stop_aks_cluster.sh
6157

6258
# Notify
6359
- name: Notify slack
6460
env:
61+
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
6562
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
66-
uses: pullreminders/[email protected]
67-
with:
68-
# env var concatenation not supported atm, so hard-code messages
69-
args: '{\"channel\":\"C012ZQHT9A4\",\"text\":\"[aks-nexus-velero] Deallocate AKS VMSS complete\"}'
63+
run: ./scripts/send_slack_message.sh "[aks-nexus-velero] Stop AKS Cluster complete"

.github/workflows/test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ jobs:
8484
# Notify
8585
- name: Notify slack
8686
env:
87+
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
8788
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
88-
uses: pullreminders/[email protected]
89-
with:
90-
# env var concatenation not supported atm, so hard-code messages
91-
args: '{\"channel\":\"C012ZQHT9A4\",\"text\":\"[aks-nexus-velero] Test notification\"}'
89+
run: ./scripts/send_slack_message.sh "[aks-nexus-velero] Test notification"

.vscode/tasks.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
{
55
"type": "func",
66
"command": "host start",
7-
"problemMatcher": "$func-watch",
7+
"problemMatcher": "$func-powershell-watch",
88
"isBackground": true,
99
"options": {
1010
"cwd": "${workspaceFolder}/function_app"
11-
},
12-
"label": "func host start"
11+
}
1312
}
1413
]
1514
}

ansible/roles/helm_repo/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
when: enable_debug_output == "true"
1515

1616
- name: Add stable Helm Chart
17-
shell: "helm repo add stable https://kubernetes-charts.storage.googleapis.com/"
17+
shell: "helm repo add stable https://charts.helm.sh/stable/"
1818

1919
- name: Download Example Helm Charts from GitHub
2020
shell: "helm pull stable/{{ item.name }} --version {{ item.version }}"

ansible/roles/init/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
register: result
2929
until:
3030
- result.status == 200
31-
# 90 x 10secs = 15mins
32-
retries: 90
31+
# 30 x 10secs = 5mins
32+
retries: 30
3333
delay: 10
3434
# reset module defaults for this simple check
3535
module_defaults:

function_app/TimerTrigger1/readme.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ For a `TimerTrigger` to work, you provide a schedule in the form of a [cron expr
88

99
## Local Testing
1010

11+
Ensure you have a `local.settings.json` file with the following settings (replacing the placeholders):
12+
13+
```json
14+
{
15+
"IsEncrypted": false,
16+
"Values": {
17+
"AzureWebJobsStorage": "<STORAGE_ACCOUNT_CONNECTION_STRING>",
18+
"FUNCTIONS_WORKER_RUNTIME": "powershell",
19+
"FUNCTIONS_WORKER_RUNTIME_VERSION": "~7",
20+
"IFTTT_WEBHOOK_KEY": "<IFTTT_WEBHOOK_KEY>",
21+
"WEEKDAY_ALLOWED_TIME_RANGE": "06:30 -> 08:00"
22+
}
23+
}
24+
```
25+
1126
Full instructions here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs-code?tabs=csharp#run-functions-locally
1227

1328
Ensure the [Azure Functions Core Tools are installed](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash#install-the-azure-functions-core-tools),
@@ -22,7 +37,7 @@ then follow the steps below to run and test
2237
the code locally:
2338

2439
```powershell
25-
<# set to use PowerShell 7
40+
<# [NO LONGER REQUIRED?] set to use PowerShell 7
2641
$env:FUNCTIONS_WORKER_RUNTIME_VERSION = '~7'
2742
#>
2843
# enter function directory

function_app/host.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
// https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json
21
{
32
"version": "2.0",
3+
"logging": {
4+
"applicationInsights": {
5+
"samplingSettings": {
6+
"isEnabled": true,
7+
"excludedTypes": "Request"
8+
}
9+
}
10+
},
411
"extensionBundle": {
512
"id": "Microsoft.Azure.Functions.ExtensionBundle",
613
"version": "[1.*, 2.0.0)"

0 commit comments

Comments
 (0)