Skip to content

Commit a63ba0f

Browse files
authored
Merge pull request #46852 from iainfoulds/aksingresshelm
[AKS] Clearer steps for ingress traffic
2 parents 802b8b6 + 0fac4a6 commit a63ba0f

File tree

2 files changed

+92
-59
lines changed

2 files changed

+92
-59
lines changed

articles/aks/ingress.md

Lines changed: 92 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,61 @@
11
---
22
title: Configure ingress with Azure Kubernetes Service (AKS) cluster
3-
description: Install and configure an NGINX ingress controller in an Azure Kubernetes Service (AKS) cluster.
3+
description: Learn how to install and configure an NGINX ingress controller that uses Let's Encrypt for automatic SSL certificate generation in an Azure Kubernetes Service (AKS) cluster.
44
services: container-service
55
author: iainfoulds
66
manager: jeconnoc
77

88
ms.service: container-service
99
ms.topic: article
10-
ms.date: 06/25/2018
10+
ms.date: 07/17/2018
1111
ms.author: iainfou
1212
ms.custom: mvc
1313
---
1414

15-
# HTTPS Ingress on Azure Kubernetes Service (AKS)
15+
# Deploy an HTTPS ingress controller on Azure Kubernetes Service (AKS)
1616

1717
An ingress controller is a piece of software that provides reverse proxy, configurable traffic routing, and TLS termination for Kubernetes services. Kubernetes ingress resources are used to configure the ingress rules and routes for individual Kubernetes services. Using an ingress controller and ingress rules, a single external address can be used to route traffic to multiple services in a Kubernetes cluster.
1818

