diff --git a/.gitattributes b/.gitattributes index 0f04fc1b..ccf37d76 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ * text=auto eol=lf *.html linguist-detectable=false *.cshtml linguist-detectable=false -*.htm linguist-detectable=false \ No newline at end of file +*.htm linguist-detectable=false +*.razor linguist-detectable=false diff --git a/CHANGELOG.md b/CHANGELOG.md index 41355724..bd30129b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,3 +26,7 @@ and this project adheres to [Semantic Versioning v2.0.0](https://semver.org/spec - Configure CD with AKS and HELM - Helm deploy powershell script - Move ingress and certificates to HELM chart +- Install Prometheus Grafana Alert manager using HELM +- Configure ingress for Prometheus Grafana Alert manager +- Fix encoding +- Merge plan and plan-destroy terraform pipelines diff --git a/EventTriangleAPI.sln b/EventTriangleAPI.sln index bc66fe50..a61d51e2 100644 --- a/EventTriangleAPI.sln +++ b/EventTriangleAPI.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 diff --git a/build/templates/helm-deploy-jobs.yml b/build/templates/helm-deploy-jobs.yml index ff978f95..7da3c2eb 100644 --- a/build/templates/helm-deploy-jobs.yml +++ b/build/templates/helm-deploy-jobs.yml @@ -1,4 +1,4 @@ -parameters: +parameters: - name: chartName type: string diff --git a/build/templates/terraform-apply-stages.yml b/build/templates/terraform-apply-stages.yml index 5f20ead5..91330f16 100644 --- a/build/templates/terraform-apply-stages.yml +++ b/build/templates/terraform-apply-stages.yml @@ -102,7 +102,7 @@ stages: -backend-config="storage_account_name=$env:TF_STATE_BLOB_ACCOUNT_NAME" ` -backend-config="container_name=$env:TF_STATE_BLOB_CONTAINER_NAME" ` -backend-config="key=$env:TF_STATE_BLOB_FILE" ` - -backend-config="sas_token=$env:TF_STATE_BLOB_SAS_TOKEN" + -backend-config="sas_token=$env:TF_STATE_BLOB_SAS_TOKEN" -reconfigure -upgrade displayName: 'Terraform Init' workingDirectory: ${{ parameters.workingDirectory }} env: diff --git a/build/templates/terraform-plan-destroy-stages.yml b/build/templates/terraform-plan-destroy-stages.yml deleted file mode 100644 index 9b12abe6..00000000 --- a/build/templates/terraform-plan-destroy-stages.yml +++ /dev/null @@ -1,125 +0,0 @@ -parameters: - - name: stageName - displayName: 'Stage name display name' - type: string - - - name: vmImage - displayName: 'Vm Image' - default: 'windows-latest' - type: string - - - name: terraformVersion - displayName: 'Terraform Version' - type: string - default: 'latest' - - - name: workingDirectory - displayName: 'Working Directory for Terraform' - type: string - - - name: storageAccount - displayName: 'Storage Account' - type: string - - - name: storageContainer - displayName: 'Storage Container' - type: string - - - name: stateFile - displayName: 'State File' - type: string - - - name: sasToken - displayName: 'Sas Token' - type: string - - - name: prefix - displayName: 'Prefix' - default: 'd01' - type: string - - - name: subscriptionId - displayName: 'Azure Subscription Id' - type: string - - - name: clientId - displayName: 'Azure Client Id' - type: string - - - name: clientSecret - displayName: 'Azure Client Secret' - type: string - - - name: tenantId - displayName: 'Azure Tenant Id' - type: string - -stages: - - stage: ${{ parameters.stageName }} - displayName: ${{ parameters.stageName }} - jobs: - - job: ${{ parameters.stageName }} - displayName: ${{ parameters.stageName }} - pool: - vmImage: ${{ parameters.VmImage }} - variables: - - name: 'TF_LOG' - value: 'INFO' - steps: - - checkout: self - fetchDepth: 0 - - - task: TerraformInstaller@1 - displayName: 'Install Terraform ${{ parameters.terraformVersion }}' - inputs: - terraformVersion: '${{ parameters.terraformVersion }}' - - - task: FileTransform@2 - displayName: 'Transform terraform.auto.tfvars.json' - inputs: - folderPath: '$(System.DefaultWorkingDirectory)' - xmlTransformationRules: '' - jsonTargetFiles: 'terraform/terraform.auto.tfvars.json' - - - powershell: | - terraform init -backend=false - terraform validate - terraform fmt -check - displayName: "Run tf validate" - workingDirectory: '${{ parameters.workingDirectory }}' - - - powershell: | - terraform init ` - -backend-config="storage_account_name=$env:TF_STATE_BLOB_ACCOUNT_NAME" ` - -backend-config="container_name=$env:TF_STATE_BLOB_CONTAINER_NAME" ` - -backend-config="key=$env:TF_STATE_BLOB_FILE" ` - -backend-config="sas_token=$env:TF_STATE_BLOB_SAS_TOKEN" - displayName: 'Terraform Init' - workingDirectory: ${{ parameters.workingDirectory }} - env: - TF_STATE_BLOB_ACCOUNT_NAME: ${{ parameters.storageAccount }} - TF_STATE_BLOB_CONTAINER_NAME: ${{ parameters.storageContainer }} - TF_STATE_BLOB_FILE: ${{ parameters.stateFile }} - TF_STATE_BLOB_SAS_TOKEN: ${{ parameters.sasToken }} - - - powershell: | - terraform plan -destroy -var "prefix=${{ parameters.prefix }}" -out main.tfplan - displayName: 'Terraform Plan' - workingDirectory: ${{ parameters.workingDirectory }} - env: - ARM_SUBSCRIPTION_ID: ${{ parameters.subscriptionId }} - ARM_CLIENT_ID: ${{ parameters.clientId }} - ARM_CLIENT_SECRET: ${{ parameters.clientSecret }} - ARM_TENANT_ID: ${{ parameters.tenantId }} - - - powershell: | - cp main.tfplan $(Build.ArtifactStagingDirectory) - displayName: 'Copy Plan' - workingDirectory: ${{ parameters.workingDirectory }} - - - task: PublishBuildArtifacts@1 - displayName: 'Publish Artifacts' - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)' - ArtifactName: 'drop' - publishLocation: 'Container' diff --git a/build/templates/terraform-plan-stages.yml b/build/templates/terraform-plan-stages.yml index c4c55e6f..d7e9ad4f 100644 --- a/build/templates/terraform-plan-stages.yml +++ b/build/templates/terraform-plan-stages.yml @@ -54,6 +54,10 @@ parameters: displayName: 'Azure Tenant Id' type: string + - name: destroy + displayName: 'Should destroy infrastructure' + type: boolean + stages: - stage: ${{ parameters.stageName }} displayName: ${{ parameters.stageName }} @@ -93,7 +97,7 @@ stages: -backend-config="storage_account_name=$env:TF_STATE_BLOB_ACCOUNT_NAME" ` -backend-config="container_name=$env:TF_STATE_BLOB_CONTAINER_NAME" ` -backend-config="key=$env:TF_STATE_BLOB_FILE" ` - -backend-config="sas_token=$env:TF_STATE_BLOB_SAS_TOKEN" + -backend-config="sas_token=$env:TF_STATE_BLOB_SAS_TOKEN" -reconfigure -upgrade displayName: 'Terraform Init' workingDirectory: ${{ parameters.workingDirectory }} env: @@ -102,15 +106,27 @@ stages: TF_STATE_BLOB_FILE: ${{ parameters.stateFile }} TF_STATE_BLOB_SAS_TOKEN: ${{ parameters.sasToken }} - - powershell: | - terraform plan -var "prefix=${{ parameters.prefix }}" -out main.tfplan - displayName: 'Terraform Plan' - workingDirectory: ${{ parameters.workingDirectory }} - env: - ARM_SUBSCRIPTION_ID: ${{ parameters.subscriptionId }} - ARM_CLIENT_ID: ${{ parameters.clientId }} - ARM_CLIENT_SECRET: ${{ parameters.clientSecret }} - ARM_TENANT_ID: ${{ parameters.tenantId }} + - ${{ if eq(parameters.destroy, false) }}: + - powershell: | + terraform plan -var "prefix=${{ parameters.prefix }}" -out main.tfplan + displayName: 'Terraform Plan' + workingDirectory: ${{ parameters.workingDirectory }} + env: + ARM_SUBSCRIPTION_ID: ${{ parameters.subscriptionId }} + ARM_CLIENT_ID: ${{ parameters.clientId }} + ARM_CLIENT_SECRET: ${{ parameters.clientSecret }} + ARM_TENANT_ID: ${{ parameters.tenantId }} + + - ${{ if eq(parameters.destroy, true) }}: + - powershell: | + terraform plan -destroy -var "prefix=${{ parameters.prefix }}" -out main.tfplan + displayName: 'Terraform Plan' + workingDirectory: ${{ parameters.workingDirectory }} + env: + ARM_SUBSCRIPTION_ID: ${{ parameters.subscriptionId }} + ARM_CLIENT_ID: ${{ parameters.clientId }} + ARM_CLIENT_SECRET: ${{ parameters.clientSecret }} + ARM_TENANT_ID: ${{ parameters.tenantId }} - powershell: | cp main.tfplan $(Build.ArtifactStagingDirectory) diff --git a/build/terraform-create-aks-cluster.yml b/build/terraform-create-aks-cluster.yml index ebb282d2..89318b51 100644 --- a/build/terraform-create-aks-cluster.yml +++ b/build/terraform-create-aks-cluster.yml @@ -44,6 +44,7 @@ stages: clientId: $(library-client-id) clientSecret: $(library-client-secret) tenantId: $(library-tenant-id) + destroy: false - template: templates/terraform-apply-stages.yml parameters: diff --git a/build/terraform-destroy-aks-cluster.yml b/build/terraform-destroy-aks-cluster.yml index bd8b09d5..5df94bfa 100644 --- a/build/terraform-destroy-aks-cluster.yml +++ b/build/terraform-destroy-aks-cluster.yml @@ -24,7 +24,7 @@ variables: value: "Terraform_Apply_Destroy_AKS_Cluster" stages: - - template: templates/terraform-plan-destroy-stages.yml + - template: templates/terraform-plan-stages.yml parameters: stageName: ${{ variables.planStageName }} VmImage: windows-latest @@ -39,6 +39,7 @@ stages: clientId: $(library-client-id) clientSecret: $(library-client-secret) tenantId: $(library-tenant-id) + destroy: true - template: templates/terraform-apply-stages.yml parameters: diff --git a/cloudflare/Get-CloudflareDnsRecords.ps1 b/cloudflare/Get-CloudflareDnsRecords.ps1 index 041efedc..060db7eb 100644 --- a/cloudflare/Get-CloudflareDnsRecords.ps1 +++ b/cloudflare/Get-CloudflareDnsRecords.ps1 @@ -1,4 +1,4 @@ -param ( +param ( [Parameter(Mandatory = $true)] [string]$ApiToken, diff --git a/cloudflare/Get-CloudflareZoneId.ps1 b/cloudflare/Get-CloudflareZoneId.ps1 index 4f560265..e1042ebf 100644 --- a/cloudflare/Get-CloudflareZoneId.ps1 +++ b/cloudflare/Get-CloudflareZoneId.ps1 @@ -1,4 +1,4 @@ -param ( +param ( [Parameter(Mandatory = $true)] [string]$ApiToken, diff --git a/cloudflare/Get-NewDnsEntries.ps1 b/cloudflare/Get-NewDnsEntries.ps1 index 9fb805ef..c2431cfd 100644 --- a/cloudflare/Get-NewDnsEntries.ps1 +++ b/cloudflare/Get-NewDnsEntries.ps1 @@ -1,4 +1,4 @@ -$postgresService = $( kubectl get service "postgres-service" -n "event-triangle" -o json ) | ConvertFrom-Json +$postgresService = $( kubectl get service "postgres-service" -n "event-triangle" -o json ) | ConvertFrom-Json $postgresPublicIp = $postgresService.status.loadBalancer.ingress[0].ip $rabbitService = $( kubectl get service "event-rabbitmq" -n "event-triangle" -o json ) | ConvertFrom-Json diff --git a/cloudflare/Main.ps1 b/cloudflare/Main.ps1 index bb63b715..38f9f70b 100644 --- a/cloudflare/Main.ps1 +++ b/cloudflare/Main.ps1 @@ -1,4 +1,4 @@ -param ( +param ( [Parameter(Mandatory = $true)] [string]$ApiToken, diff --git a/cloudflare/Update-CloudflareDnsRecord.ps1 b/cloudflare/Update-CloudflareDnsRecord.ps1 index 14a2c059..64755543 100644 --- a/cloudflare/Update-CloudflareDnsRecord.ps1 +++ b/cloudflare/Update-CloudflareDnsRecord.ps1 @@ -1,4 +1,4 @@ -param ( +param ( [Parameter(Mandatory = $true)] [string]$ApiToken, diff --git a/docs/AcrConnectionSetting.md b/docs/AcrConnectionSetting.md index 945e979d..56833163 100644 --- a/docs/AcrConnectionSetting.md +++ b/docs/AcrConnectionSetting.md @@ -1,4 +1,4 @@ -# Setup ACR to push images from Pipelines +# Setup ACR to push images from Pipelines - Enable admin for ACR in Azure Portal - Update Service connection with admin username and password diff --git a/docs/AksResourceDeployment.md b/docs/AksResourceDeployment.md index 18089389..66a07cd8 100644 --- a/docs/AksResourceDeployment.md +++ b/docs/AksResourceDeployment.md @@ -1,4 +1,4 @@ -# K8s Deployment notes +# K8s Deployment notes ## Deployment order diff --git a/helm/README.md b/helm/README.md index 8d660baf..43007d21 100644 --- a/helm/README.md +++ b/helm/README.md @@ -1,4 +1,4 @@ -# Commands +# Commands ## HELM Create diff --git a/kubernetes/certificate-issuer-letsencrypt/certificate-issuer-letsencrypt.yaml b/kubernetes/certificate-issuer-letsencrypt/certificate-issuer-letsencrypt.yaml index 0f30861a..ba0b7769 100644 --- a/kubernetes/certificate-issuer-letsencrypt/certificate-issuer-letsencrypt.yaml +++ b/kubernetes/certificate-issuer-letsencrypt/certificate-issuer-letsencrypt.yaml @@ -1,4 +1,4 @@ -apiVersion: cert-manager.io/v1 +apiVersion: cert-manager.io/v1 kind: ClusterIssuer metadata: name: letsencrypt-prod diff --git a/kubernetes/certificate/certificate.yaml b/kubernetes/certificate/certificate.yaml index 1f9daffc..c7aaedb6 100644 --- a/kubernetes/certificate/certificate.yaml +++ b/kubernetes/certificate/certificate.yaml @@ -1,4 +1,4 @@ -apiVersion: cert-manager.io/v1 +apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: razumovsky-me-tls diff --git a/kubernetes/helm-install-cert-manager/deploy-cert-manager-helm.ps1 b/kubernetes/helm-install-cert-manager/deploy-cert-manager-helm.ps1 index fc8a6ce1..3b9fc4b2 100644 --- a/kubernetes/helm-install-cert-manager/deploy-cert-manager-helm.ps1 +++ b/kubernetes/helm-install-cert-manager/deploy-cert-manager-helm.ps1 @@ -1,4 +1,4 @@ -param( +param( [Parameter(Position = 0, Mandatory = $true)] [string] $HelmReleaseName, [Parameter(Position = 1, Mandatory = $true)] diff --git a/kubernetes/helm-install-grafana-prometheus/Example.ps1 b/kubernetes/helm-install-grafana-prometheus/Example.ps1 new file mode 100644 index 00000000..64696310 --- /dev/null +++ b/kubernetes/helm-install-grafana-prometheus/Example.ps1 @@ -0,0 +1,16 @@ +helm repo add prometheus-community https://prometheus-community.github.io/helm-charts +helm repo update +kubectl create namespace monitoring +helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring --set grafana.service.type=ClusterIP --set prometheus.service.type=ClusterIP +kubectl get svc -n monitoring +kubectl --namespace monitoring get secret prometheus-grafana -o jsonpath="{.data.admin-password}" | ForEach-Object { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) } + +# Port mapping for grafana +kubectl --namespace monitoring port-forward svc/prometheus-grafana 3000:80 + +# Port mapping for prometheus master +kubectl --namespace monitoring port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 + +# Port mapping for k8s metrics endpoint +kubectl --namespace monitoring port-forward svc/prometheus-kube-state-metrics 8080:8080 + diff --git a/kubernetes/helm-install-grafana-prometheus/monitoring-http-nginx-ingress.yaml b/kubernetes/helm-install-grafana-prometheus/monitoring-http-nginx-ingress.yaml new file mode 100644 index 00000000..2441508e --- /dev/null +++ b/kubernetes/helm-install-grafana-prometheus/monitoring-http-nginx-ingress.yaml @@ -0,0 +1,47 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ing-monitoring + namespace: monitoring + annotations: + nginx.ingress.kubernetes.io/enable-cors: 'true' + nginx.ingress.kubernetes.io/cors-allow-headers: 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Accept-Language' + nginx.ingress.kubernetes.io/cors-max-age: '600' + nginx.ingress.kubernetes.io/proxy-body-size: '12m' + nginx.ingress.kubernetes.io/rewrite-target: '/' + nginx.ingress.kubernetes.io/use-regex: 'true' +spec: + ingressClassName: nginx + rules: + - host: prometheus-et.razumovsky.me + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: prometheus-kube-prometheus-prometheus + port: + number: 9090 + + - host: grafana-et.razumovsky.me + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: prometheus-grafana + port: + number: 80 + + - host: metrics-et.razumovsky.me + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: prometheus-kube-state-metrics + port: + number: 8080 diff --git a/kubernetes/namespace/namespace.yaml b/kubernetes/namespace/namespace.yaml index 253e2a1b..60a94e6a 100644 --- a/kubernetes/namespace/namespace.yaml +++ b/kubernetes/namespace/namespace.yaml @@ -1,4 +1,4 @@ -apiVersion: v1 +apiVersion: v1 kind: Namespace metadata: name: event-triangle \ No newline at end of file diff --git a/scripts/Build-Docker.ps1 b/scripts/Build-Docker.ps1 index d1311540..b68baad8 100644 --- a/scripts/Build-Docker.ps1 +++ b/scripts/Build-Docker.ps1 @@ -1,4 +1,4 @@ -param ( +param ( [Parameter(Mandatory = $true)] [string]$DockerRegistryUrl, diff --git a/scripts/Build-Docker.sh b/scripts/Build-Docker.sh index 0f723a5d..005a555c 100644 --- a/scripts/Build-Docker.sh +++ b/scripts/Build-Docker.sh @@ -1,4 +1,4 @@ -GIT_VERSION_IMAGE="${{ parameters.dockerRegistryUrl }}/${{ parameters.imageRepository }}:$(GitVersion.SemVer)" +GIT_VERSION_IMAGE="${{ parameters.dockerRegistryUrl }}/${{ parameters.imageRepository }}:$(GitVersion.SemVer)" LATEST_VERSION_IMAGE="${{ parameters.dockerRegistryUrl }}/${{ parameters.imageRepository }}:latest" echo "GIT_VERSION_IMAGE: $GIT_VERSION_IMAGE" echo "LATEST_VERSION_IMAGE: $LATEST_VERSION_IMAGE" diff --git a/scripts/Deploy-Helm-Chart.ps1 b/scripts/Deploy-Helm-Chart.ps1 index 68ba8f2e..b35d9ff8 100644 --- a/scripts/Deploy-Helm-Chart.ps1 +++ b/scripts/Deploy-Helm-Chart.ps1 @@ -1,4 +1,4 @@ -param ( +param ( [string]$HelmChartsFolder = "E:\RiderProjects\02_DOTNET_PROJECTS\EventTriangleAPI\helm", [string]$ChartName = "auth-service-chart", [string]$Version, diff --git a/scripts/verify-encoding.ps1 b/scripts/verify-encoding.ps1 new file mode 100644 index 00000000..41691507 --- /dev/null +++ b/scripts/verify-encoding.ps1 @@ -0,0 +1,111 @@ +# SPDX-FileCopyrightText: 2020-2025 Friedrich von Never +# +# SPDX-License-Identifier: MIT + +<# +.SYNOPSIS + encoding-verifier v2.0.1. + + This script will verify that there's no UTF-8 BOM or CRLF line endings in the files inside of the project. + + https://github.com/ForNeVeR/encoding-verifier +#> +param ( +# Path to the repository root. All text files under the root will be checked for UTF-8 BOM and CRLF. +# +# By default (if nothing's passed), the script will try auto-detecting the nearest Git root. + [string] $SourceRoot, + +# Makes the script to perform file modifications to bring them to the standard. + [switch] $Autofix, + +# List of file extensions (with leading dots) to ignore. Case-insensitive. + [string[]] $ExcludeExtensions = @( + '.dotsettings' +) +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +if (!$SourceRoot) { + $SourceRoot = git rev-parse --show-toplevel + if (!$?) { + throw "Cannot call `"git rev-parse`": exit code $LASTEXITCODE." + } +} + +# For PowerShell to properly process the UTF-8 output from git ls-tree we need to set up the output encoding: +[Console]::OutputEncoding = [Text.Encoding]::UTF8 + +try { + Push-Location $SourceRoot + [array] $allFiles = git -c core.quotepath=off ls-tree -r HEAD --name-only + if (!$?) { + throw "Cannot call `"git ls-tree`": exit code $LASTEXITCODE." + } + Write-Output "Total files in the repository: $($allFiles.Length)" + + $counter = [pscustomobject] @{ Value = 0 } + $groupSize = 50 + [array] $chunks = $allFiles | Group-Object -Property { [math]::Floor($counter.Value++ / $groupSize) } + Write-Output "Split into $($chunks.Count) chunks." + + # https://stackoverflow.com/questions/6119956/how-to-determine-if-git-handles-a-file-as-binary-or-as-text#comment15281840_6134127 + $nullHash = '4b825dc642cb6eb9a060e54bf8d69288fbee4904' + $textFiles = $chunks | ForEach-Object { + $chunk = $_.Group + $filePaths = git -c core.quotepath=off diff --numstat $nullHash HEAD -- @chunk + if (!$?) { + throw "Cannot call `"git diff`": exit code $LASTEXITCODE." + } + $filePaths | + Where-Object { -not $_.StartsWith('-') } | + ForEach-Object { [Regex]::Unescape($_.Split("`t", 3)[2]) } + } + + Write-Output "Text files in the repository: $($textFiles.Length)" + + $bom = @(0xEF, 0xBB, 0xBF) + $bomErrors = @() + $lineEndingErrors = @() + + foreach ($file in $textFiles) { + if ($ExcludeExtensions -contains [IO.Path]::GetExtension($file).ToLowerInvariant()) { + continue + } + + $fullPath = Resolve-Path -LiteralPath $file + $bytes = [IO.File]::ReadAllBytes($fullPath) | Select-Object -First $bom.Length + if (!$bytes) { continue } # filter empty files + + $bytesEqualsBom = @(Compare-Object $bytes $bom -SyncWindow 0).Length -eq 0 + if ($bytesEqualsBom -and $Autofix) { + $fullContent = [IO.File]::ReadAllBytes($fullPath) + $newContent = $fullContent | Select-Object -Skip $bom.Length + [IO.File]::WriteAllBytes($fullPath, $newContent) + Write-Output "Removed UTF-8 BOM from file $file" + } elseif ($bytesEqualsBom) { + $bomErrors += @($file) + } + + $text = [IO.File]::ReadAllText($fullPath) + $hasWrongLineEndings = $text.Contains("`r`n") + if ($hasWrongLineEndings -and $Autofix) { + $newText = $text -replace "`r`n", "`n" + [IO.File]::WriteAllText($fullPath, $newText) + Write-Output "Fixed the line endings for file $file" + } elseif ($hasWrongLineEndings) { + $lineEndingErrors += @($file) + } + } + + if ($bomErrors.Length) { + throw "The following $($bomErrors.Length) files have UTF-8 BOM:`n" + ($bomErrors -join "`n") + } + if ($lineEndingErrors.Length) { + throw "The following $($lineEndingErrors.Length) files have CRLF instead of LF:`n" + ($lineEndingErrors -join "`n") + } +} finally { + Pop-Location +} diff --git a/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.Designer.cs b/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.Designer.cs index 129bd742..a5b3ec48 100644 --- a/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.Designer.cs +++ b/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using EventTriangleAPI.Authorization.Persistence; using Microsoft.EntityFrameworkCore; diff --git a/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.cs b/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.cs index 124dc06d..af23d29e 100644 --- a/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.cs +++ b/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/20230804064756_Initialize.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/DatabaseContextModelSnapshot.cs b/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/DatabaseContextModelSnapshot.cs index 2a7a2c6d..426132bf 100644 --- a/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/authorization/EventTriangleAPI.Authorization.Persistence/Migrations/DatabaseContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using EventTriangleAPI.Authorization.Persistence; using Microsoft.EntityFrameworkCore; diff --git a/src/authorization/EventTriangleAPI.Authorization.Presentation/Properties/launchSettings.json b/src/authorization/EventTriangleAPI.Authorization.Presentation/Properties/launchSettings.json index 8ad1b52c..e13e1ec1 100644 --- a/src/authorization/EventTriangleAPI.Authorization.Presentation/Properties/launchSettings.json +++ b/src/authorization/EventTriangleAPI.Authorization.Presentation/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, diff --git a/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.Designer.cs b/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.Designer.cs index 0a065f55..4eb5448c 100644 --- a/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.Designer.cs +++ b/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using EventTriangleAPI.Consumer.Persistence; using Microsoft.EntityFrameworkCore; diff --git a/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.cs b/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.cs index 6ae7b3ca..588c0a0e 100644 --- a/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.cs +++ b/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/20230823153056_Initialize.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/DatabaseContextModelSnapshot.cs b/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/DatabaseContextModelSnapshot.cs index c1cd6ede..f4707f47 100644 --- a/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/consumer/EventTriangleAPI.Consumer.Persistence/Migrations/DatabaseContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using EventTriangleAPI.Consumer.Persistence; using Microsoft.EntityFrameworkCore; diff --git a/src/consumer/EventTriangleAPI.Consumer.Presentation/Properties/launchSettings.json b/src/consumer/EventTriangleAPI.Consumer.Presentation/Properties/launchSettings.json index d368c95d..76e264cf 100644 --- a/src/consumer/EventTriangleAPI.Consumer.Presentation/Properties/launchSettings.json +++ b/src/consumer/EventTriangleAPI.Consumer.Presentation/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, diff --git a/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.Designer.cs b/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.Designer.cs index 739555df..4fd70fbc 100644 --- a/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.Designer.cs +++ b/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using EventTriangleAPI.Sender.Persistence; using Microsoft.EntityFrameworkCore; diff --git a/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.cs b/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.cs index 072b1338..ced410f6 100644 --- a/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.cs +++ b/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/20230823153137_Initialize.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/DatabaseContextModelSnapshot.cs b/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/DatabaseContextModelSnapshot.cs index 7e812071..311d2a6a 100644 --- a/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/sender/EventTriangleAPI.Sender.Persistence/Migrations/DatabaseContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using EventTriangleAPI.Sender.Persistence; using Microsoft.EntityFrameworkCore; diff --git a/src/sender/EventTriangleAPI.Sender.Presentation/Properties/launchSettings.json b/src/sender/EventTriangleAPI.Sender.Presentation/Properties/launchSettings.json index bba18975..bf53da65 100644 --- a/src/sender/EventTriangleAPI.Sender.Presentation/Properties/launchSettings.json +++ b/src/sender/EventTriangleAPI.Sender.Presentation/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, diff --git a/terraform/.gitattributes b/terraform/.gitattributes deleted file mode 100644 index ccf37d76..00000000 --- a/terraform/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -* text=auto eol=lf -*.html linguist-detectable=false -*.cshtml linguist-detectable=false -*.htm linguist-detectable=false -*.razor linguist-detectable=false diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index 3c99d546..03ed0f10 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -42,22 +42,22 @@ provider "registry.terraform.io/hashicorp/azuread" { } provider "registry.terraform.io/hashicorp/azurerm" { - version = "4.16.0" + version = "4.21.1" constraints = ">= 3.71.0" hashes = [ - "h1:HZdmFPnC/+x6si15pq4rGYv/1TrCcyQXLnDMqq1SONw=", - "zh:2035e461a94bd4180557a06f8e56f228a8a035608d0dac4d08e5870cf9265276", - "zh:3f15778a22ef1b9d0fa28670e5ea6ef1094b0be2533f43f350a2ef15d471b353", - "zh:4f1a4d03b008dd958bcd6bf82cf088fbaa9c121be2fd35e10e6b06c6e8f6aaa1", - "zh:5859f31c342364e849b4f8c437a46f33e927fa820244d0732b8d2ec74a95712d", - "zh:693d0f15512ca8c6b5e999b3a7551503feb06b408b3836bc6a6403e518b9ddab", - "zh:7f4912bec5b04f5156935292377c12484c13582151eb3c2555df409a7e5fb6e0", - "zh:bb9a509497f3a131c52fac32348919bf1b9e06c69a65f24607b03f7b56fb47b6", - "zh:c1b0c64e49ac591fd038ad71e71403ff71c07476e27e8da718c29f0028ea6d0d", - "zh:dd4ca432ee14eb0bb0cdc0bb463c8675b8ef02497be870a20d8dfee3e7fe52b3", - "zh:df58bb7fea984d2b11709567842ca4d55b3f24e187aa6be99e3677f55cbbe7da", + "h1:K4QidQiHvsJfLhTb7gwQuvGZuGZnXSD3ccQXWIV6cvE=", + "zh:0ba8a63b1b2572a8b04c122fd76fdca9a529b4ca3364cc1c8883341300285bf8", + "zh:1ba2e24a88aa54a87bde2c0519e3bf39a245c6ec1759fd671e96342b0bedc6c7", + "zh:22664d3bcad2c9ebecfb1165b076d2733c8a369a0f6d2b7f8f8ad2ee7eb64f03", + "zh:32128a565a615386e9020694d8ae9741ae6159ae46eaf0bfbd91b4fa45791af0", + "zh:33e7afa34ff2b0936abcad831e0971de58f9ac0debc024033dedcd9d01b5a1db", + "zh:540b27a9860d8a027dd1bc88bbf7a7b296e9476ff9f837fc0e48ff7e8a05d110", + "zh:6f8462409ab025182844b88b0c3c3b5368e06677a7e44f4edbcc473cd3cd873e", + "zh:7ab962e4d8401f0016199e97f7ca48cb9e9ee9e74a548579175ac1e6cd5c6189", + "zh:7b8f98dc6e26c9e5395ac1246c3876c1327d8e47b9894b3c8650a0f7b67bbc06", + "zh:8c40a9ec1b1f43cd60e6758316b7d2cb08bd2fa87260a37031de1156aa9c2a83", + "zh:c4908c33c404050528e0c0bd4d0567d139ddeb0f6f37f61a3c9c8c4e1af2fe2a", "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:f7fb37704da50c096f9c7c25e8a95fe73ce1d3c5aab0d616d506f07bc5cfcdd8", ] } diff --git a/terraform/README.md b/terraform/README.md index 3d0a6b05..41b8dfd5 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -1,4 +1,4 @@ -# Commands +# Commands ## Connect to AKS diff --git a/terraform/modules/aks/main.tf b/terraform/modules/aks/main.tf index b6a67174..0548e031 100644 --- a/terraform/modules/aks/main.tf +++ b/terraform/modules/aks/main.tf @@ -24,8 +24,8 @@ resource "azurerm_kubernetes_cluster" "aks" { } network_profile { - load_balancer_sku = "standard" - network_plugin = "kubenet" # CNI + network_plugin = "azure" + network_policy = "azure" } dynamic "oms_agent" { diff --git a/terraform/output.tf b/terraform/output.tf index ad450f94..b71f337e 100644 --- a/terraform/output.tf +++ b/terraform/output.tf @@ -10,6 +10,10 @@ output "subscription" { value = data.azurerm_client_config.current.subscription_id } +output "cluster_connect_command" { + value = "az aks get-credentials --resource-group ${azurerm_resource_group.public.name} --name ${module.aks.name} --subscription ${var.subscription_id}" +} + output "grafana_endpoint" { value = length(module.grafana) > 0 ? module.grafana[0].grafana_endpoint : null } diff --git a/terraform/terraform.auto.tfvars.json b/terraform/terraform.auto.tfvars.json index 35fef168..e642697a 100644 --- a/terraform/terraform.auto.tfvars.json +++ b/terraform/terraform.auto.tfvars.json @@ -8,9 +8,9 @@ "default_node_pool_type": "VirtualMachineScaleSets", "system_node_count": 3, "log_analytics_sku": "PerGB2018", - "should_deploy_acr": true, - "should_deploy_log_analytics": true, - "should_deploy_prometheus": true, + "should_deploy_acr": false, + "should_deploy_log_analytics": false, + "should_deploy_prometheus": false, "acr_name": "azuredevopsacrd01", "subscription_id": "f32f6566-8fa0-4198-9c91-a3b8ac69e89a", "tenant_id": "b40a105f-0643-4922-8e60-10fc1abf9c4b",