Skip to content

Commit c06a8af

Browse files
authored
Merge pull request #100234 from zr-msft/aks-ingress-basic-helm3
[AKS] updated ingress for helm 3
2 parents 42a5a48 + b45ab4a commit c06a8af

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

articles/aks/ingress-basic.md

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: mlearned
66

77
ms.service: container-service
88
ms.topic: article
9-
ms.date: 05/24/2019
9+
ms.date: 12/20/2019
1010
ms.author: mlearned
1111
---
1212

@@ -25,18 +25,18 @@ You can also:
2525

2626
## Before you begin
2727

28-
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].
28+
This article uses Helm to install the NGINX ingress controller and a sample web app.
2929

3030
This article also requires that you are running the Azure CLI version 2.0.64 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
3131

3232
## Create an ingress controller
3333

34-
To create the ingress controller, use `Helm` to install *nginx-ingress*. For added redundancy, two replicas of the NGINX ingress controllers are deployed with the `--set controller.replicaCount` parameter. To fully benefit from running replicas of the ingress controller, make sure there's more than one node in your AKS cluster.
34+
To create the ingress controller, use Helm to install *nginx-ingress*. For added redundancy, two replicas of the NGINX ingress controllers are deployed with the `--set controller.replicaCount` parameter. To fully benefit from running replicas of the ingress controller, make sure there's more than one node in your AKS cluster.
3535

3636
The ingress controller also needs to be scheduled on a Linux node. Windows Server nodes (currently in preview in AKS) shouldn't run the ingress controller. A node selector is specified using the `--set nodeSelector` parameter to tell the Kubernetes scheduler to run the NGINX ingress controller on a Linux-based node.
3737

3838
> [!TIP]
39-
> The following example creates a Kubernetes namespace for the ingress resources named *ingress-basic*. Specify a namespace for your own environment as needed. If your AKS cluster is not RBAC enabled, add `--set rbac.create=false` to the Helm commands.
39+
> The following example creates a Kubernetes namespace for the ingress resources named *ingress-basic*. Specify a namespace for your own environment as needed.
4040
4141
> [!TIP]
4242
> If you would like to enable [client source IP preservation][client-source-ip] for requests to containers in your cluster, add `--set controller.service.externalTrafficPolicy=Local` to the Helm install command. The client source IP is stored in the request header under *X-Forwarded-For*. When using an ingress controller with client source IP preservation enabled, SSL pass-through will not work.
@@ -45,10 +45,12 @@ The ingress controller also needs to be scheduled on a Linux node. Windows Serve
4545
# Create a namespace for your ingress resources
4646
kubectl create namespace ingress-basic
4747

48+
# Add the official stable repository
49+
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
50+
4851
# Use Helm to deploy an NGINX ingress controller
49-
helm install stable/nginx-ingress \
52+
helm install nginx-ingress stable/nginx-ingress \
5053
--namespace ingress-basic \
51-
--name nginx-ingress \
5254
--set controller.replicaCount=2 \
5355
--set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \
5456
--set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux
@@ -59,16 +61,16 @@ When the Kubernetes load balancer service is created for the NGINX ingress contr
5961
```
6062
$ kubectl get service -l app=nginx-ingress --namespace ingress-basic
6163
62-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
63-
aspiring-labradoodle-nginx-ingress-controller LoadBalancer 10.0.61.144 40.117.74.8 80:30386/TCP,443:32276/TCP 6m2s
64-
aspiring-labradoodle-nginx-ingress-default-backend ClusterIP 10.0.192.145 <none> 80/TCP 6m2s
64+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
65+
nginx-ingress-controller LoadBalancer 10.0.61.144 EXTERNAL_IP 80:30386/TCP,443:32276/TCP 6m2s
66+
nginx-ingress-default-backend ClusterIP 10.0.192.145 <none> 80/TCP 6m2s
6567
```
6668

6769
No ingress rules have been created yet, so the NGINX ingress controller's default 404 page is displayed if you browse to the internal IP address. Ingress rules are configured in the following steps.
6870

6971
## Run demo applications
7072

71-
To see the ingress controller in action, 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.
73+
To see the ingress controller in action, 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.
7274

7375
Before you can install the sample Helm charts, add the Azure samples repository to your Helm environment as follows:
7476

@@ -79,23 +81,23 @@ helm repo add azure-samples https://azure-samples.github.io/helm-charts/
7981
Create the first demo application from a Helm chart with the following command:
8082

8183
```console
82-
helm install azure-samples/aks-helloworld --namespace ingress-basic
84+
helm install aks-helloworld azure-samples/aks-helloworld --namespace ingress-basic
8385
```
8486

8587
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:
8688

8789
```console
88-
helm install azure-samples/aks-helloworld \
90+
helm install aks-helloworld-two azure-samples/aks-helloworld \
8991
--namespace ingress-basic \
9092
--set title="AKS Ingress Demo" \
91-
--set serviceName="ingress-demo"
93+
--set serviceName="aks-helloworld-two"
9294
```
9395

9496
## Create an ingress route
9597

