diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index f05f7388f788..c3468a111b5d 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -213,9 +213,17 @@ function DeployStressPackage( $imageTagBase += "/$($pkg.Namespace)/$($pkg.ReleaseName)" if (!$Template) { - Write-Host "Creating namespace $($pkg.Namespace) if it does not exist..." - kubectl create namespace $pkg.Namespace --dry-run=client -o yaml | kubectl apply -f - - if ($LASTEXITCODE) {exit $LASTEXITCODE} + Write-Host "Checking for namespace $($pkg.Namespace)" + kubectl get namespace $pkg.Namespace + if ($LASTEXITCODE) { + Write-Host "Creating namespace $($pkg.Namespace) ..." + kubectl create namespace $pkg.Namespace --dry-run=client -o yaml | kubectl apply -f - + if ($LASTEXITCODE) {exit $LASTEXITCODE} + # Give a few seconds for stress watcher to initialize the federated identity credential + # and create the service account before we reference it + Write-Host "Waiting 15 seconds for namespace federated credentials to be created and synced" + Start-Sleep 15 + } Write-Host "Adding default resource requests to namespace/$($pkg.Namespace)" $limitRangeSpec | kubectl apply -n $pkg.Namespace -f - if ($LASTEXITCODE) {exit $LASTEXITCODE}