From b1d54dbe2da9985846d1fc8b9a60341d5a344b6a Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 10:55:48 +0100 Subject: [PATCH 1/7] Add howto doc for path-regex annotations --- .../ingress-path-regex-annotation.md | 456 ++++++++++++++++++ 1 file changed, 456 insertions(+) create mode 100644 docs/content/tutorials/ingress-path-regex-annotation.md diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md new file mode 100644 index 0000000000..e8135833ef --- /dev/null +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -0,0 +1,456 @@ +--- +title: Customizing Ingresses with Path-Regex Annotations +description: | + How to customize Ingress Types with path-regex annotations. +weight: 1800 +doctypes: ["concept"] +toc: true +--- +## Customizing NGINX Ingress Controller with Path-Regex Annotations + + +This document explains how to use `path-regex` annotations with Simpe Ingresses and Mergeable Ingresses (Master - Minion) +types. + +[NGINX documentation](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) provides +additional information about how NGINX and NGINX Plus resolve location priority. +Read [it](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) before using + the ``path-regex`` annotation. + +## Simple Ingress Type + +In this example, we will use the `nginx.org/path-regex` annotations to add regex modifiers the location paths. + +Start by modifying `cafe-ingress.tmpl` metadata. Add the annotation section and configure annotation ``nginx.org/path-regex`` +with value `case_sensitive`. + +The content of `cafe-ingress.tmpl`: + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress + annotations: + nginx.org/path-regex: "case_sensitive" +spec: + tls: + - hosts: + - cafe.example.com + secretName: cafe-secret + rules: + - host: cafe.example.com + http: + paths: + - path: /tea/[A-Z0-9] + backend: + serviceName: tea-svc + servicePort: 80 + - path: /coffee/[A-Z0-9] + backend: + serviceName: coffee-svc + servicePort: 80 +``` + +After creating the Ingress (`kubectl create -f cafe-ingres,yaml`), all defined paths will be updated. In the generated +NGINX config file the ``tea`` and ``coffee`` paths will look like in the snippets below: + +tea path: + +```bash +location ~ "^/tea/[A-Z0-9]" { +``` + +coffee path: + +```bash +location ~ "^/coffee/[A-Z0-9]" { +``` + +Note that the regex modifier `case_sensitive` is applied to all paths. + +To change regex modifier value from `case_sensitive` to `case_insensitive` update the `nginx.org/path-regex` annotation. +The config `cafe-ingress.tmpl` file below shows the change. + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress + annotations: + nginx.org/path-regex: "case_insensitive" +spec: + tls: + - hosts: + - cafe.example.com + secretName: cafe-secret + rules: + - host: cafe.example.com + http: + paths: + - path: /tea/[A-Z0-9] + backend: + serviceName: tea-svc + servicePort: 80 + - path: /coffee/[A-Z0-9] + backend: + serviceName: coffee-svc + servicePort: 80 +``` + +In the NGINX config file the ``tea`` and ``coffee`` paths will look like in the snippets below: + +tea path: + +```nginx +location ~* "^/tea/[A-Z0-9]" { +``` + +coffee path: + +```nginx +location ~* "^/coffee/[A-Z0-9]" { +``` + + +## Mergeable Ingress Type + +This document section explains how to deploy and configure Mergeable Ingress Type. + +You will deploy a Master Ingress and two Minion Ingresses. Next, you will configure them with `path-regex` annotations. + +Start by creating a Master Ingress. + +`cafe-master.yaml` +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress-master + annotations: + nginx.org/mergeable-ingress-type: "master" +spec: + ingressClassName: nginx + tls: + - hosts: + - cafe.example.com + secretName: cafe-secret + rules: + - host: cafe.example.com +``` + +Create the Ingress: + +```console +kubectl create -f cafe-master.yaml +``` + +Verify the Master Ingress is created + +```console +kubectl get ingress cafe-ingress-master + +NAME CLASS HOSTS ADDRESS PORTS AGE +cafe-ingress-master nginx cafe.example.com 80, 443 29s +``` + + +```console +kubectl describe ingress cafe-ingress-master + +Name: cafe-ingress-master +Labels: +Namespace: default +Address: +Ingress Class: nginx +Default backend: +TLS: + cafe-secret terminates cafe.example.com +Rules: + Host Path Backends + ---- ---- -------- + * * +Annotations: nginx.org/mergeable-ingress-type: master +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal AddedOrUpdated 62s nginx-ingress-controller Configuration for default/cafe-ingress-master was added or updated +``` + +Create first Ingress Minion. + +`tea-minion.yaml` +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress-tea-minion + annotations: + nginx.org/mergeable-ingress-type: "minion" +spec: + ingressClassName: nginx + rules: + - host: cafe.example.com + http: + paths: + - path: /tea + pathType: Prefix + backend: + service: + name: tea-svc + port: + number: 80 +``` + +```console +kubectl create -f tea-minion.yaml +ingress.networking.k8s.io/cafe-ingress-tea-minion created +``` + +Verify the minion was created + +```console +kubectl get ingress cafe-ingress-tea-minion + +NAME CLASS HOSTS ADDRESS PORTS AGE +cafe-ingress-tea-minion nginx cafe.example.com 80 23m +``` + +```console +kubectl describe ingress cafe-ingress-tea-minion + +Name: cafe-ingress-tea-minion +Labels: +Namespace: default +Address: +Ingress Class: nginx +Default backend: +Rules: + Host Path Backends + ---- ---- -------- + cafe.example.com + /tea tea-svc:80 (10.244.0.6:8080,10.244.0.7:8080,10.244.0.8:8080) +Annotations: nginx.org/mergeable-ingress-type: minion +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal AddedOrUpdated 24m nginx-ingress-controller Configuration for default/cafe-ingress-tea-minion was added or updated +``` + +Create second Minion + +`tea-minion.yaml` + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress-tea-minion + annotations: + nginx.org/mergeable-ingress-type: "minion" +spec: + ingressClassName: nginx + rules: + - host: cafe.example.com + http: + paths: + - path: /tea + pathType: Prefix + backend: + service: + name: tea-svc + port: + number: 80 +``` + + +```console +kubectl create -f tea-minion.yaml + +ingress.networking.k8s.io/cafe-ingress-tea-minion created +``` + +Verify the minion was created + +```console +kubectl get ingress cafe-ingress-tea-minion + +NAME CLASS HOSTS ADDRESS PORTS AGE +cafe-ingress-tea-minion nginx cafe.example.com 80 5m21s +``` + +```console +kubectl describe ingress cafe-ingress-tea-minion + +Name: cafe-ingress-tea-minion +Labels: +Namespace: default +Address: +Ingress Class: nginx +Default backend: +Rules: + Host Path Backends + ---- ---- -------- + cafe.example.com + /tea tea-svc:80 (10.244.0.6:8080,10.244.0.7:8080,10.244.0.8:8080) +Annotations: nginx.org/mergeable-ingress-type: minion +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal AddedOrUpdated 5m52s nginx-ingress-controller Configuration for default/cafe-ingress-tea-minion was added or updated +``` + +You created Master Ingress two Minion Ingresses. Minion Ingresses define two paths: `/tea` and `/coffee`. + +In the following steps, you will modify the paths by applying regex modifiers. + +Update Minion Ingress `Tea`: + +- add `path-regex` annotation with value `case_insensitive` +- modify path with regex you want to use (in the example below: `/tea/[A-Z0-9]`) + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress-tea-minion + annotations: + nginx.org/mergeable-ingress-type: "minion" + nginx.org/path-regex: "case_insensitive" +spec: + ingressClassName: nginx + rules: + - host: cafe.example.com + http: + paths: + - path: /tea/[A-Z0-9] + pathType: Prefix + backend: + service: + name: tea-svc + port: + number: 80 +``` + +Apply the changes + +```console +kuubectl apply -f tea-minion.yaml +``` + +Verify the change + +```console +kubectl describe ingress cafe-ingress-tea-minion + +Name: cafe-ingress-tea-minion +Labels: +Namespace: default +Address: +Ingress Class: nginx +Default backend: +Rules: + Host Path Backends + ---- ---- -------- + cafe.example.com + /tea/[A-Z0-9] tea-svc:80 (10.244.0.6:8080,10.244.0.7:8080,10.244.0.8:8080) +Annotations: nginx.org/mergeable-ingress-type: minion + nginx.org/path-regex: case_insensitive +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal AddedOrUpdated 47s (x2 over 34m) nginx-ingress-controller Configuration for default/cafe-ingress-tea-minion was added or updated +``` + +Note the updated list of annotations. The new `path-regex` annotation was added. +It updates the path `/tea/[A-Z0-9]` using `case_insensitive` reg-ex modifier. +Updated path (location) in the NGINX config file: `location ~* "^/tea/[A-Z0-9]"`. + +Note that the `path-regex` annotation applies only to paths defined on the corresponding Minion Ingress. +The paths defined in the second Minion (`coffee`) are not modified. + +Follow the steps below to configure the type `case_sensitive` regex modifier on the Second Minion Ingress. + +Modify deployed `coffee-minion.yaml` + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress-coffee-minion + annotations: + nginx.org/mergeable-ingress-type: "minion" +spec: + ingressClassName: nginx + rules: + - host: cafe.example.com + http: + paths: + - path: /coffee + pathType: Prefix + backend: + service: + name: coffee-svc + port: + number: 80 +``` + +Add `path-regex` annotation and modify path `/coffee` + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cafe-ingress-coffee-minion + annotations: + nginx.org/mergeable-ingress-type: "minion" + nginx.org/path-regex: "case_sensitive" +spec: + ingressClassName: nginx + rules: + - host: cafe.example.com + http: + paths: + - path: /coffee/[A-Za-z0-9] + pathType: Prefix + backend: + service: + name: coffee-svc + port: + number: 80 +``` + +Apply changes to the Minion Ingress + +```console +kubectl apply -f coffee-minion.yaml + +ingress.networking.k8s.io/cafe-ingress-coffee-minion created +``` + +Verify applied changes + +```console +kubectl describe ingress cafe-ingress-coffee-minion + +Name: cafe-ingress-coffee-minion +Labels: +Namespace: default +Address: +Ingress Class: nginx +Default backend: +Rules: + Host Path Backends + ---- ---- -------- + cafe.example.com + /coffee/[A-Za-z0-9] coffee-svc:80 (10.244.0.10:8080,10.244.0.9:8080) +Annotations: nginx.org/mergeable-ingress-type: minion + nginx.org/path-regex: case_sensitive +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal AddedOrUpdated 11m nginx-ingress-controller Configuration for default/cafe-ingress-coffee-minion was added or updated +``` + +The new annotation `nginx.org/path-regex` was added. It updates the path `/coffee/[A-Za-z0-9]` using `case_sensitive` +regex modifier. Updated path (location) in the NGINX config file: `location ~ "^/coffee/[A-Za-z0-9]"`. From 71a7de162a5040cd778cc560d9444caaa4c64876 Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 11:18:46 +0100 Subject: [PATCH 2/7] Update howto doc --- .../ingress-path-regex-annotation.md | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md index e8135833ef..86eb02a84a 100644 --- a/docs/content/tutorials/ingress-path-regex-annotation.md +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -1,15 +1,14 @@ --- title: Customizing Ingresses with Path-Regex Annotations description: | - How to customize Ingress Types with path-regex annotations. + How to customize Simple Ingress and Mergeable Ingress types with path-regex annotations. weight: 1800 doctypes: ["concept"] toc: true --- ## Customizing NGINX Ingress Controller with Path-Regex Annotations - -This document explains how to use `path-regex` annotations with Simpe Ingresses and Mergeable Ingresses (Master - Minion) +This document explains how to use `path-regex` annotations with Simpe Ingress and Mergeable Ingress (Master and Minions) types. [NGINX documentation](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) provides @@ -19,12 +18,12 @@ Read [it](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx- ## Simple Ingress Type -In this example, we will use the `nginx.org/path-regex` annotations to add regex modifiers the location paths. +In this example, you will use the `nginx.org/path-regex` annotations to add regex modifiers the location paths. Start by modifying `cafe-ingress.tmpl` metadata. Add the annotation section and configure annotation ``nginx.org/path-regex`` with value `case_sensitive`. -The content of `cafe-ingress.tmpl`: +`cafe-ingress.tmpl`: ```yaml apiVersion: networking.k8s.io/v1 @@ -70,6 +69,7 @@ location ~ "^/coffee/[A-Z0-9]" { Note that the regex modifier `case_sensitive` is applied to all paths. To change regex modifier value from `case_sensitive` to `case_insensitive` update the `nginx.org/path-regex` annotation. + The config `cafe-ingress.tmpl` file below shows the change. ```yaml @@ -98,18 +98,18 @@ spec: servicePort: 80 ``` -In the NGINX config file the ``tea`` and ``coffee`` paths will look like in the snippets below: +In the NGINX config file the ``/tea/[A-Z0-9]`` and ``/coffee/[A-Z0-9]`` paths will look like in the snippets below. -tea path: +tea path ```nginx -location ~* "^/tea/[A-Z0-9]" { +location ~* "^/tea/[A-Z0-9]" ``` -coffee path: +coffee path ```nginx -location ~* "^/coffee/[A-Z0-9]" { +location ~* "^/coffee/[A-Z0-9]" ``` @@ -119,7 +119,7 @@ This document section explains how to deploy and configure Mergeable Ingress Typ You will deploy a Master Ingress and two Minion Ingresses. Next, you will configure them with `path-regex` annotations. -Start by creating a Master Ingress. +Create a Master Ingress. `cafe-master.yaml` ```yaml @@ -139,13 +139,13 @@ spec: - host: cafe.example.com ``` -Create the Ingress: +Create the Ingress ```console kubectl create -f cafe-master.yaml ``` -Verify the Master Ingress is created +Verify the Master Ingress was created ```console kubectl get ingress cafe-ingress-master @@ -204,6 +204,7 @@ spec: ```console kubectl create -f tea-minion.yaml + ingress.networking.k8s.io/cafe-ingress-tea-minion created ``` @@ -335,7 +336,7 @@ spec: Apply the changes ```console -kuubectl apply -f tea-minion.yaml +kubectl apply -f tea-minion.yaml ``` Verify the change From ea7abcc858b8a1f3bcb1aa349680ad43b719954a Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 15:59:00 +0100 Subject: [PATCH 3/7] Update howto docs --- .../ingress-path-regex-annotation.md | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md index 86eb02a84a..78c24a176e 100644 --- a/docs/content/tutorials/ingress-path-regex-annotation.md +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -1,5 +1,5 @@ --- -title: Customizing Ingresses with Path-Regex Annotations +title: Ingresses Path Matching Using Path-Regex Annotation description: | How to customize Simple Ingress and Mergeable Ingress types with path-regex annotations. weight: 1800 @@ -8,22 +8,17 @@ toc: true --- ## Customizing NGINX Ingress Controller with Path-Regex Annotations -This document explains how to use `path-regex` annotations with Simpe Ingress and Mergeable Ingress (Master and Minions) -types. - -[NGINX documentation](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) provides -additional information about how NGINX and NGINX Plus resolve location priority. -Read [it](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) before using - the ``path-regex`` annotation. +We suggest reading the NGINX [documentation on resolve location priority](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) +to gain additional contenx about NGINX and NGINX Plus before using the ``path-regex`` annotation. ## Simple Ingress Type In this example, you will use the `nginx.org/path-regex` annotations to add regex modifiers the location paths. -Start by modifying `cafe-ingress.tmpl` metadata. Add the annotation section and configure annotation ``nginx.org/path-regex`` -with value `case_sensitive`. +Start by modifying `cafe-ingress.yaml` metadata to add the annotation section and configure +the ``nginx.org/path-regex`` annotation. -`cafe-ingress.tmpl`: +`cafe-ingress.yaml`: ```yaml apiVersion: networking.k8s.io/v1 @@ -51,26 +46,26 @@ spec: servicePort: 80 ``` -After creating the Ingress (`kubectl create -f cafe-ingres,yaml`), all defined paths will be updated. In the generated +After creating the Ingress (`kubectl create -f cafe-ingres.yaml`), all defined paths will be updated. In the generated NGINX config file the ``tea`` and ``coffee`` paths will look like in the snippets below: tea path: -```bash -location ~ "^/tea/[A-Z0-9]" { +```nginx +location ~ "^/tea/[A-Z0-9]" ``` coffee path: -```bash -location ~ "^/coffee/[A-Z0-9]" { +```nginx +location ~ "^/coffee/[A-Z0-9]" ``` Note that the regex modifier `case_sensitive` is applied to all paths. To change regex modifier value from `case_sensitive` to `case_insensitive` update the `nginx.org/path-regex` annotation. -The config `cafe-ingress.tmpl` file below shows the change. +The config `cafe-ingress.yaml` file below shows the change. ```yaml apiVersion: networking.k8s.io/v1 @@ -421,17 +416,17 @@ spec: number: 80 ``` -Apply changes to the Minion Ingress +Apply changes to the Minion Ingress: -```console +```shell kubectl apply -f coffee-minion.yaml ingress.networking.k8s.io/cafe-ingress-coffee-minion created ``` -Verify applied changes +Verify the applied changes: -```console +```shell kubectl describe ingress cafe-ingress-coffee-minion Name: cafe-ingress-coffee-minion @@ -453,5 +448,6 @@ Events: Normal AddedOrUpdated 11m nginx-ingress-controller Configuration for default/cafe-ingress-coffee-minion was added or updated ``` -The new annotation `nginx.org/path-regex` was added. It updates the path `/coffee/[A-Za-z0-9]` using `case_sensitive` -regex modifier. Updated path (location) in the NGINX config file: `location ~ "^/coffee/[A-Za-z0-9]"`. +The new annotation `nginx.org/path-regex` was added. +It updates the path `/coffee/[A-Za-z0-9]` using the `case_sensitive` regex modifier. +Updated path (location) in the NGINX config file: `location ~ "^/coffee/[A-Za-z0-9]"`. From 1326ed46ee9968b20af5b8befe7306c6ff4cfbdc Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 16:04:27 +0100 Subject: [PATCH 4/7] Update howto docs --- .../ingress-path-regex-annotation.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md index 78c24a176e..418be945cb 100644 --- a/docs/content/tutorials/ingress-path-regex-annotation.md +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -107,7 +107,6 @@ coffee path location ~* "^/coffee/[A-Z0-9]" ``` - ## Mergeable Ingress Type This document section explains how to deploy and configure Mergeable Ingress Type. @@ -117,6 +116,7 @@ You will deploy a Master Ingress and two Minion Ingresses. Next, you will config Create a Master Ingress. `cafe-master.yaml` + ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress @@ -136,21 +136,20 @@ spec: Create the Ingress -```console +```shell kubectl create -f cafe-master.yaml ``` Verify the Master Ingress was created -```console +```shell kubectl get ingress cafe-ingress-master NAME CLASS HOSTS ADDRESS PORTS AGE cafe-ingress-master nginx cafe.example.com 80, 443 29s ``` - -```console +```shell kubectl describe ingress cafe-ingress-master Name: cafe-ingress-master @@ -175,6 +174,7 @@ Events: Create first Ingress Minion. `tea-minion.yaml` + ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress @@ -197,7 +197,7 @@ spec: number: 80 ``` -```console +```shell kubectl create -f tea-minion.yaml ingress.networking.k8s.io/cafe-ingress-tea-minion created @@ -205,14 +205,14 @@ ingress.networking.k8s.io/cafe-ingress-tea-minion created Verify the minion was created -```console +```shell kubectl get ingress cafe-ingress-tea-minion NAME CLASS HOSTS ADDRESS PORTS AGE cafe-ingress-tea-minion nginx cafe.example.com 80 23m ``` -```console +```shell kubectl describe ingress cafe-ingress-tea-minion Name: cafe-ingress-tea-minion @@ -260,7 +260,7 @@ spec: ``` -```console +```shell kubectl create -f tea-minion.yaml ingress.networking.k8s.io/cafe-ingress-tea-minion created @@ -268,14 +268,14 @@ ingress.networking.k8s.io/cafe-ingress-tea-minion created Verify the minion was created -```console +```shell kubectl get ingress cafe-ingress-tea-minion NAME CLASS HOSTS ADDRESS PORTS AGE cafe-ingress-tea-minion nginx cafe.example.com 80 5m21s ``` -```console +```shell kubectl describe ingress cafe-ingress-tea-minion Name: cafe-ingress-tea-minion @@ -330,13 +330,13 @@ spec: Apply the changes -```console +```shell kubectl apply -f tea-minion.yaml ``` Verify the change -```console +```shell kubectl describe ingress cafe-ingress-tea-minion Name: cafe-ingress-tea-minion From 23fce5f2fe0cae48b16d960dd4ce7a1afe46bc7c Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 16:16:08 +0100 Subject: [PATCH 5/7] Update howto docs --- .../ingress-path-regex-annotation.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md index 418be945cb..8666115a81 100644 --- a/docs/content/tutorials/ingress-path-regex-annotation.md +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -111,7 +111,7 @@ location ~* "^/coffee/[A-Z0-9]" This document section explains how to deploy and configure Mergeable Ingress Type. -You will deploy a Master Ingress and two Minion Ingresses. Next, you will configure them with `path-regex` annotations. +First, you will deploy a Master Ingress and two Minion Ingresses. Then, you will configure them with `path-regex` annotations. Create a Master Ingress. @@ -171,7 +171,7 @@ Events: Normal AddedOrUpdated 62s nginx-ingress-controller Configuration for default/cafe-ingress-master was added or updated ``` -Create first Ingress Minion. +Create the first Ingress Minion. `tea-minion.yaml` @@ -203,7 +203,7 @@ kubectl create -f tea-minion.yaml ingress.networking.k8s.io/cafe-ingress-tea-minion created ``` -Verify the minion was created +Verify the Minion was created: ```shell kubectl get ingress cafe-ingress-tea-minion @@ -233,7 +233,7 @@ Events: Normal AddedOrUpdated 24m nginx-ingress-controller Configuration for default/cafe-ingress-tea-minion was added or updated ``` -Create second Minion +Create the second Ingress Minion. `tea-minion.yaml` @@ -259,14 +259,13 @@ spec: number: 80 ``` - ```shell kubectl create -f tea-minion.yaml ingress.networking.k8s.io/cafe-ingress-tea-minion created ``` -Verify the minion was created +Verify the Minion Ingress was created: ```shell kubectl get ingress cafe-ingress-tea-minion @@ -296,11 +295,11 @@ Events: Normal AddedOrUpdated 5m52s nginx-ingress-controller Configuration for default/cafe-ingress-tea-minion was added or updated ``` -You created Master Ingress two Minion Ingresses. Minion Ingresses define two paths: `/tea` and `/coffee`. +You created a Master Ingress and two Minion Ingresses. Minion Ingresses are defined with two paths: `/tea` and `/coffee`. In the following steps, you will modify the paths by applying regex modifiers. -Update Minion Ingress `Tea`: +Update the Minion Ingress `Tea`: - add `path-regex` annotation with value `case_insensitive` - modify path with regex you want to use (in the example below: `/tea/[A-Z0-9]`) @@ -328,13 +327,13 @@ spec: number: 80 ``` -Apply the changes +Apply the changes: ```shell kubectl apply -f tea-minion.yaml ``` -Verify the change +Verify the change: ```shell kubectl describe ingress cafe-ingress-tea-minion @@ -358,8 +357,9 @@ Events: Normal AddedOrUpdated 47s (x2 over 34m) nginx-ingress-controller Configuration for default/cafe-ingress-tea-minion was added or updated ``` -Note the updated list of annotations. The new `path-regex` annotation was added. -It updates the path `/tea/[A-Z0-9]` using `case_insensitive` reg-ex modifier. +Looking at the updated list of annotations, we can see the new `path-regex` annotation was added. + +It updates the path `/tea/[A-Z0-9]` using the `case_insensitive` regex modifier. Updated path (location) in the NGINX config file: `location ~* "^/tea/[A-Z0-9]"`. Note that the `path-regex` annotation applies only to paths defined on the corresponding Minion Ingress. @@ -391,7 +391,7 @@ spec: number: 80 ``` -Add `path-regex` annotation and modify path `/coffee` +Add `path-regex` annotation and modify the path `/coffee`: ```yaml apiVersion: networking.k8s.io/v1 @@ -449,5 +449,5 @@ Events: ``` The new annotation `nginx.org/path-regex` was added. -It updates the path `/coffee/[A-Za-z0-9]` using the `case_sensitive` regex modifier. +It updates the path `/coffee/[A-Za-z0-9]` using the `case_sensitive` regex modifier. Updated path (location) in the NGINX config file: `location ~ "^/coffee/[A-Za-z0-9]"`. From 99fcbb3adf861418fcd3d42bc99f1e2dd42fe0bd Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 16:31:22 +0100 Subject: [PATCH 6/7] Update howto docs --- docs/content/tutorials/ingress-path-regex-annotation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md index 8666115a81..da8fa5779f 100644 --- a/docs/content/tutorials/ingress-path-regex-annotation.md +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -93,7 +93,7 @@ spec: servicePort: 80 ``` -In the NGINX config file the ``/tea/[A-Z0-9]`` and ``/coffee/[A-Z0-9]`` paths will look like in the snippets below. +In the NGINX config file, the ``/tea/[A-Z0-9]`` and ``/coffee/[A-Z0-9]`` paths should look like in the snippets below. tea path From b0f2ac5a6ee93e1becc89532588bf759f679a0f8 Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 18 Aug 2023 16:40:26 +0100 Subject: [PATCH 7/7] Remove ref to Simple Ingress --- docs/content/tutorials/ingress-path-regex-annotation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/tutorials/ingress-path-regex-annotation.md b/docs/content/tutorials/ingress-path-regex-annotation.md index da8fa5779f..d3db4696cb 100644 --- a/docs/content/tutorials/ingress-path-regex-annotation.md +++ b/docs/content/tutorials/ingress-path-regex-annotation.md @@ -1,7 +1,7 @@ --- title: Ingresses Path Matching Using Path-Regex Annotation description: | - How to customize Simple Ingress and Mergeable Ingress types with path-regex annotations. + How to customize Ingress and Mergeable Ingress types with path-regex annotations. weight: 1800 doctypes: ["concept"] toc: true @@ -11,9 +11,9 @@ toc: true We suggest reading the NGINX [documentation on resolve location priority](https://docs.nginx.com/nginx/admin-guide/web-server/web-server/#nginx-location-priority) to gain additional contenx about NGINX and NGINX Plus before using the ``path-regex`` annotation. -## Simple Ingress Type +## Ingress Type -In this example, you will use the `nginx.org/path-regex` annotations to add regex modifiers the location paths. +In this example, you will use the `nginx.org/path-regex` annotations to add regex modifiers to the location paths. Start by modifying `cafe-ingress.yaml` metadata to add the annotation section and configure the ``nginx.org/path-regex`` annotation.