Skip to content

Commit 1ae78b4

Browse files
aks bastion: correctly set the contents of the kubeconfig (#9415)
Signed-off-by: Steve Kuznetsov <[email protected]> Co-authored-by: FumingZhang <[email protected]>
1 parent 59814d0 commit 1ae78b4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
* `az aks bastion`: Correctly configure `$KUBECONFIG` values for tunneling traffic into a private AKS cluster.
1415

1516
19.0.0b16
1617
+++++++

src/aks-preview/azext_aks_preview/bastion/bastion.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,13 @@ def aks_bastion_set_kubeconfig(kubeconfig_path, port):
186186
with open(kubeconfig_path, "r") as f:
187187
data = yaml.load(f, Loader=yaml.SafeLoader)
188188
current_context = data["current-context"]
189+
current_cluster = ""
190+
for context in data["contexts"]:
191+
if context["name"] == current_context:
192+
current_cluster = context["context"]["cluster"]
193+
189194
for cluster in data["clusters"]:
190-
if cluster["name"] == current_context:
195+
if cluster["name"] == current_cluster:
191196
server = cluster["cluster"]["server"]
192197
hostname = urlparse(server).hostname
193198
# update the server URL to point to the local port

0 commit comments

Comments
 (0)