Skip to content

Commit 7380c9a

Browse files
aks bastion: correctly set the contents of the kubeconfig
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 3785797 commit 7380c9a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ 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.0b15
1617
+++++++
17-
* Fix `NoneType` error when performing operations on automatic clusters that have hosted system components enabled.
18-
18+
* Fix `NoneType` error when performing operations on automatic clusters that have hosted system components enabled
1919

2020
19.0.0b14
2121
+++++++

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)