Skip to content

Commit b7cc220

Browse files
authored
Merge pull request #211 from adamrushuk/develop
devops-lab-v2.0.0
2 parents b1d4916 + c409511 commit b7cc220

File tree

14 files changed

+1328
-80
lines changed

14 files changed

+1328
-80
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ env:
6161
TF_INPUT: "false"
6262
TF_PLAN: "tfplan"
6363
# https://github.com/hashicorp/terraform/releases
64-
TF_VERSION: "1.0.3"
64+
TF_VERSION: "1.0.10"
6565
TF_WORKING_DIR: ./terraform
6666
# https://github.com/terraform-linters/tflint-ruleset-azurerm/releases
67-
TFLINT_RULESET_AZURERM_VERSION: "v0.11.0"
67+
TFLINT_RULESET_AZURERM_VERSION: "v0.13.2"
6868
# https://github.com/terraform-linters/tflint/releases
69-
TFLINT_VERSION: "v0.30.0"
69+
TFLINT_VERSION: "v0.33.0"
7070

7171
# Env var concatenation is currently not supported at Workflow or Job scope. See workaround below:
7272
# https://github.community/t5/GitHub-Actions/How-can-we-concatenate-multiple-env-vars-at-workflow-and-job/td-p/48489

.github/workflows/destroy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ env:
5555
TF_LOG_PATH: terraform.log
5656
TF_LOG: TRACE
5757
# https://github.com/hashicorp/terraform/releases
58-
TF_VERSION: "1.0.3"
58+
TF_VERSION: "1.0.8"
5959
TF_WORKING_DIR: terraform
6060

6161
# Env var concatenation is currently not supported at Workflow or Job scope. See workaround below:

.github/workflows/test.yml

Lines changed: 8 additions & 7 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: Webhook
2+
name: Test-Workflow
33

44
# name of GitHub event that triggers workflow
55
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#external-events-repository_dispatch
@@ -28,8 +28,8 @@ on:
2828
env:
2929
MY_WORKFLOW_VAR: work
3030

31-
# UNSUPPORTED: Cannot concatenante at Workflow level
32-
# MY_WORKFLOW_VAR2: ${{ env.MY_WORKFLOW_VAR }}-workvalue01
31+
# TODO Currently Unsupported: Cannot concatenante at Workflow level
32+
MY_CONCATENATED_WORKFLOW_VAR: "$MY_WORKFLOW_VAR-workflowvalue02"
3333

3434
jobs:
3535
build:
@@ -41,8 +41,8 @@ jobs:
4141
env:
4242
MY_JOB_VAR: job
4343

44-
# UNSUPPORTED: Cannot concatenante at Job level
45-
# MY_WORK_JOB_VAR: ${{ env.MY_WORKFLOW_VAR }}
44+
# TODO Currently Unsupported: Cannot concatenante at Job level
45+
# MY_WORK_JOB_VAR: "${{ env.MY_WORKFLOW_VAR }}-test"
4646

