Skip to content

Commit 23a2edd

Browse files
feat: Added WAF aligned params for AKS
1 parent 5414d29 commit 23a2edd

5 files changed

Lines changed: 193 additions & 278 deletions

File tree

Deployment/resourcedeployment.ps1

Lines changed: 39 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -129,37 +129,23 @@ function LoginAzure([string]$tenantId, [string]$subscriptionID) {
129129
}
130130

131131
function DisplayResult([DeploymentResult]$displayResult) {
132-
$resourcegroupName = $displayResult.ResourceGroupName
133-
# $solutionPrefix = $displayResult.S
134-
135-
$storageAccountName = $displayResult.StorageAccountName
136-
$azsearchServiceName = $displayResult.AzSearchServiceName
137-
$aksName = $displayResult.AksName
138-
139-
$containerRegistryName = $displayResult.ContainerRegistryName
140-
$azcognitiveserviceName = $displayResult.AzCognitiveServiceName
141-
$azopenaiServiceName = $displayResult.AzOpenAIServiceName
142-
$azcosmosDBName = $displayResult.AzCosmosDBName
143-
$azappConfigEndpoint = $displayResult.AzAppConfigEndpoint
144-
145-
# Display banner
146132
Write-Host "********************************************************************************" -ForegroundColor Blue
147133
Write-Host "* Deployed Azure Resources Information *" -ForegroundColor Blue
148134
Write-Host "********************************************************************************" -ForegroundColor Blue
149-
Write-Host "* Tenant Id: " -ForegroundColor Yellow -NoNewline; Write-Host "$tenantId" -ForegroundColor Green
150-
Write-Host "* Subscription Id: " -ForegroundColor Yellow -NoNewline; Write-Host "$subscriptionID" -ForegroundColor Green
151-
Write-Host "* Knowledge Mining Digital Asset resource group: " -ForegroundColor Yellow -NoNewline; Write-Host "$resourcegroupName" -ForegroundColor Green
152-
Write-Host "* Azure Kubernetes Account " -ForegroundColor Yellow -NoNewline; Write-Host "$aksName" -ForegroundColor Green
153-
Write-Host "* Azure Container Registry " -ForegroundColor Yellow -NoNewline; Write-Host "$containerRegistryName" -ForegroundColor Green
154-
Write-Host "* Azure Search Service " -ForegroundColor Yellow -NoNewline; Write-Host "$azsearchServiceName" -ForegroundColor Green
155-
Write-Host "* Azure Open AI Service " -ForegroundColor Yellow -NoNewline; Write-Host "$azopenaiServiceName" -ForegroundColor Green
156-
Write-Host "* Azure Cognitive Service " -ForegroundColor Yellow -NoNewline; Write-Host "$azcognitiveserviceName" -ForegroundColor Green
157-
Write-Host "* Azure Storage Account " -ForegroundColor Yellow -NoNewline; Write-Host "$storageAccountName" -ForegroundColor Green
158-
Write-Host "* Azure Cosmos DB " -ForegroundColor Yellow -NoNewline; Write-Host "$azcosmosDBName" -ForegroundColor Green
159-
Write-Host "* Azure App Configuration Endpoint " -ForegroundColor Yellow -NoNewline; Write-Host "$azappConfigEndpoint" -ForegroundColor Green
160-
Write-Output "rg_name=$resourcegroupName" >> $Env:GITHUB_ENV
161-
162-
Write-Output "SOLUTION_PREFIX=$solutionPrefix" >> $Env:GITHUB_ENV
135+
Write-Host "* Tenant Id: " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.TenantId)" -ForegroundColor Green
136+
Write-Host "* Subscription Id: " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.SubscriptionId)" -ForegroundColor Green
137+
Write-Host "* Knowledge Mining Digital Asset resource group: " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.ResourceGroupName)" -ForegroundColor Green
138+
Write-Host "* Azure Kubernetes Account " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AksName)" -ForegroundColor Green
139+
Write-Host "* Azure Container Registry " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AzContainerRegistryName)" -ForegroundColor Green
140+
Write-Host "* Azure Search Service " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AzSearchServiceName)" -ForegroundColor Green
141+
Write-Host "* Azure Open AI Service " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AzOpenAIServiceName)" -ForegroundColor Green
142+
Write-Host "* Azure Cognitive Service " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AzCognitiveServiceName)" -ForegroundColor Green
143+
Write-Host "* Azure Storage Account " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.StorageAccountName)" -ForegroundColor Green
144+
Write-Host "* Azure Cosmos DB " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AzCosmosDBName)" -ForegroundColor Green
145+
Write-Host "* Azure App Configuration Endpoint " -ForegroundColor Yellow -NoNewline; Write-Host "$($displayResult.AzAppConfigEndpoint)" -ForegroundColor Green
146+
Write-Output "rg_name=$($displayResult.ResourceGroupName)" >> $Env:GITHUB_ENV
147+
148+
Write-Output "SOLUTION_PREFIX=$($displayResult.SolutionPrefix)" >> $Env:GITHUB_ENV
163149
}
164150

