You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/stale.yml
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -23,19 +23,19 @@ jobs:
23
23
exempt-pr-labels: 'keep-open'
24
24
stale-pr-message: >
25
25
This pull request has been inactive for 14 days.
26
-
If you are finished with your changes, don't forget to sign off. See the [contributor guide](https://review.docs.microsoft.com/en-us/help/contribute/contribute-how-to-write-pull-request-automation) for instructions.
26
+
If you are finished with your changes, don't forget to sign off. See the [contributor guide](https://review.docs.microsoft.com/en-us/help/contribute/contribute-how-to-write-pull-request-automation?branch=main) for instructions.
27
27
If this PR is inactive for 14 more days, it will be closed automatically. Thank you!
Copy file name to clipboardExpand all lines: bridge/articles/bridge-to-kubernetes-aks.md
+53-98Lines changed: 53 additions & 98 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ manager: jmartens
6
6
ms.technology: bridge
7
7
ms.custom: "contperf-fy22q1"
8
8
title: Use Bridge to Kubernetes to run and debug locally with Kubernetes with AKS in Azure
9
-
ms.date: 08/11/2022
9
+
ms.date: 08/15/2022
10
10
description: Learn how to use Bridge to Kubernetes to connect your development computer to an AKS Kubernetes cluster
11
11
---
12
12
@@ -16,7 +16,7 @@ In this tutorial, you'll use a specific AKS sample microservices web app to lear
16
16
17
17
## Before you begin
18
18
19
-
This guide uses the [Bike Sharing sample application][bike-sharing-github] to demonstrate connecting your development computer to a Kubernetes cluster running in AKS. If you already have your own application running on a Kubernetes cluster, see [Develop with Kubernetes](bridge-to-kubernetes-vs-code.md). If you are using another cluster, such as MiniKube running locally, see [Use Bridge to Kubernetes with a sample](bridge-to-kubernetes-sample.md).
19
+
This guide uses the [Todo App sample application](https://github.com/microsoft/mindaro/tree/master/samples/todo-app) to demonstrate connecting your development computer to a Kubernetes cluster running in AKS. If you already have your own application running on a Kubernetes cluster, see [Develop with Kubernetes](bridge-to-kubernetes-vs-code.md). If you are using another cluster, such as MiniKube running locally, see [Use Bridge to Kubernetes with a sample](bridge-to-kubernetes-sample.md).
20
20
21
21
### Prerequisites
22
22
@@ -43,156 +43,111 @@ az aks create \
43
43
44
44
## Install the sample application
45
45
46
-
Install the sample application on your cluster using the provided script. You can run this script on your development computer or using the [Azure Cloud Shell][azure-cloud-shell]. Use the name of your cluster and resource group.
47
-
48
-
> [!IMPORTANT]
49
-
> You must have **Owner** or **Contributor** access to your cluster in order to run the script.
Checking directory /home/<user>/mindaro for GIT repo Microsoft/Mindaro
63
-
Setting the Kube context
64
-
...
65
-
To try out the app, open the url:
66
-
bikeapp.bikesharingweb.EXTERNAL_IP.nip.io
67
-
```
68
-
69
-
In the above sample, the public URL is `bikeapp.bikesharingweb.EXTERNAL_IP.nip.io`.
70
-
71
-
## Connect to your cluster and debug a service
54
+
## Connect to your cluster and deploy the app
72
55
73
56
On your development computer, download and configure the Kubernetes CLI to connect to your Kubernetes cluster using [az aks get-credentials][az-aks-get-credentials].
74
57
75
58
```azurecli
76
59
az aks get-credentials --resource-group MyResourceGroup --name MyAKS
Open `mindaro/samples/BikeSharingApp/Bikes` from the [Bike Sharing sample application][bike-sharing-github] in Visual Studio Code. Open the Azure Kubernetes Service extension and select the **bikeapp** namespace in the **MyAKS** cluster. Right-click the **bikeapp** node, and choose **Use Namespace**.
On the same terminal you were using earlier run below command and copy the IP for front end service under the External IP columnd.
82
68
83
-
Open a terminal window (**Terminal > New Terminal**), and in the terminal window in the **Bikes** folder, use the `npm install` command to install the dependencies for the application.
84
-
85
-
```console
86
-
npm install
69
+
```azurecli
70
+
kubectl get services
87
71
```
88
72
89
-
Open the Command Palette (**CTRL**+**SHIFT**+**P** or **Cmd**+**Shift**+**P** on a Mac), and run the command **Bridge to Kubernetes: Configure** to start the configuration process.
All traffic in the Kubernetes cluster is redirected for the bikes service to the version of your application running in your development computer. Bridge to Kubernetes also routes all outbound traffic from the application back to your Kubernetes cluster.
96
-
97
-
> [!IMPORTANT]
98
-
> You can only redirect services that have a single pod.
99
-
100
-
After you select your service, you are prompted to enter the TCP port for your local application. For this example, enter "3000".
On the same terminal you were using earlier type below ot open stats-api in vscode.
107
79
108
-
> [!NOTE]
109
-
> You will be prompted to allow the **EndpointManager** to run elevated and modify your hosts file.
80
+
```azurecli
81
+
code ./stats-api
82
+
```
110
83
111
-
You have the option of running isolated or not isolated. If you run isolated, only your requests are routed to your local process; other developers can use the cluster without being affected. If you don't run isolated, all traffic is redirected to your local process. For more information on this option, see [Using routing capabilities for developing in isolation][btk-overview-routing].
84
+
First, place a breakpoint on line 17 of `server.js`.
Then, make sure todo-app namespace in MYAKS cluster is set as default (if it has * next to it). If it is not set as default, right-click the **todo-app** node, and choose **Use Namespace**.
114
87
115
-
Select the **Debug** icon on the left and select **Launch via NPM with Kubernetes** at the top.
88
+

116
89
117
-

90
+
Next, configure bridge: open the Command Palette (**CTRL**+**SHIFT**+**P** or **Cmd**+**Shift**+**P** on a Mac) and type Bridge to Kubernetes. Select the **Bridge to Kubernetes: Configure** option.
118
91
119
-
Your development computer is connected when the VS Code status bar turns orange and the Kubernetes extension shows you are connected.
92
+

You are prompted to configure the service you want to replace, the port to forward from your developmentcomputer, and the launch task to use.
122
95
123
-
> [!NOTE]
124
-
> On subsequent launches, you will not be prompted for the service name, port, launch task, or whether to run isolated. These values are saved in `.vscode/tasks.json`. To change these settings later, open the Command Palette (**CTRL**+**SHIFT**+**P** or **Cmd**+**Shift**+**P** on a Mac), and run the command **Bridge to Kubernetes: Configure**.
96
+
Choose the `stats-api` service.
125
97
126
-
Once your development computer is connected, traffic starts redirecting to your development computer for the service you are replacing.
98
+

127
99
128
-
## Set a break point
100
+
> [!IMPORTANT]
101
+
> You can only redirect services that have a single pod.
129
102
130
-
Open [server.js][server-js-breakpoint] and put your cursor somewhere on line 233. Set a breakpoint with **F9** or selecting **Run** then **Toggle Breakpoint**.
103
+
After you select your service, you are prompted to enter the TCP port for your local application. For this example, enter 3001.
131
104
132
-
Navigate to the sample application by opening the public URL. Select **Aurelia Briggs (customer)** as the user, then select a bike to rent. Notice the image for the bike does not load. Return to Visual Studio Code and observe line 233 is highlighted. The breakpoint you set has paused the service at line 233. To resume the service, hit **F5** or select **Run** then **Continue**. Return to your browser and verify you see a placeholder image for the bike.
105
+

133
106
134
-
Remove the breakpoint by putting your cursor on line 233 in `server.js` and hitting **F9**.
107
+
Choose **Run Script: dev** as the launch task.
135
108
136
-
### Update your application
109
+

137
110
138
-
Edit `server.js`to remove lines 234 and 235:
111
+
You have the option of running isolated or not isolated. If you run isolated, only your requests are routed to your local process; other developers can use the cluster without being affected. If you don't run isolated, all traffic is redirected to your local process. For more information on this option, see [Using routing capabilities for developing in isolation](overview-bridge-to-kubernetes.md#using-routing-capabilities-for-developing-in-isolation). For this example, we will proceed with non-isolated. If you chose isolation, task.json will have the prefix you should use to route request to your machine.
139
112
140
-
```javascript
141
-
// Hard code image url *FIX ME*
142
-
theBike.imageUrl="/static/logo.svg";
143
-
```
113
+

144
114
145
-
The section should now look like:
115
+
> [!NOTE]
116
+
> On subsequent launches, you will just click the debug icon without going through this set up and being prompted for the service name, port, launch task, or whether to run isolated. These values are saved in `.vscode/tasks.json`. To change these settings later, open the Command Palette (**CTRL**+**SHIFT**+**P** or **Cmd**+**Shift**+**P** on a Mac), and run the command **Bridge to Kubernetes: Configure**.
146
117
147
-
```javascript
148
-
var theBike = result;
149
-
theBike.id=theBike._id;
150
-
deletetheBike._id;
151
-
```
118
+
The Bridge to Kubernetes debugging profile has been successfully configured.
152
119
153
-
Save your changes and press **Ctrl**+**Shift**+**F5** (**⇧⌘F5** on a Mac) or select **Run** then **Restart Debugging**. After you are reconnected, refresh your browser and verify that you no longer see a placeholder image for the bike.
120
+
To start debugging, select the Debug icon on the left and select **Run Script: dev with Kubernetes**. Click the start button next to **Run Script: dev with Kubernetes**.
154
121
155
-
Select **Run** then **Stop Debugging** or press **Shift**+**F5** to stop the debugger.
122
+

156
123
157
124
> [!NOTE]
158
-
> By default, stopping the debugging task also disconnects your development computer from your Kubernetes cluster. You can change this behavior by searching for **Bridge to Kubernetes: Disconnect After Debugging** in the Visual Studio Code settings and removing the check next to **Disconnect automatically when Debugging ends**. After updating this setting, your development computer will remain connected when you stop and start debugging. To disconnect your development computer from your cluster, click on the Bridge to Kubernetes extension on the status bar then choose **Disconnect current session**.
159
-
160
-
## Additional configuration
161
-
162
-
Bridge to Kubernetes can handle routing traffic and replicating environment variables without any additional configuration. If you need to locally replicate services from other namespaces or download any files that are mounted to the container in your Kubernetes cluster, such as a ConfigMap file, you can create a `KubernetesLocalProcessConfig.yaml` to download those files to your development computer. For more information, see [Configure Bridge to Kubernetes][kubernetesLocalProcessConfig-yaml].
125
+
> You will be prompted to allow the EndpointManager to run elevated and modify your hosts file.
163
126
164
-
## Using logging and diagnostics
127
+
Your development computer is connected when the VS Code status bar turns orange and the Kubernetes extension shows you are connected. Once your development computer is connected, traffic starts redirecting to your development computer for the stats-api you are replacing.
165
128
166
-
Logging output is written to the **Bridge to Kubernetes** window after your development computer is connected to your Kubernetes cluster.
129
+

Navigate to the frontend entry point of your todo-app. Using that external IP you found earlier (your external IP from get services command).nip.io. Note, if you selected isolation mode, you will need to use (your prefix - can be found in task.json).(your external IP from get services command).nip.io.
169
132
170
-
Click on the **Kubernetes** Status bar and choose **Show connection diagnostics information**. This command prints the current environment variables and DNS entries in the logging output.
133
+
Make a request to the stats-api by choosing the **stats** link.
171
134
172
-

135
+

173
136
174
-
Additionally, you can find the diagnostic logs in the `Bridge to Kubernetes` directory in your development computer's TEMP directory. On Windows 10, that's in `%TEMP%\Bridge to Kubernetes`. On a Mac, the TEMP directory can be found by running `echo $TMPDIR` from a terminal window. On Linux, it is `/tmp/Bridge to Kubernetes`.
137
+
Notice the traffic that initially started in your cluster was redirected to your locally running version (outside of the cluster) where the breakpoint was triggered.
175
138
176
-
## Running in isolation mode
139
+
Press play and let the request continue complete transparently.
177
140
178
-
With Bridge to Kubernetes, you can also set up an isolated version the services you're working on, meaning that others who are using the cluster won't be affected by your changes. This isolation mode is accomplished by routing your requests to your copy of each affected service, but routing all other traffic normally. More explanation on how this is done can be found at [How Bridge to Kubernetes Works][btk-overview-routing].
141
+
## Clean up
179
142
180
-
## Remove the sample application from your cluster
143
+
When you stop the debugger all changes to the cluster are reverted. Note, if you were running with isolation on, the routing manager pod will be left there to expedite the start of the debugger the next time around.
181
144
182
-
Use the provided script to remove the sample application from your cluster.
145
+
You can leave your AKS cluster on for future debugging or you can delete it with below command.
az aks delete --name MyAKS --resource-group MyResourceGroup
186
149
```
187
150
188
-
## Troubleshooting
189
-
190
-
If you get this error when activating the Bridge to Kubernetes extension:
191
-
192
-
"Failed to update dependencies: maximum number of retries exceeded"
193
-
194
-
First, retry the activation using the button. If it repeatedly does not succeed, see [https://github.com/microsoft/mindaro/issues/32](https://github.com/microsoft/mindaro/issues/32).
195
-
196
151
## Next steps
197
152
198
153
Learn more about Bridge to Kubernetes at [How Bridge to Kubernetes works][btk-how-it-works].
0 commit comments