4747
steps:
4848
# Checkout
@@ -58,15 +58,15 @@ jobs:
5858
# https://github.community/t5/GitHub-Actions/How-can-we-concatenate-multiple-env-vars-at-workflow-and-job/td-p/48489
5959
- name: BASH - Concatenate env vars (Workaround)
6060
run: |
61-
echo "MY_CONCATENATED_BASH_VAR=${{ env.MY_WORKFLOW_VAR }}-${{ env.MY_JOB_VAR }}-bash-stepvalue01 >> $GITHUB_ENV
61+
echo "MY_CONCATENATED_BASH_VAR=${{ env.MY_WORKFLOW_VAR }}-${{ env.MY_JOB_VAR }}-bash-stepvalue01" >> $GITHUB_ENV
6262
6363
- name: PWSH - Concatenate env vars (Workaround)
6464
# override the default bash shell, as running on ubuntu
6565
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
6666
shell: pwsh
6767
# pwsh requires double quotes when setting env vars
6868
run: |
69-
echo ""MY_CONCATENATED_PWSH_VAR=${{ env.MY_WORKFLOW_VAR }}-${{ env.MY_JOB_VAR }}-pwsh-stepvalue01" >> $GITHUB_ENV
69+
echo "MY_CONCATENATED_PWSH_VAR=${{ env.MY_WORKFLOW_VAR }}-${{ env.MY_JOB_VAR }}-pwsh-stepvalue01" | Out-File -Append -Encoding utf8 -FilePath "$env:GITHUB_ENV"
7070
7171
- name: Output event data
7272
shell: pwsh
@@ -77,6 +77,7 @@ jobs:
7777
Write-Output "MY_WORKFLOW_VAR is: [$env:MY_WORKFLOW_VAR]"
7878
Write-Output "MY_JOB_VAR is: [$env:MY_JOB_VAR]"
7979
Write-Output "MY_STEP_VAR is: [$env:MY_STEP_VAR]"
80+
Write-Output "MY_CONCATENATED_WORKFLOW_VAR is: [$env:MY_CONCATENATED_WORKFLOW_VAR]"
8081
Write-Output "MY_CONCATENATED_BASH_VAR is: [$env:MY_CONCATENATED_BASH_VAR]"
8182
Write-Output "MY_CONCATENATED_PWSH_VAR is: [$env:MY_CONCATENATED_PWSH_VAR]"
8283
Write-Output "SLACK_JSON is: [$env:SLACK_JSON]"

