@@ -739,14 +739,21 @@ try {
739739 # 6-1. Get Az Network resource Name with the public IP address
740740 Write-Host " Assign DNS Name to the public IP address" - ForegroundColor Green
741741 $publicIpName = $ (az network public- ip list -- resource- group $aksResourceGroupName -- query " [?ipAddress=='$externalIP '].name" -- output tsv)
742- # 6-2. Generate Unique backend API fqdn Name - esgdocanalysis-3 digit random number with padding 0
743- $dnsName = " kmgs$ ( $ (Get-Random - Minimum 0 - Maximum 9999 ).ToString(" D4" )) "
744-
745- # Validate if the AKS Resource Group Name, Public IP name and DNS Name are provided
742+ # 6-2. Reuse existing DNS name if already assigned, otherwise generate a new one
743+ # Validate if the AKS Resource Group Name and Public IP name are provided
746744 ValidateVariableIsNullOrEmpty - variableValue $aksResourceGroupName - variableName " AKS Resource Group name"
747745
748746 ValidateVariableIsNullOrEmpty - variableValue $publicIpName - variableName " Public IP name"
749747
748+ $existingDnsName = az network public- ip show -- resource- group $aksResourceGroupName -- name $publicIpName -- query " dnsSettings.domainNameLabel" -- output tsv 2> $null
749+ if ($existingDnsName ) {
750+ Write-Host " Reusing existing DNS name: $existingDnsName " - ForegroundColor Yellow
751+ $dnsName = $existingDnsName
752+ } else {
753+ $dnsName = " kmgs$ ( $ (Get-Random - Minimum 0 - Maximum 9999 ).ToString(" D4" )) "
754+ Write-Host " Generated new DNS name: $dnsName " - ForegroundColor Green
755+ }
756+
750757 ValidateVariableIsNullOrEmpty - variableValue $dnsName - variableName " DNS Name"
751758
752759 # 6-3. Assign DNS Name to the public IP address
@@ -1028,7 +1035,7 @@ try {
10281035 kubectl apply -f " ./kubernetes/deploy.ingress.internal.yaml.template" - n $kubenamespace
10291036
10301037 # Deploy network policies to restrict backend traffic to internal only
1031- kubectl apply -f " ./kubernetes/deploy.networkpolicy.yaml" - n $kubenamespace
1038+ kubectl apply -f " ./kubernetes/deploy.networkpolicy.yaml.template " - n $kubenamespace
10321039
10331040 Write-Host " WAF network policies and internal backend ingress applied successfully." - ForegroundColor Green
10341041 }
0 commit comments