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
description: "Review and test changes from a pull request directly in Azure Kubernetes Service using GitHub Actions and Azure Dev Spaces."
11
11
keywords: "Docker, Kubernetes, Azure, AKS, Azure Kubernetes Service, containers, GitHub Actions, Helm, service mesh, service mesh routing, kubectl, k8s"
@@ -17,40 +17,21 @@ Azure Dev Spaces provides a workflow using GitHub Actions that allows you to tes
17
17
18
18
In this guide, you will learn how to:
19
19
20
-
- Set up Azure Dev Spaces on a managed Kubernetes cluster in Azure.
21
-
- Deploy a large application with multiple microservices to a dev space.
22
-
- Set up CI/CD with GitHub actions.
23
-
- Test a single microservice in an isolated dev space within the context of the full application.
20
+
* Set up Azure Dev Spaces on a managed Kubernetes cluster in Azure.
21
+
* Deploy a large application with multiple microservices to a dev space.
22
+
* Set up CI/CD with GitHub actions.
23
+
* Test a single microservice in an isolated dev space within the context of the full application.
24
24
25
25
> [!IMPORTANT]
26
26
> This feature is currently in preview. Previews are made available to you on the condition that you agree to the [supplemental terms of use](https://azure.microsoft.com/support/legal/preview-supplemental-terms/). Some aspects of this feature may change prior to general availability (GA).
27
27
28
28
## Prerequisites
29
29
30
-
- An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free).
31
-
-[Azure CLI installed][azure-cli-installed].
32
-
-[Helm 2.13 or greater installed][helm-installed].
33
-
- A GitHub Account with [GitHub Actions enabled][github-actions-beta-signup].
34
-
35
-
## Create an Azure Kubernetes Service cluster
36
-
37
-
You must create an AKS cluster in a [supported region][supported-regions]. The below commands create a resource group called *MyResourceGroup* and an AKS cluster called *MyAKS*.
38
-
39
-
```cmd
40
-
az group create --name MyResourceGroup --location eastus
41
-
az aks create -g MyResourceGroup -n MyAKS --location eastus --disable-rbac --generate-ssh-keys
42
-
```
43
-
44
-
## Enable Azure Dev Spaces on your AKS cluster
45
-
46
-
Use the `use-dev-spaces` command to enable Dev Spaces on your AKS cluster and follow the prompts. The below command enables Dev Spaces on the *MyAKS* cluster in the *MyResourceGroup* group and creates a dev space called *dev*.
47
-
48
-
> [!NOTE]
49
-
> The `use-dev-spaces` command will also install the Azure Dev Spaces CLI if its not already installed. You cannot install the Azure Dev Spaces CLI in the Azure Cloud Shell.
50
-
51
-
```cmd
52
-
az aks use-dev-spaces -g MyResourceGroup -n MyAKS --space dev --yes
53
-
```
30
+
* An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free).
31
+
*[Azure CLI installed][azure-cli-installed].
32
+
*[Helm 2.13 or greater installed][helm-installed].
33
+
* A GitHub Account with [GitHub Actions enabled][github-actions-beta-signup].
34
+
* The [Azure Dev Spaces Bike Sharing sample application](https://github.com/Azure/dev-spaces/tree/master/samples/BikeSharingApp/README.md) running on an AKS cluster.
54
35
55
36
## Create an Azure Container Registry
56
37
@@ -98,95 +79,19 @@ az role assignment create --assignee <ClientId> --scope <ACRId> --role AcrPush
98
79
> [!IMPORTANT]
99
80
> You must be the owner of both your AKS cluster and ACR in order to give your service principal access to those resources.
100
81
101
-
## Get sample application code
102
-
103
-
In this article, you use the [Azure Dev Spaces Bike Sharing sample application][bike-sharing-gh] to demonstrate using Azure Dev Spaces with GitHub actions.
104
-
105
-
Fork the Azure Dev Spaces sample repository then navigate to your forked repository. Click on the *Actions* tab and choose to enable actions for this repository.
106
-
107
-
Clone your forked repository and navigate into its directory:
108
-
109
-
```cmd
110
-
git clone https://github.com/USERNAME/dev-spaces
111
-
cd dev-spaces/samples/BikeSharingApp/
112
-
```
113
-
114
-
## Retrieve the HostSuffix for *dev*
115
-
116
-
Use the `azds show-context` command to show the HostSuffix for *dev*.
Open [charts/values.yaml][bike-sharing-values-yaml] and replace all instances of `<REPLACE_ME_WITH_HOST_SUFFIX>` with the HostSuffix value you retrieved earlier. Save your changes and close the file.
129
-
130
-
## Run the sample application in Kubernetes
131
-
132
-
The commands for running the sample application on Kubernetes are part of an existing process and have no dependency on Azure Dev Spaces tooling. In this case, Helm is the tooling used to run this sample application but other tooling could be used to run your entire application in a namespace within a cluster. The Helm commands are targeting the dev space named *dev* you created earlier, but this dev space is also a Kubernetes namespace. As a result, dev spaces can be targeted by other tooling the same as other namespaces.
133
-
134
-
You can use Azure Dev Spaces for development after an application is running in a cluster regardless of the tooling used to deploy it.
135
-
136
-
Use the `helm init` and `helm install` commands to set up and install the sample application on your cluster.
137
-
138
-
```cmd
139
-
cd charts/
140
-
helm init --wait
141
-
helm install -n bikesharing . --dep-up --namespace dev --atomic
142
-
```
143
-
144
-
> [!Note]
145
-
> **If you are using an RBAC-enabled cluster**, be sure to configure [a service account for Tiller][tiller-rbac]. Otherwise, `helm` commands will fail.
146
-
147
-
The `helm install` command may take several minutes to complete. The output of the command shows the status of all the services it deployed to the cluster when completed:
148
-
149
-
```cmd
150
-
$ cd charts/
151
-
$ helm init --wait
152
-
...
153
-
Happy Helming!
154
-
155
-
$ helm install -n bikesharing . --dep-up --namespace dev --atomic
156
-
157
-
Hang tight while we grab the latest from your chart repositories...
158
-
...
159
-
NAME READY UP-TO-DATE AVAILABLE AGE
160
-
bikes 1/1 1 1 4m32s
161
-
bikesharingweb 1/1 1 1 4m32s
162
-
billing 1/1 1 1 4m32s
163
-
gateway 1/1 1 1 4m32s
164
-
reservation 1/1 1 1 4m32s
165
-
reservationengine 1/1 1 1 4m32s
166
-
users 1/1 1 1 4m32s
167
-
```
168
-
169
-
After the sample application is installed on your cluster and since you have Dev Spaces enabled on your cluster, use the `azds list-uris` command to display the URLs for the sample application in *dev* that is currently selected.
http://dev.bikesharingweb.fedcab0987.eus.azds.io/ Available
176
-
http://dev.gateway.fedcab0987.eus.azds.io/ Available
177
-
```
178
-
179
-
Navigate to the *bikesharingweb* service by opening the public URL from the `azds list-uris` command. In the above example, the public URL for the *bikesharingweb* service is `http://dev.bikesharingweb.fedcab0987.eus.azds.io/`. Select *Aurelia Briggs (customer)* as the user, then select a bike to rent. Verify you see a placeholder image for the bike.
180
-
181
82
## Configure your GitHub action
182
83
84
+
> [!IMPORTANT]
85
+
> You must have GitHub Actions enabled for your repository. To enable GitHub Actions for your repository, navigate to your repository on GitHub, click on the Actions tab, and choose to enable actions for this repository.
86
+
183
87
Navigate to your forked repository and click *Settings*. Click on *Secrets* in the left sidebar. Click *Add a new secret* to add each new secret below:
184
88
185
89
1.*AZURE_CREDENTIALS*: the entire output from the service principal creation.
186
90
1.*RESOURCE_GROUP*: the resource group for your AKS cluster, which in this example is *MyResourceGroup*.
187
91
1.*CLUSTER_NAME*: the name of your AKS cluster, which in this example is *MyAKS*.
188
92
1.*CONTAINER_REGISTRY*: the *loginServer* for the ACR.
189
93
1.*HOST*: the host for your Dev Space, which takes the form *<MASTER_SPACE>.<APP_NAME>.<HOST_SUFFIX>*, which in this example is *dev.bikesharingweb.fedcab0987.eus.azds.io*.
94
+
1.*HOST_SUFFIX*: the host suffix for your Dev Space, which in this example is *fedcab0987.eus.azds.io*.
190
95
1.*IMAGE_PULL_SECRET*: the name of the secret you wish to use, for example *demo-secret*.
191
96
1.*MASTER_SPACE*: the name of your parent Dev Space, which in this example is *dev*.
192
97
1.*REGISTRY_USERNAME*: the *clientId* from the JSON output from the service principal creation.
@@ -197,10 +102,10 @@ Navigate to your forked repository and click *Settings*. Click on *Secrets* in t
197
102
198
103
## Create a new branch for code changes
199
104
200
-
Navigate back to `BikeSharingApp/` and create a new branch called *bike-images*.
105
+
Navigate to `BikeSharingApp/` and create a new branch called *bike-images*.
201
106
202
107
```cmd
203
-
cd ..
108
+
cd dev-spaces/samples/BikeSharingApp/
204
109
git checkout -b bike-images
205
110
```
206
111
@@ -234,7 +139,7 @@ Use `git push` to push your new branch to your forked repository:
234
139
git push origin bike-images
235
140
```
236
141
237
-
After the push is complete, navigate to your forked repository on GitHub create a pull request with the *master* in your forked repository as the base branch compared to the *bike-images* branch.
142
+
After the push is complete, navigate to your forked repository on GitHub create a pull request with the *dev* in your forked repository as the base branch compared to the *bike-images* branch.
238
143
239
144
After your pull request is opened, navigate to the *Actions* tab. Verify a new action has started and is building the *Bikes* service.
240
145
@@ -247,6 +152,8 @@ After the action has completed, you will see a comment with a URL to your new ch
247
152
248
153
Navigate to the *bikesharingweb* service by opening the URL from the comment. Select *Aurelia Briggs (customer)* as the user, then select a bike to rent. Verify you no longer see the placeholder image for the bike.
249
154
155
+
If you merge your changes into the *dev* branch, another action will run to rebuild and run your entire application in the parent dev space. This requires In this example, the parent space is *dev*. This action is configured in [.github/workflows/bikesharing.yml][github-action-bikesharing-yaml].
0 commit comments