From 070162c68ccd2f93e1d8932b8e99a8c33e6ce6d9 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:46:32 -0500 Subject: [PATCH] Set default LimitRange for stress container resource requests (#2396) Co-authored-by: Ben Broderick Phillips --- .../stress-test-deployment-lib.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 e6f9ee1919..91d7734a9f 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -5,6 +5,19 @@ $FailedCommands = New-Object Collections.Generic.List[hashtable] . (Join-Path $PSScriptRoot "../Helpers" PSModule-Helpers.ps1) +$limitRangeSpec = @" +apiVersion: v1 +kind: LimitRange +metadata: + name: default-resource-request +spec: + limits: + - defaultRequest: + cpu: 100m + memory: 100Mi + type: Container +"@ + # Powershell does not (at time of writing) treat exit codes from external binaries # as cause for stopping execution, so do this via a wrapper function. # See https://github.com/PowerShell/PowerShell-RFC/pull/277 @@ -191,6 +204,9 @@ function DeployStressPackage( 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 "Adding default resource requests to namespace/$($pkg.Namespace)" + $limitRangeSpec | kubectl apply -n $pkg.Namespace -f - + if ($LASTEXITCODE) {exit $LASTEXITCODE} $dockerBuildConfigs = @()