165151
# Function to replace placeholders in a template with actual values
@@ -372,15 +358,12 @@ try {
372358
# Map the deployment result to DeploymentResult object from .env file
373359
$deploymentResult.MapResult()
374360

361+
LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId
362+
375363
# Display the deployment result
376364
DisplayResult($deploymentResult)
377365

378-
LoginAzure $deploymentResult.TenantId $deploymentResult.SubscriptionId
379-
380-
###############################################################
381-
# Step 2 : Validate deloyment result
382-
Show-Banner -Title "Step 2 : Validate deloyment result"
383-
###############################################################
366+
# Step 1.2 Validate the deployment result
384367
# Validate if the Storage Account Name is empty or null
385368
ValidateVariableIsNullOrEmpty -variableValue $deploymentResult.StorageAccountName -variableName "Storage Account Name"
386369

@@ -402,13 +385,9 @@ try {
402385
# Get MongoDB connection string
403386
$deploymentResult.AzCosmosDBConnectionString = az cosmosdb keys list --name $deploymentResult.AzCosmosDBName --resource-group $deploymentResult.ResourceGroupName --type connection-strings --query "connectionStrings[0].connectionString" -o tsv
404387

405-
Write-Host "Secrets have been retrieved successfully." -ForegroundColor Green
388+
Write-Host "Validation Completed" -ForegroundColor Green
406389

407-
######################################################################################################################
408-
# Step 3 : Update App Configuration files with Secrets and information for AI Service and Kernel Memory Service.
409-
Show-Banner -Title "Step 3 : Update App Configuration files with Secrets and information for AI Service and Kernel Memory Service."
410-
######################################################################################################################
411-
# Step 3-1 Loading aiservice's configution file template then replace the placeholder with the actual values
390+
# Step 1-3 Loading aiservice's configution file template then replace the placeholder with the actual values
412391
# Define the placeholders and their corresponding values for AI service configuration
413392

414393
$aiServicePlaceholders = @{
@@ -440,48 +419,11 @@ try {
440419
$aiServiceConfigTemplate = Get-Content -Path .\appconfig\aiservice\appconfig.jsonl -Raw
441420
$aiServiceConfigTemplate = Invoke-PlaceholdersReplacement $aiServiceConfigTemplate $aiServicePlaceholders
442421

443-
# ## Save the updated AI service configuration file
444-
# $aiServiceConfigPath = ".\appconfig\aiservice\appsettings.dev.jsonl"
445-
# $aiServiceConfigTemplate | Set-Content -Path $aiServiceConfigPath -Force
446-
# Write-Host "Knowledge Mining Solution Accelerator Service Application Configuration file has been updated successfully." -ForegroundColor Green
447-
448-
# ## Set error action preference to silently continue
449-
# $ErrorActionPreference = "SilentlyContinue"
450-
# ## Get the current script directory dynamically
451-
# $scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
452-
453-
# ## Construct the relative path to the JSON file
454-
# $filePath = Join-Path $scriptDirectory ".\appconfig\aiservice\appsettings.dev.jsonl"
455-
456-
# ## Other variables
457-
# $appConfigName = $deploymentResult.AzAppConfigName
458-
459-
# ## Output the file path for verification
460-
# #write-host "Using file path: $filePath"
461-
462-
# ## Execute the az appconfig kv import command using PowerShell
463-
# az appconfig kv import `
464-
# --name $appConfigName `
465-
# --source file `
466-
# --path $filePath `
467-
# --format json `
468-
# --separator "," `
469-
# --content-type "application/x-ndjson" `
470-
# --yes
471-
472-
# ## Check if the file exists and delete it
473-
# if (Test-Path $aiServiceConfigPath) {
474-
# Remove-Item $aiServiceConfigPath -Force
475-
# #Write-Host "File '$aiServiceConfigPath' has been deleted."
476-
# } else {
477-
# Write-Host "File '$aiServiceConfigPath' does not exist."
478-
# }
479-
# $ErrorActionPreference = "Continue"
480-
422+
Write-Host "Update Configuration files Completed." -ForegroundColor Green
481423

482424
######################################################################################################################
483-
# Step 4 : Configure Kubernetes Infrastructure
484-
Show-Banner -Title "Step 4 : Configure Kubernetes Infrastructure"
425+
# Step 2 : Configure Kubernetes Infrastructure
426+
Show-Banner -Title "Step 2 : Configure Kubernetes Infrastructure"
485427
######################################################################################################################
486428
# 0. Attach Container Registry to AKS
487429
Write-Host "Attach Container Registry to AKS" -ForegroundColor Green
@@ -535,7 +477,6 @@ try {
535477
exit 1
536478
}
537479

538-
539480
# 2.Connect to AKS cluster
540481
try {
541482
Write-Host "Connecting to AKS cluster..." -ForegroundColor Cyan
@@ -684,18 +625,18 @@ try {
684625
}
685626

686627
#########################################################################################################################################
687-
# Step 5 : Update Kubernetes configuration files with the FQDN, Container Image Path and Email address for the certificate management
688-
#Write-Host "Step 5 : Update Kubernetes yaml files with Container Image Path and Email address for the certificate management" -ForegroundColor Yellow
689-
Show-Banner -Title "Step 5 : Update Kubernetes yaml files with Container Image Path and Email address for the certificate management"
628+
# Step 3 : Update Kubernetes configuration files with the FQDN, Container Image Path and Email address for the certificate management
629+
#Write-Host "Step 3 : Update Kubernetes yaml files with Container Image Path and Email address for the certificate management" -ForegroundColor Yellow
630+
Show-Banner -Title "Step 3 : Update Kubernetes yaml files with Container Image Path and Email address for the certificate management"
690631
#########################################################################################################################################
691632

692-
# 5.1 Update deploy.certclusterissuer.yaml.template file and save as deploy.certclusterissuer.yaml
633+
# 3.1 Update deploy.certclusterissuer.yaml.template file and save as deploy.certclusterissuer.yaml
693634
$certManagerTemplate = Get-Content -Path .\kubernetes\deploy.certclusterissuer.yaml.template -Raw
694635
$certManagerTemplate = $certManagerTemplate -replace '{{ your-email }}', $email
695636
$certManagerPath = ".\kubernetes\deploy.certclusterissuer.yaml"
696637
$certManagerTemplate | Set-Content -Path $certManagerPath -Force
697638

698-
# 5.2 Update deploy.ingress.yaml.template file and save as deploy.ingress.yaml
639+
# 3.2 Update deploy.ingress.yaml.template file and save as deploy.ingress.yaml
699640
# webfront / apibackend
700641
$ingressPlaceholders = @{
701642
'{{ fqdn }}' = $fqdn
@@ -708,7 +649,7 @@ try {
708649
Write-Host "Ingress Controller configuration file have been updated successfully." -ForegroundColor Green
709650

710651

711-
# 5.3 Update deploy.deployment.yaml.template file and save as deploy.deployment.yaml
652+
# 3.3 Update deploy.deployment.yaml.template file and save as deploy.deployment.yaml
712653
# Validate AzContainerRegistryName IsNull Or Empty.
713654
ValidateVariableIsNullOrEmpty -variableValue $deploymentResult.AzContainerRegistryName -variableName "Azure Container Registry Name"
714655

@@ -737,9 +678,9 @@ try {
737678
$deployment | Set-Content -Path $deploymentPath -Force
738679

739680
########################################################################################################################################################
740-
# Step 6 : Configure AKS (deploy Cert Manager, Ingress Controller) and Deploy Images on the kubernetes cluster
741-
#Write-Host "Step 6 : Configure AKS (deploy Cert Manager) and Deploy Images on the kubernetes cluster" -ForegroundColor Yellow
742-
Show-Banner -Title "Step 6 : Configure AKS (deploy Cert Manager) and Deploy Images on the kubernetes cluster"
681+
# Step 4 : Configure AKS (deploy Cert Manager, Ingress Controller) and Deploy Images on the kubernetes cluster
682+
#Write-Host "Step 4 : Configure AKS (deploy Cert Manager) and Deploy Images on the kubernetes cluster" -ForegroundColor Yellow
683+
Show-Banner -Title "Step 4 : Configure AKS (deploy Cert Manager) and Deploy Images on the kubernetes cluster"
743684
########################################################################################################################################################
744685
function Wait-ForCertManager {
745686
Write-Host "Waiting for Cert-Manager to be ready..." -ForegroundColor Cyan
@@ -756,7 +697,7 @@ try {
756697
}
757698

758699
Write-Host "Deploying Cert Manager" -ForegroundColor Green
759-
# 6.1. Install Cert Manager and nginx ingress controller in Kubernetes for SSL/TLS certificate
700+
# 4.1. Install Cert Manager and nginx ingress controller in Kubernetes for SSL/TLS certificate
760701
# Install Cert-Manager
761702
Write-Host "Deploying...." -ForegroundColor Green
762703
helm repo add jetstack https://charts.jetstack.io --force-update
@@ -823,8 +764,8 @@ try {
823764
Copy-Item -Path $frontAppConfigPath -Destination "..\App\frontend-app\.env" -Force
824765

825766
######################################################################################################################
826-
# Step 7 : docker build and push container images to Azure Container Registry
827-
Show-Banner -Title "Step 7 : docker build and push container images to Azure Container Registry"
767+
# Step 5 : docker build and push container images to Azure Container Registry
768+
Show-Banner -Title "Step 5 : docker build and push container images to Azure Container Registry"
828769
######################################################################################################################
829770
# $acrNamespace = "kmgs"
830771
# $acrAIServiceTag = "$($deploymentResult.AzContainerRegistryName).azurecr.io/$acrNamespace/aiservice"
@@ -853,16 +794,16 @@ try {
853794

854795
#======================================================================================================================================================================
855796

856-
# 7.2. Deploy ClusterIssuer in Kubernetes for SSL/TLS certificate
797+
# 5.2. Deploy ClusterIssuer in Kubernetes for SSL/TLS certificate
857798
kubectl apply -f "./kubernetes/deploy.certclusterissuer.yaml"
858799

859-
# 7.3. Deploy Deployment in Kubernetes
800+
# 5.3. Deploy Deployment in Kubernetes
860801
kubectl apply -f "./kubernetes/deploy.deployment.yaml" -n $kubenamespace
861802

862-
# 7.4. Deploy Services in Kubernetes
803+
# 5.4. Deploy Services in Kubernetes
863804
kubectl apply -f "./kubernetes/deploy.service.yaml" -n $kubenamespace
864805

865-
# 7.5. Deploy Ingress Controller in Kubernetes for external access
806+
# 5.5. Deploy Ingress Controller in Kubernetes for external access
866807
kubectl apply -f "./kubernetes/deploy.ingress.yaml" -n $kubenamespace
867808

868809
# #####################################################################
@@ -874,7 +815,7 @@ try {
874815

875816

876817
#####################################################################
877-
# Step 8 : Display the deployment result and following instructions
818+
# Step 6 : Display the deployment result and following instructions
878819
#####################################################################
879820
#Write-Host "Deployment has been completed successfully." -ForegroundColor Green
880821
successBanner

0 commit comments

Comments
 (0)