19-
This document walks through a sample deployment of the [NGINX ingress controller][nginx-ingress] in an Azure Kubernetes Service (AKS) cluster. Additionally, the [cert-manager][cert-manager] project is used to automatically generate and configure [Let's Encrypt][lets-encrypt] certificates. Finally, several applications are run in the AKS cluster, each of which is accessible over a single address.
19+
This article shows you how to deploy the [NGINX ingress controller][nginx-ingress] in an Azure Kubernetes Service (AKS) cluster. The [cert-manager][cert-manager] project is used to automatically generate and configure [Let's Encrypt][lets-encrypt] certificates. Finally, several applications are run in the AKS cluster, each of which is accessible over a single address.
20+
21+
## Before you begin
22+
23+
This article uses Helm to install the NGINX ingress controller, cert-manager, and a sample web app. You need to have Helm initialized within your AKS cluster and using a service account for Tiller. For more information on configuring and using Helm, see [Install applications with Helm in Azure Kubernetes Service (AKS)][use-helm].
24+
25+
This article also requires that you are running the Azure CLI version 2.0.41 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
2026

2127
## Install an ingress controller
2228

23-
Use Helm to install the NGINX ingress controller. See the NGINX ingress controller [documentation][nginx-ingress] for detailed deployment information.
29+
Use Helm to install the NGINX ingress controller. For detailed deployment information, see the [NGINX ingress controller documentation][nginx-ingress].
2430

25-
This example installs the controller in the `kube-system` namespace, this can be modified to a namespace of your choice. If your AKS cluster is not RBAC enabled, add `--set rbac.create=false` to the command. For more information, see the [nginx-ingress chart][nginx-ingress].
31+
The following example installs the controller in the `kube-system` namespace. You can specify a different namespace for your own environment. If your AKS cluster is not RBAC enabled, add `--set rbac.create=false` to the command.
2632

27-
```bash
33+
```console
2834
helm install stable/nginx-ingress --namespace kube-system
2935
```
3036

31-
During the installation, an Azure public IP address is created for the ingress controller. To get the public IP address, use the kubectl get service command. It may take some time for the IP address to be assigned to the service.
37+
During the installation, an Azure public IP address is created for the ingress controller. To get the public IP address, use the `kubectl get service` command. It takes a few minutes for the IP address to be assigned to the service.
3238

33-
```console
39+
```
3440
$ kubectl get service -l app=nginx-ingress --namespace kube-system
3541
3642
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
3743
eager-crab-nginx-ingress-controller LoadBalancer 10.0.182.160 51.145.155.210 80:30920/TCP,443:30426/TCP 20m
3844
eager-crab-nginx-ingress-default-backend ClusterIP 10.0.255.77 <none> 80/TCP 20m
3945
```
4046

41-
Because no ingress rules have been created, if you browse to the public IP address, you are routed to the NGINX ingress controllers default 404 page.
47+
No ingress rules have been created yet. If you browse to the public IP address, the NGINX ingress controller's default 404 page is displayed, as shown in the following example:
4248

4349
![Default NGINX backend](media/ingress/default-back-end.png)
4450

45-
## Configure DNS name
51+
## Configure a DNS name
4652

47-
Because HTTPS certificates are used, you need to configure an FQDN name for the ingress controllers IP address. For this example, an Azure FQDN is created with the Azure CLI. Update the script with the IP address of the ingress controller and the name that you would like to use in the FQDN.
53+
For the HTTPS certificates to work correctly, configure an FQDN for the ingress controller IP address. Update the following script with the IP address of your ingress controller and a unique name that you would like to use for the FQDN:
4854

49-
```bash
55+
```console
5056
#!/bin/bash
5157

52-
# Public IP address
58+
# Public IP address of your ingress controller
5359
IP="51.145.155.210"
5460

5561
# Name to associate with public IP address
@@ -58,59 +64,70 @@ DNSNAME="demo-aks-ingress"
5864
# Get the resource-id of the public ip
5965
PUBLICIPID=$(az network public-ip list --query "[?ipAddress!=null]|[?contains(ipAddress, '$IP')].[id]" --output tsv)
6066

61-
# Update public ip address with dns name
67+
# Update public ip address with DNS name
6268
az network public-ip update --ids $PUBLICIPID --dns-name $DNSNAME
6369
```
6470

65-
The ingress controller should now be accessible through the FQDN.
71+
The ingress controller is now accessible through the FQDN.
6672

6773
## Install cert-manager
6874

69-
The NGINX ingress controller supports TLS termination. While there are several ways to retrieve and configure certificates for HTTPS, this document demonstrates using [cert-manager][cert-manager], which provides automatic [Lets Encrypt][lets-encrypt] certificate generation and management functionality.
75+
The NGINX ingress controller supports TLS termination. There are several ways to retrieve and configure certificates for HTTPS. This article demonstrates using [cert-manager][cert-manager], which provides automatic [Lets Encrypt][lets-encrypt] certificate generation and management functionality.
7076

71-
To install the cert-manager controller, use the following Helm install command.
77+
> [!NOTE]
78+
> This article uses the `staging` environment for Let's Encrypt. In production deployments, use `letsencrypt-prod` and `https://acme-v02.api.letsencrypt.org/directory` in the resource definitions and when installing the Helm chart.
7279
73-
```bash
74-
helm install stable/cert-manager --set ingressShim.defaultIssuerName=letsencrypt-prod --set ingressShim.defaultIssuerKind=ClusterIssuer
80+
To install the cert-manager controller in an RBAC-enabled cluster, use the following `helm install` command:
81+
82+
```console
83+
helm install stable/cert-manager --set ingressShim.defaultIssuerName=letsencrypt-staging --set ingressShim.defaultIssuerKind=ClusterIssuer
7584
```
7685

77-
If your cluster is not RBAC enabled, use this command.
86+
If your cluster is not RBAC enabled, instead use the following command:
7887

79-
```bash
88+
```console
8089
helm install stable/cert-manager \
81-
--set ingressShim.defaultIssuerName=letsencrypt-prod \
90+
--set ingressShim.defaultIssuerName=letsencrypt-staging \
8291
--set ingressShim.defaultIssuerKind=ClusterIssuer \
8392
--set rbac.create=false \
8493
--set serviceAccount.create=false
8594
```
8695

8796
For more information on cert-manager configuration, see the [cert-manager project][cert-manager].
8897

89-
## Create CA cluster issuer
98+
## Create a CA cluster issuer
9099

91-
Before certificates can be issued, cert-manager requires an [Issuer][cert-manager-issuer] or [ClusterIssuer][cert-manager-cluster-issuer] resource. The resources are identical in functionality however `Issuer` works in a single namespace where `ClusterIssuer` works across all namespaces. For more information, see the [cert-manager issuer][cert-manager-issuer] documentation.
100+
Before certificates can be issued, cert-manager requires an [Issuer][cert-manager-issuer] or [ClusterIssuer][cert-manager-cluster-issuer] resource. These Kubernetes resources are identical in functionality, however `Issuer` works in a single namespace, and `ClusterIssuer` works across all namespaces. For more information, see the [cert-manager issuer][cert-manager-issuer] documentation.
92101

93-
Create a cluster issuer using the following manifest. Update the email address with a valid address from your organization.
102+
Create a cluster issuer, such as `cluster-issuer.yaml`, using the following example manifest. Update the email address with a valid address from your organization:
94103

95104
```yaml
96105
apiVersion: certmanager.k8s.io/v1alpha1
97106
kind: ClusterIssuer
98107
metadata:
99-
name: letsencrypt-prod
108+
name: letsencrypt-staging
100109
spec:
101110
acme:
102-
server: https://acme-v02.api.letsencrypt.org/directory
111+
server: https://acme-staging-v02.api.letsencrypt.org/directory
103112
104113
privateKeySecretRef:
105-
name: letsencrypt-prod
114+
name: letsencrypt-staging
106115
http01: {}
107116
```
108117
109-
## Create certificate object
118+
To create the issuer, use the `kubectl create -f cluster-issuer.yaml` command.
119+
120+
```
121+
$ kubectl create -f cluster-issuer.yaml
122+
123+
clusterissuer.certmanager.k8s.io/letsencrypt-prod created
124+
```
125+
126+
## Create a certificate object
110127
111-
Next, a certificate resource must be created. The certificate resource defines the desired X.509 certificate. For more information, see, [cert-manager certificates][cert-manager-certificates].
128+
Next, a certificate resource must be created. The certificate resource defines the desired X.509 certificate. For more information, see [cert-manager certificates][cert-manager-certificates].
112129
113-
Create the certificate resource with the following manifest.
130+
Create the certificate resource, such as `certificates.yaml`, with the following example manifest. Update the *dnsNames* and *domains* to the DNS name you created in a previous step.
114131
115132
```yaml
116133
apiVersion: certmanager.k8s.io/v1alpha1
@@ -128,43 +145,47 @@ spec:
128145
domains:
129146
- demo-aks-ingress.eastus.cloudapp.azure.com
130147
issuerRef:
131-
name: letsencrypt-prod
148+
name: letsencrypt-staging
132149
kind: ClusterIssuer
133150
```
134151

135-
## Run application
152+
To create the certificate resource, use the `kubectl create -f certificates.yaml` command.
153+
154+
```
155+
$ kubectl create -f certificates.yaml
156+
157+
certificate.certmanager.k8s.io/tls-secret created
158+
```
136159

137-
At this point, an ingress controller and a certificate management solution have been configured. Now run a few applications in your AKS cluster.
160+
## Run demo applications
138161

139-
For this example, Helm is used to run multiple instances of a simple hello world application.
162+
An ingress controller and a certificate management solution have been configured. Now let's run two demo applications in your AKS cluster. In this example, Helm is used to deploy two instances of a simple 'Hello world' application.
140163

141-
Before running the application, add the Azure samples Helm repository on your development system.
164+
Before you can install the sample Helm charts, add the Azure samples repository to your Helm environment as follows:
142165

143-
```bash
166+
```console
144167
helm repo add azure-samples https://azure-samples.github.io/helm-charts/
145168
```
146169

147-
Run the AKS hello world chart with the following command:
170+
Create the first demo application from a Helm chart with the following command:
148171

149-
```bash
172+
```console
150173
helm install azure-samples/aks-helloworld
151174
```
152175

153-
Now install a second instance of the hello world application.
154-
155-
For the second instance, specify a new title so that the two applications are visually distinct. You also need to specify a unique service name. These configurations can be seen in the following command.
176+
Now install a second instance of the demo application. For the second instance, you specify a new title so that the two applications are visually distinct. You also specify a unique service name:
156177

157-
```bash
178+
```console
158179
helm install azure-samples/aks-helloworld --set title="AKS Ingress Demo" --set serviceName="ingress-demo"
159180
```
160181

161-
## Create ingress route
182+
## Create an ingress route
162183

163-
Both applications are now running on your Kubernetes cluster, however have been configured with a service of type `ClusterIP`. As such, the applications are not accessible from the internet. In order to make them available, create a Kubernetes ingress resource. The ingress resource configures the rules that route traffic to one of the two applications.
184+
Both applications are now running on your Kubernetes cluster, however they're configured with a service of type `ClusterIP`. As such, the applications aren't accessible from the internet. To make them publicly available, create a Kubernetes ingress resource. The ingress resource configures the rules that route traffic to one of the two applications.
164185

165-
Create a file name `hello-world-ingress.yaml` and copy in the following YAML.
186+
In the following example, traffic to the address `https://demo-aks-ingress.eastus.cloudapp.azure.com/` is routed to the service named `aks-helloworld`. Traffic to the address `https://demo-aks-ingress.eastus.cloudapp.azure.com/hello-world-two` is routed to the `ingress-demo` service. Update the *hosts* and *host* to the DNS name you created in a previous step.
166187

167-
Take note that the traffic to the address `https://demo-aks-ingress.eastus.cloudapp.azure.com/` is routed to the service named `aks-helloworld`. Traffic to the address `https://demo-aks-ingress.eastus.cloudapp.azure.com/hello-world-two` is routed to the `ingress-demo` service.
188+
Create a file named `hello-world-ingress.yaml` and copy in the following example YAML:
168189

169190
```yaml
170191
apiVersion: extensions/v1beta1
@@ -173,7 +194,7 @@ metadata:
173194
name: hello-world-ingress
174195
annotations:
175196
kubernetes.io/ingress.class: nginx
176-
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
197+
certmanager.k8s.io/cluster-issuer: letsencrypt-staging
177198
nginx.ingress.kubernetes.io/rewrite-target: /
178199
spec:
179200
tls:
@@ -194,29 +215,37 @@ spec:
194215
servicePort: 80
195216
```
196217
197-
Create the ingress resource with the `kubectl apply` command.
218+
Create the ingress resource using the `kubectl create -f hello-world-ingress.yaml` command.
198219

199-
```console
200-
kubectl apply -f hello-world-ingress.yaml
220+
```
221+
$ kubectl create -f hello-world-ingress.yaml
222+
223+
ingress.extensions/hello-world-ingress created
201224
```
202225
203226
## Test the ingress configuration
204227
205-
Browse to the FQDN of your Kubernetes ingress controller, you should see the hello world application.
228+
Open a web browser to the FQDN of your Kubernetes ingress controller, such as *https://demo-aks-ingress.eastus.cloudapp.azure.com*.
206229
207-
![Application example one](media/ingress/app-one.png)
230+
As these examples use `letsencrypt-staging`, the issued SSL certificate is not trusted by the browser. Accept the warning prompt to continue to your application. The certificate information shows this *Fake LE Intermediate X1* certificate is issued by Let's Encrypt. This fake certificate indicates `cert-manager` processed the request correctly and received a certificate from the provider:
208231
209-
Now browse to the FQDN of the ingress controller with the `/hello-world-two` path, you should see the hello world application with the custom title.
232+
![Let's Encrypt staging certificate](media/ingress/staging-certificate.png)
210233
211-
![Application example two](media/ingress/app-two.png)
234+
When you change Let's Encrypt to use `prod` rather than `staging`, a trusted certificate issued by Let's Encrypt is used, as shown in the following example:
235+
236+
![Let's Encrypt certificate](media/ingress/certificate.png)
237+
238+
The demo application is shown in the web browser:
212239
213-
Also notice that the connection is encrypted and that a certificate issued by Let's Encrypt is used.
240+
![Application example one](media/ingress/app-one.png)
241+
242+
Now add the */hello-world-two* path to the FQDN, such as *https://demo-aks-ingress.eastus.cloudapp.azure.com/hello-world-two*. The second demo application with the custom title is shown:
214243
215-
![Lets encrypt certificate](media/ingress/certificate.png)
244+
![Application example two](media/ingress/app-two.png)
216245
217246
## Next steps
218247
219-
Learn more about the software demonstrated in this document.
248+
This article included some external components to AKS. To learn more about these components, see the following project pages:
220249
221250
- [Helm CLI][helm-cli]
222251
- [NGINX ingress controller][nginx-ingress]
@@ -230,3 +259,7 @@ Learn more about the software demonstrated in this document.
230259
[cert-manager-issuer]: https://cert-manager.readthedocs.io/en/latest/reference/issuers.html
231260
[lets-encrypt]: https://letsencrypt.org/
232261
[nginx-ingress]: https://github.com/kubernetes/ingress-nginx
262+
263+
<!-- LINKS - internal -->
264+
[use-helm]: kubernetes-helm.md
265+
[azure-cli-install]: /cli/azure/install-azure-cli
48.7 KB
Loading

0 commit comments

Comments
 (0)