terraform/aks.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ resource "azurerm_log_analytics_solution" "aks" {
5454
# https://registry.terraform.io/modules/adamrushuk/aks/azurerm/latest
5555
module "aks" {
5656
source = "adamrushuk/aks/azurerm"
57-
version = "~> 0.9.0"
57+
version = "~> 0.11.0"
5858

5959
kubernetes_version = var.kubernetes_version
6060
location = azurerm_resource_group.aks.location

terraform/argocd_sso.tf

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
#
33
# https://argo-cd.readthedocs.io/en/stable/operator-manual/user-management/microsoft/#azure-ad-app-registration-auth-using-oidc
44

5-
resource "random_password" "argocd" {
6-
length = 32
7-
special = false
8-
keepers = {
9-
service_principal = azuread_application.argocd.id
10-
}
5+
# https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/application_published_app_ids
6+
data "azuread_application_published_app_ids" "well_known" {}
7+
8+
resource "azuread_service_principal" "msgraph" {
9+
application_id = data.azuread_application_published_app_ids.well_known.result.MicrosoftGraph
10+
use_existing = true
1111
}
1212

1313
# https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/application
1414
resource "azuread_application" "argocd" {
1515
display_name = var.argocd_app_reg_name
16-
identifier_uris = ["https://${var.argocd_app_reg_name}"]
16+
identifier_uris = ["https://${var.argocd_fqdn}"]
1717
sign_in_audience = "AzureADMyOrg"
18-
group_membership_claims = "All"
18+
group_membership_claims = ["All"]
1919
prevent_duplicate_names = true
20+
logo_image = filebase64("${path.module}/files/argocd-logo.png")
2021

2122
web {
2223
homepage_url = "https://${var.argocd_fqdn}"
@@ -31,13 +32,20 @@ resource "azuread_application" "argocd" {
3132
# reference: https://github.com/mjisaak/azure-active-directory/blob/master/README.md#well-known-appids
3233
required_resource_access {
3334
# Microsoft Graph
34-
resource_app_id = "00000003-0000-0000-c000-000000000000"
35+
resource_app_id = data.azuread_application_published_app_ids.well_known.result.MicrosoftGraph
3536

36-
# User.Read - e1fe6dd8-ba31-4d61-89e7-88639da4683d - Sign in and read user profile
37+
# Oauth2Permissions are delegated permissions, type=Scope
3738
resource_access {
38-
id = "e1fe6dd8-ba31-4d61-89e7-88639da4683d"
39+
id = azuread_service_principal.msgraph.oauth2_permission_scope_ids["User.Read"]
3940
type = "Scope"
4041
}
42+
43+
# ? keeping for future reference
44+
# # application permissions, type=Role
45+
# resource_access {
46+
# id = azuread_service_principal.msgraph.app_role_ids["User.Read.All"]
47+
# type = "Role"
48+
# }
4149
}
4250

4351
optional_claims {
@@ -57,24 +65,26 @@ resource "azuread_application" "argocd" {
5765
}
5866
}
5967

60-
# TODO: add "SelfServiceAppAccess" tag to enable self-service options in Enterprise App
68+
data "azuread_client_config" "current" {}
69+
6170
resource "azuread_service_principal" "argocd" {
62-
application_id = azuread_application.argocd.application_id
71+
application_id = azuread_application.argocd.application_id
72+
owners = [data.azuread_client_config.current.object_id]
73+
description = "Argo CD Service Principle"
74+
notes = "Operational notes can go here"
75+
preferred_single_sign_on_mode = "oidc"
76+
# tags = ["notApiConsumer", "webApp"]
6377
}
6478

6579
# https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/application_password
6680
resource "azuread_application_password" "argocd" {
6781
application_object_id = azuread_application.argocd.id
6882
display_name = "argocd_secret"
69-
value = random_password.argocd.result
7083
end_date = "2099-01-01T01:02:03Z"
71-
72-
depends_on = [azuread_service_principal.argocd]
7384
}
7485

7586
data "azurerm_client_config" "current" {}
7687

77-
7888
# argocd-cm patch
7989
# https://www.terraform.io/docs/provisioners/local-exec.html
8090
resource "null_resource" "argocd_cm" {
@@ -115,7 +125,7 @@ resource "null_resource" "argocd_cm" {
115125
resource "null_resource" "argocd_secret" {
116126
triggers = {
117127
yaml_contents = filemd5(var.argocd_secret_yaml_path)
118-
clientSecret = random_password.argocd.result
128+
clientSecret = azuread_application_password.argocd.value
119129
}
120130

121131
provisioner "local-exec" {
@@ -125,7 +135,7 @@ resource "null_resource" "argocd_secret" {
125135
ARGOCD_SECRET_PATCH_YAML = templatefile(
126136
var.argocd_secret_yaml_path,
127137
{
128-
"clientSecretBase64" = base64encode(random_password.argocd.result)
138+
"clientSecretBase64" = base64encode(azuread_application_password.argocd.value)
129139
}
130140
)
131141
}

terraform/files/argocd-logo.png

16 KB
Loading

terraform/files/argocd-values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
installCRDs: false
2-
31
server:
42
# this is required to disable SSL redirection, as ingress handles this
53
extraArgs:

terraform/files/scripts/argocd_config.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,30 @@
66
set -euo pipefail
77
trap "echo 'error: Script failed: see failed command above'" ERR
88

9+
# Manual Testing
10+
# ARGOCD_FQDN="argocd.thehypepipe.co.uk"
11+
# ARGOCD_PATH="argocd"
12+
# ARGOCD_ADMIN_PASSWORD="[SEE VAULT]"
13+
914
# Vars
1015
ARGOCD_PATH="./argocd"
1116
REPO_SSH_PRIVATE_KEY_PATH="./id_ed25519_argocd"
1217
export ARGOCD_OPTS="--grpc-web"
1318
ARGOCD_HEALTH_CHECK_URL="https://$ARGOCD_FQDN/healthz"
1419

1520
# Install
16-
VERSION="v2.0.5"
21+
# https://github.com/argoproj/argo-cd/releases/
22+
VERSION="v2.1.6"
1723
curl -sSL -o "$ARGOCD_PATH" "https://github.com/argoproj/argo-cd/releases/download/$VERSION/argocd-linux-amd64"
1824
chmod +x "$ARGOCD_PATH"
1925

2026
# Wait for URL to be responsive
2127
echo "Checking ArgoCD is ready on [$ARGOCD_HEALTH_CHECK_URL]..."
22-
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $ARGOCD_HEALTH_CHECK_URL)" != "200" ]]; do
28+
while [[ "$(curl --silent --output /dev/null --write-out ''%{http_code}'' --url "$ARGOCD_HEALTH_CHECK_URL")" != "200" ]]; do
2329
echo "Still waiting for ArgoCD to be ready on [$ARGOCD_HEALTH_CHECK_URL]..."
2430
sleep 10
2531
done
2632

27-
# Show version
28-
echo "Showing Argo CD version info for [$ARGOCD_FQDN]..."
29-
"$ARGOCD_PATH" version --server "$ARGOCD_FQDN"
30-
3133
# Get default admin password
3234
# Argo CD v1.9 and later: https://argoproj.github.io/argo-cd/getting_started/#4-login-using-the-cli
3335
# check secret called "argocd-initial-admin-secret"
@@ -46,6 +48,10 @@ else
4648
"$ARGOCD_PATH" login "$ARGOCD_FQDN" --username admin --password "$ARGOCD_ADMIN_PASSWORD"
4749
fi
4850

51+
# Show version
52+
echo "Showing Argo CD version info for [$ARGOCD_FQDN]..."
53+
"$ARGOCD_PATH" version "$ARGOCD_FQDN"
54+
4955
# Show info
5056
echo "Showing Argo CD cluster info..."
5157
"$ARGOCD_PATH" account list

terraform/helm/aad_pod_identity_default_values.yaml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# source: https://github.com/Azure/aad-pod-identity/blob/v1.8.0/charts/aad-pod-identity/values.yaml
1+
# source: https://github.com/Azure/aad-pod-identity/blob/v1.8.3/charts/aad-pod-identity/values.yaml
22

33
# Default values for aad-pod-identity-helm.
44
# This is a YAML-formatted file.
@@ -45,7 +45,7 @@ operationMode: "standard"
4545

4646
mic:
4747
image: mic
48-
tag: v1.8.0
48+
tag: v1.8.3
4949

5050
# ref: https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/#marking-pod-as-critical
5151
priorityClassName: ""
@@ -77,17 +77,18 @@ mic:
7777
# - key: "CriticalAddonsOnly"
7878
# operator: "Exists"
7979

80-
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity
81-
affinity: {}
82-
# nodeAffinity:
83-
# preferredDuringSchedulingIgnoredDuringExecution:
84-
# - weight 1
85-
# preference:
86-
# matchExpressions:
87-
# - key: kubernetes.azure.com/mode
88-
# operator: In
89-
# values:
90-
# - system
80+
# Affinity rules to apply to the mic deployment.
81+
# Uses an anti-affinity rule to prefer not to co-locate pods on the same node as default.
82+
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
83+
affinity:
84+
podAntiAffinity:
85+
preferredDuringSchedulingIgnoredDuringExecution:
86+
- weight: 1
87+
podAffinityTerm:
88+
topologyKey: kubernetes.io/hostname
89+
labelSelector:
90+
matchLabels:
91+
app.kubernetes.io/component: mic
9192

9293
# Topology spread constraints rely on node labels to identify the topology domain(s) that each Node is in.
9394
# ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
@@ -158,7 +159,7 @@ mic:
158159

159160
nmi:
160161
image: nmi
161-
tag: v1.8.0
162+
tag: v1.8.3
162163

163164
# ref: https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/#marking-pod-as-critical
164165
priorityClassName: ""
@@ -175,6 +176,11 @@ nmi:
175176
cpu: 100m
176177
memory: 256Mi
177178

179+
updateStrategy:
180+
type: RollingUpdate
181+
rollingUpdate:
182+
maxUnavailable: 1
183+
178184
podAnnotations: {}
179185

180186
podLabels: {}
@@ -219,8 +225,8 @@ nmi:
219225
findIdentityRetryIntervalInSeconds: ""
220226

221227
# Enable scale features - https://github.com/Azure/aad-pod-identity/blob/master/docs/readmes/README.featureflags.md#enable-scale-features-flag
222-
# Accepted values are true/false. Default is false.
223-
enableScaleFeatures: ""
228+
# Accepted values are true/false. Default is true for v1.8.1+.
229+
enableScaleFeatures: true
224230

225231
# default value is 9090
226232
# prometheus port for metrics
@@ -242,6 +248,9 @@ nmi:
242248
# default is /etc/default/kubelet
243249
kubeletConfig: "/etc/default/kubelet"
244250

251+
# Set retry-after header in the NMI responses when the identity is still being assigned.
252+
setRetryAfterHeader: false
253+
245254
rbac:
246255
enabled: true
247256
# NMI requires permissions to get secrets when service principal (type: 1) is used in AzureIdentity.

0 commit comments

Comments
 (0)