Skip to content

Commit 6d5cfdf

Browse files
aks bastion: correctly set the contents of the kubeconfig
Signed-off-by: Steve Kuznetsov <stekuznetsov@microsoft.com>
1 parent 3785797 commit 6d5cfdf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Pending
1515
19.0.0b15
1616
+++++++
1717
* Fix `NoneType` error when performing operations on automatic clusters that have hosted system components enabled.
18-
18+
* `az aks bastion`: Correctly configure `$KUBECONFIG` values for tunneling traffic into a private AKS cluster.
1919

2020
19.0.0b14
2121
+++++++

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ 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-
for cluster in data["clusters"]:
189+
for i, cluster in enumerate(data["clusters"]):
190190
if cluster["name"] == current_context:
191191
server = cluster["cluster"]["server"]
192192
hostname = urlparse(server).hostname
193193
# update the server URL to point to the local port
194-
cluster["cluster"]["server"] = f"https://localhost:{port}/"
194+
data["clusters"][i]["cluster"]["server"] = f"https://localhost:{port}/"
195195
# set the tls-server-name to the hostname
196-
cluster["cluster"]["tls-server-name"] = hostname
196+
data["clusters"][i]["cluster"]["tls-server-name"] = hostname
197197
break
198198
with open(kubeconfig_path, "w") as f:
199199
yaml.dump(data, f)

0 commit comments

Comments
 (0)