Skip to content

Commit f29aa76

Browse files
authored
Merge pull request #108508 from zr-msft/ds-traefik-ingress-rbac
[Dev Spaces] added RBAC for helm upgrade
2 parents 4ec2d3a + 93f50f6 commit f29aa76

File tree

1 file changed

+51
-7
lines changed

1 file changed

+51
-7
lines changed

articles/dev-spaces/how-to/ingress-https-traefik.md

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ helm repo add stable https://kubernetes-charts.storage.googleapis.com/
4545
Create a Kubernetes namespace for the traefik ingress controller and install it using `helm`.
4646

4747
> [!NOTE]
48-
> If your AKS does not have RBAC enabled, remove the *--set rbac.enabled=true* parameter.
48+
> If your AKS cluster does not have RBAC enabled, remove the *--set rbac.enabled=true* parameter.
4949
5050
```console
5151
kubectl create ns traefik
@@ -212,12 +212,50 @@ Use `kubectl` to apply `letsencrypt-clusterissuer.yaml`.
212212
kubectl apply -f letsencrypt-clusterissuer.yaml --namespace traefik
213213
```
214214

215-
Upgrade traefik to use HTTPS using `helm`.
215+
Remove the previous *traefik* *ClusterRole* and *ClusterRoleBinding*, then upgrade traefik to use HTTPS using `helm`.
216+
217+
> [!NOTE]
218+
> If your AKS cluster does not have RBAC enabled, remove the *--set rbac.enabled=true* parameter.
219+
220+
```console
221+
kubectl delete ClusterRole traefik
222+
kubectl delete ClusterRoleBinding traefik
223+
helm upgrade traefik stable/traefik --namespace traefik --set kubernetes.ingressClass=traefik --set rbac.enabled=true --set kubernetes.ingressEndpoint.useDefaultPublishedService=true --version 1.85.0 --set ssl.enabled=true --set ssl.enforced=true --set ssl.permanentRedirect=true
224+
```
225+
226+
Get the updated IP address of the traefik ingress controller service using [kubectl get][kubectl-get].
227+
228+
```console
229+
kubectl get svc -n traefik --watch
230+
```
231+
232+
The sample output shows the IP addresses for all the services in the *traefik* name space.
216233

217234
```console
218-
helm upgrade traefik stable/traefik --namespace traefik --set kubernetes.ingressClass=traefik --set kubernetes.ingressEndpoint.useDefaultPublishedService=true --version 1.85.0 --set ssl.enabled=true --set ssl.enforced=true --set ssl.permanentRedirect=true
235+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
236+
traefik LoadBalancer 10.0.205.78 <pending> 80:32484/TCP,443:30620/TCP 20s
237+
...
238+
traefik LoadBalancer 10.0.205.78 MY_NEW_EXTERNAL_IP 80:32484/TCP,443:30620/TCP 60s
219239
```
220240

241+
Add an *A* record to your DNS zone with the new external IP address of the traefik service using [az network dns record-set a add-record][az-network-dns-record-set-a-add-record] and remove the previous *A* record using [az network dns record-set a remove-record][az-network-dns-record-set-a-remove-record].
242+
243+
```azurecli
244+
az network dns record-set a add-record \
245+
--resource-group myResourceGroup \
246+
--zone-name MY_CUSTOM_DOMAIN \
247+
--record-set-name *.traefik \
248+
--ipv4-address MY_NEW_EXTERNAL_IP
249+
250+
az network dns record-set a remove-record \
251+
--resource-group myResourceGroup \
252+
--zone-name MY_CUSTOM_DOMAIN \
253+
--record-set-name *.traefik \
254+
--ipv4-address PREVIOUS_EXTERNAL_IP
255+
```
256+
257+
The above example updates the *A* record in the *MY_CUSTOM_DOMAIN* DNS zone to use *PREVIOUS_EXTERNAL_IP*.
258+
221259
Update [values.yaml][values-yaml] to include the details for using *cert-manager* and HTTPS. Below is an example of an updated `values.yaml` file:
222260