9698
Both applications are now running on your Kubernetes cluster. To route traffic to each application, create a Kubernetes ingress resource. The ingress resource configures the rules that route traffic to one of the two applications.
9799

98-
In the following example, traffic to the address `http://40.117.74.8/` is routed to the service named `aks-helloworld`. Traffic to the address `http://40.117.74.8/hello-world-two` is routed to the `ingress-demo` service.
100+
In the following example, traffic to *EXTERNAL_IP* is routed to the service named `aks-helloworld`. Traffic to *EXTERNAL_IP/hello-world-two* is routed to the `aks-helloworld-two` service. Traffic to *EXTERNAL_IP/static* is routed to the service named `aks-helloworld` for static assets.
99101

100102
Create a file named `hello-world-ingress.yaml` and copy in the following example YAML.
101103

@@ -118,9 +120,27 @@ spec:
118120
servicePort: 80
119121
path: /(.*)
120122
- backend:
121-
serviceName: ingress-demo
123+
serviceName: aks-helloworld-two
122124
servicePort: 80
123125
path: /hello-world-two(/|$)(.*)
126+
---
127+
apiVersion: extensions/v1beta1
128+
kind: Ingress
129+
metadata:
130+
name: hello-world-ingress-static
131+
namespace: ingress-basic
132+
annotations:
133+
kubernetes.io/ingress.class: nginx
134+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
135+
nginx.ingress.kubernetes.io/rewrite-target: /static/$2
136+
spec:
137+
rules:
138+
- http:
139+
paths:
140+
- backend:
141+
serviceName: aks-helloworld
142+
servicePort: 80
143+
path: /static(/|$)(.*)
124144
```
125145
126146
Create the ingress resource using the `kubectl apply -f hello-world-ingress.yaml` command.
@@ -129,15 +149,16 @@ Create the ingress resource using the `kubectl apply -f hello-world-ingress.yaml
129149
$ kubectl apply -f hello-world-ingress.yaml
130150

131151
ingress.extensions/hello-world-ingress created
152+
ingress.extensions/hello-world-ingress-static created
132153
```
133154
134155
## Test the ingress controller
135156
136-
To test the routes for the ingress controller, browse to the two applications. Open a web browser to the IP address of your NGINX ingress controller, such as *http://40.117.74.8*. The first demo application is displayed in the web browser, as shown in the follow example:
157+
To test the routes for the ingress controller, browse to the two applications. Open a web browser to the IP address of your NGINX ingress controller, such as *EXTERNAL_IP*. The first demo application is displayed in the web browser, as shown in the follow example:
137158
138159
![First app running behind the ingress controller](media/ingress-basic/app-one.png)
139160
140-
Now add the */hello-world-two* path to the IP address, such as *http://40.117.74.8/hello-world-two*. The second demo application with the custom title is displayed:
161+
Now add the */hello-world-two* path to the IP address, such as *EXTERNAL_IP/hello-world-two*. The second demo application with the custom title is displayed:
141162
142163
![Second app running behind the ingress controller](media/ingress-basic/app-two.png)
143164
@@ -164,22 +185,22 @@ helm repo remove azure-samples
164185
Alternatively, a more granular approach is to delete the individual resources created. List the Helm releases with the `helm list` command. Look for charts named *nginx-ingress* and *aks-helloworld*, as shown in the following example output:
165186

166187
```
167-
$ helm list
188+
$ helm list --namespace ingress-basic
168189
169-
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
170-
aspiring-labradoodle 1 Wed Mar 27 19:55:37 2019 DEPLOYED nginx-ingress-1.3.1 0.22.0 ingress-basic
171-
esteemed-koala 1 Wed Mar 27 19:59:18 2019 DEPLOYED aks-helloworld-0.1.0 ingress-basic
172-
wonderful-puma 1 Wed Mar 27 19:59:07 2019 DEPLOYED aks-helloworld-0.1.0 ingress-basic
190+
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
191+
aks-helloworld ingress-basic 1 2020-01-06 19:57:00.131576 -0600 CST deployed aks-helloworld-0.1.0
192+
aks-helloworld-two ingress-basic 1 2020-01-06 19:57:10.971365 -0600 CST deployed aks-helloworld-0.1.0
193+
nginx-ingress ingress-basic 1 2020-01-06 19:55:46.358275 -0600 CST deployed nginx-ingress-1.27.1 0.26.1
173194
```
174195

175196
Delete the releases with the `helm delete` command. The following example deletes the NGINX ingress deployment, and the two sample AKS hello world apps.
176197

177198
```
178-
$ helm delete aspiring-labradoodle esteemed-koala wonderful-puma
199+
$ helm delete aks-helloworld aks-helloworld-two nginx-ingress --namespace ingress-basic
179200
180-
release "aspiring-labradoodle" deleted
181-
release "esteemed-koala" deleted
182-
release "wonderful-puma" deleted
201+
release "aks-helloworld" uninstalled
202+
release "aks-helloworld-two" uninstalled
203+
release "nginx-ingress" uninstalled
183204
```
184205

185206
Next, remove the Helm repo for the AKS hello world app:

0 commit comments

Comments
 (0)