From f937eae89cc9a416d9aca6e7e880ab91d772e0ab Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 17 Dec 2021 11:41:13 -0800 Subject: [PATCH] Preserve kubectl context namespace if set for active stress cluster (#3187) Co-authored-by: Ben Broderick Phillips --- .../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 eb6254662..5ab159704 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