223261
```yaml
@@ -252,10 +290,15 @@ gateway:
252290
Upgrade the sample application using `helm`:
253291

254292
```console
255-
helm upgrade bikesharing . --namespace dev --atomic
293+
helm upgrade bikesharingsampleapp . --namespace dev --atomic
256294
```
257295

258-
Navigate to the sample application in the *dev/azureuser1* child space and notice you are redirected to use HTTPS. Also notice that the page loads, but the browser shows some errors. Opening the browser console shows the error relates to an HTTPS page trying to load HTTP resources. For example:
296+
Navigate to the sample application in the *dev/azureuser1* child space and notice you are redirected to use HTTPS.
297+
298+
> [!IMPORTANT]
299+
> It may take 30 minutes or more for the DNS changes to complete and your sample application to be accessible.
300+
301+
Also notice that the page loads, but the browser shows some errors. Opening the browser console shows the error relates to an HTTPS page trying to load HTTP resources. For example:
259302

260303
```console
261304
Mixed Content: The page at 'https://azureuser1.s.dev.bikesharingweb.traefik.MY_CUSTOM_DOMAIN/devsignin' was loaded over HTTPS, but requested an insecure resource 'http://azureuser1.s.dev.gateway.traefik.MY_CUSTOM_DOMAIN/api/user/allUsers'. This request has been blocked; the content must be served over HTTPS.
@@ -286,7 +329,7 @@ Update [BikeSharingWeb/package.json][package-json] with a dependency for the *ur
286329
...
287330
```
288331

289-
Update the *getApiHostAsync* method in [BikeSharingWeb/pages/helpers.js][helpers-js] to use HTTPS:
332+
Update the *getApiHostAsync* method in [BikeSharingWeb/lib/helpers.js][helpers-js] to use HTTPS:
290333

291334
```javascript
292335
...
@@ -323,6 +366,7 @@ Learn how Azure Dev Spaces helps you develop more complex applications across mu
323366
[az-cli]: /cli/azure/install-azure-cli?view=azure-cli-latest
324367
[az-aks-get-credentials]: /cli/azure/aks?view=azure-cli-latest#az-aks-get-credentials
325368
[az-network-dns-record-set-a-add-record]: /cli/azure/network/dns/record-set/a?view=azure-cli-latest#az-network-dns-record-set-a-add-record
369+
[az-network-dns-record-set-a-remove-record]: /cli/azure/network/dns/record-set/a?view=azure-cli-latest#az-network-dns-record-set-a-remove-record
326370
[custom-domain]: ../../app-service/manage-custom-dns-buy-domain.md#buy-the-domain
327371
[dns-zone]: ../../dns/dns-getstarted-cli.md
328372
[qs-cli]: ../quickstart-cli.md
@@ -333,7 +377,7 @@ Learn how Azure Dev Spaces helps you develop more complex applications across mu
333377
[cert-manager]: https://cert-manager.io/
334378
[helm-installed]: https://helm.sh/docs/intro/install/
335379
[helm-stable-repo]: https://helm.sh/docs/intro/quickstart/#initialize-a-helm-chart-repository
336-
[helpers-js]: https://github.com/Azure/dev-spaces/blob/master/samples/BikeSharingApp/BikeSharingWeb/pages/helpers.js#L7
380+
[helpers-js]: https://github.com/Azure/dev-spaces/blob/master/samples/BikeSharingApp/BikeSharingWeb/lib/helpers.js#L7
337381
[kubectl]: https://kubernetes.io/docs/user-guide/kubectl/
338382
[kubectl-get]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#get
339383
[letsencrypt-staging-issuer]: https://cert-manager.io/docs/configuration/acme/#creating-a-basic-acme-issuer

0 commit comments

Comments
 (0)