Skip to content

Commit 90807d1

Browse files
azure-sdkbenbp
andauthored
Preserve kubectl context namespace if set for active stress cluster (Azure#19383)
Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent f331d51 commit 90807d1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$pushImages
4040
$cluster = RunOrExitOnFailure az aks list -g $clusterGroup --subscription $subscription -o json
4141
$clusterName = ($cluster | ConvertFrom-Json).name
4242

43+
$kubeContext = (RunOrExitOnFailure kubectl config view -o json) | ConvertFrom-Json
44+
$defaultNamespace = $kubeContext.contexts.Where({ $_.name -eq $clusterName }).context.namespace
45+
4346
RunOrExitOnFailure az aks get-credentials `
4447
-n "$clusterName" `
4548
-g "$clusterGroup" `
4649
--subscription "$subscription" `
4750
--overwrite-existing
4851

52+
if ($defaultNamespace) {
53+
RunOrExitOnFailure kubectl config set-context $clusterName --namespace $defaultNamespace
54+
}
55+
4956
if ($pushImages) {
5057
$registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json
5158
$registryName = ($registry | ConvertFrom-Json).name

0 commit comments

Comments
 (0)