From 89a24bedac761b2f03d0cb9c4e6dab95893451bf Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Wed, 15 Dec 2021 15:03:23 -0500 Subject: [PATCH] Preserve kubectl context namespace if set for active stress cluster --- .../scripts/stress-testing/stress-test-deployment-lib.ps1 | 7 +++++++ 1 file changed, 7 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 eb62546621..5ab1597043 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -40,12 +40,19 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$pushImages $cluster = RunOrExitOnFailure az aks list -g $clusterGroup --subscription $subscription -o json $clusterName = ($cluster | ConvertFrom-Json).name + $kubeContext = (RunOrExitOnFailure kubectl config view -o json) | ConvertFrom-Json + $defaultNamespace = $kubeContext.contexts.Where({ $_.name -eq $clusterName }).context.namespace + RunOrExitOnFailure az aks get-credentials ` -n "$clusterName" ` -g "$clusterGroup" ` --subscription "$subscription" ` --overwrite-existing + if ($defaultNamespace) { + RunOrExitOnFailure kubectl config set-context $clusterName --namespace $defaultNamespace + } + if ($pushImages) { $registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json $registryName = ($registry | ConvertFrom-Json).name