From d0751d6187e34fac8f886a3b1f7f56b48af7cb6b Mon Sep 17 00:00:00 2001
From: Dean Coakley <dean.s.coakley@gmail.com>
Date: Fri, 15 May 2020 16:28:27 +0100
Subject: [PATCH 1/6] Fix multiple KIC deploys via helm

---
 .../transportserver.yaml}                                   | 6 +++---
 .../virtualserver.yaml}                                     | 6 +++---
 .../virtualserverroute.yaml}                                | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
 rename deployments/helm-chart/{templates/controller-ts-definition.yaml => crds/transportserver.yaml} (95%)
 rename deployments/helm-chart/{templates/controller-vs-definition.yaml => crds/virtualserver.yaml} (99%)
 rename deployments/helm-chart/{templates/controller-vsr-definition.yaml => crds/virtualserverroute.yaml} (99%)

diff --git a/deployments/helm-chart/templates/controller-ts-definition.yaml b/deployments/helm-chart/crds/transportserver.yaml
similarity index 95%
rename from deployments/helm-chart/templates/controller-ts-definition.yaml
rename to deployments/helm-chart/crds/transportserver.yaml
index cefee61914..689eb32613 100644
--- a/deployments/helm-chart/templates/controller-ts-definition.yaml
+++ b/deployments/helm-chart/crds/transportserver.yaml
@@ -1,10 +1,11 @@
-{{- if .Values.controller.enableCustomResources }}
 apiVersion: apiextensions.k8s.io/v1beta1
 kind: CustomResourceDefinition
 metadata:
   name: transportservers.k8s.nginx.org
   labels:
-    {{- include "nginx-ingress.labels" . | nindent 4 }}
+    app.kubernetes.io/name: "nginx-ingress"
+  annotations:
+    "helm.sh/hook": crd-install
 spec:
   group: k8s.nginx.org
   versions:
@@ -76,4 +77,3 @@ spec:
                     type: integer
                   service:
                     type: string
-{{- end }}
diff --git a/deployments/helm-chart/templates/controller-vs-definition.yaml b/deployments/helm-chart/crds/virtualserver.yaml
similarity index 99%
rename from deployments/helm-chart/templates/controller-vs-definition.yaml
rename to deployments/helm-chart/crds/virtualserver.yaml
index 7aa9a38bfd..15acf73136 100644
--- a/deployments/helm-chart/templates/controller-vs-definition.yaml
+++ b/deployments/helm-chart/crds/virtualserver.yaml
@@ -1,10 +1,11 @@
-{{- if .Values.controller.enableCustomResources }}
 apiVersion: apiextensions.k8s.io/v1beta1
 kind: CustomResourceDefinition
 metadata:
   name: virtualservers.k8s.nginx.org
   labels:
-    {{- include "nginx-ingress.labels" . | nindent 4 }}
+    app.kubernetes.io/name: "nginx-ingress"
+  annotations:
+    "helm.sh/hook": crd-install
 spec:
   group: k8s.nginx.org
   versions:
@@ -648,4 +649,3 @@ spec:
               type: string
             state:
               type: string
-{{- end }}
diff --git a/deployments/helm-chart/templates/controller-vsr-definition.yaml b/deployments/helm-chart/crds/virtualserverroute.yaml
similarity index 99%
rename from deployments/helm-chart/templates/controller-vsr-definition.yaml
rename to deployments/helm-chart/crds/virtualserverroute.yaml
index 502cabcb55..ddcdcbdc2e 100644
--- a/deployments/helm-chart/templates/controller-vsr-definition.yaml
+++ b/deployments/helm-chart/crds/virtualserverroute.yaml
@@ -1,10 +1,11 @@
-{{- if .Values.controller.enableCustomResources }}
 apiVersion: apiextensions.k8s.io/v1beta1
 kind: CustomResourceDefinition
 metadata:
   name: virtualserverroutes.k8s.nginx.org
   labels:
-    {{- include "nginx-ingress.labels" . | nindent 4 }}
+    app.kubernetes.io/name: "nginx-ingress"
+  annotations:
+    "helm.sh/hook": crd-install
 spec:
   group: k8s.nginx.org
   versions:
@@ -632,4 +633,3 @@ spec:
               type: string
             state:
               type: string
-{{- end }}

From c93f0e038fa06a1a880ed2c370689d809899d805 Mon Sep 17 00:00:00 2001
From: Dean Coakley <dean.s.coakley@gmail.com>
Date: Fri, 26 Jun 2020 19:35:21 +0100
Subject: [PATCH 2/6] Add helm2 backport

---
 deployments/helm-chart/templates/crds.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 deployments/helm-chart/templates/crds.yaml

diff --git a/deployments/helm-chart/templates/crds.yaml b/deployments/helm-chart/templates/crds.yaml
new file mode 100644
index 0000000000..0557f404e2
--- /dev/null
+++ b/deployments/helm-chart/templates/crds.yaml
@@ -0,0 +1,7 @@
+{{- if .Values.controller.enableCustomResources }}
+{{- range $path, $bytes := .Files.Glob "crds/*.yaml" }}
+{{ $.Files.Get $path }}
+---
+{{- end }}
+{{- end }}
+

From aee0168a398af2d89c31800f8dc8194fdaaa8b02 Mon Sep 17 00:00:00 2001
From: Dean Coakley <dean.s.coakley@gmail.com>
Date: Mon, 29 Jun 2020 12:32:46 +0100
Subject: [PATCH 3/6] Add docs

---
 deployments/helm-chart/README.md | 56 +++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/deployments/helm-chart/README.md b/deployments/helm-chart/README.md
index ae7f17b279..35ba8ef999 100644
--- a/deployments/helm-chart/README.md
+++ b/deployments/helm-chart/README.md
@@ -15,10 +15,24 @@ This chart deploys the NGINX Ingress controller in your Kubernetes cluster.
 
 ## Installing the Chart
 
+### Installing CRDs
+
+The VirtualServer and VirtualServerRoute resources are new load balancing configuration, introduced in release 1.5 as an alternative to the Ingress resource. The resources enable use cases not supported with the Ingress resource, such as [traffic splitting](https://github.com/nginxinc/kubernetes-ingress/tree/master/examples-of-custom-resources/traffic-splitting) and [advanced content-based routing](https://github.com/nginxinc/kubernetes-ingress/tree/master/examples-of-custom-resources/advanced-routing).
+
+To see additional examples of using the resources for specific use cases, see [examples of custom resources](https://github.com/nginxinc/kubernetes-ingress/blob/master/examples-of-custom-resources).
+
+* Using Helm 3.x client:
+
+    Helm will install CRDs by default. Specify `helm install --skip-crds` to skip installation of CRDs.
+
+* Using a Helm 2.x client:
+
+    Helm will install CRDs if `controller.enableCustomResources` is set.
+
 ### Installing via Helm Repository
 
 1. Add NGINX Helm repository:
-    ```
+    ```console
     $ helm repo add nginx-edge https://helm.nginx.com/edge
     $ helm repo update
     ```
@@ -92,6 +106,38 @@ This chart deploys the NGINX Ingress controller in your Kubernetes cluster.
 
 > **Tip**: List all releases using `helm list`
 
+### Running Multiple Ingress Controllers
+
+It is recommended to set `controller.reportIngressStatus.enableLeaderElection` so that only one Ingress Controller deployment reports the Ingress, VirtualServer and VirtualServerRoute status.
+
+> **Note**: CRDs are shared between releases and are not namespaced. Great caution should be taken when removing CRDs as all deployed Custom Resources will also be deleted. It is however, safe to delete a release, the CRDs will be left behind for this reason and must be removed manually via `kubectl`.
+
+See [running multiple ingress controllers](https://docs.nginx.com/nginx-ingress-controller/installation/running-multiple-ingress-controllers/) for more details.
+
+## Upgrading the Chart
+
+To upgrade the release `my-release`
+
+* Using Helm 3.x client:
+
+    ```console
+    $ helm upgrade my-release
+    ```
+
+* Using Helm 2.x client:
+
+    ```console
+    $ helm upgrade -n my-release
+    ```
+
+### Updating CRDs
+
+Helm does not assist in updating of CRDs. Updates should be done via `kubectl`. See [release notes](https://www.github.com/nginxinc/kubernetes-ingress/releases) for detailed instructions for a specific release upgrade.
+
+```console
+$ kubectl apply -f crds/
+```
+
 ## Uninstalling the Chart
 
 To uninstall/delete the release `my-release`
@@ -110,6 +156,14 @@ To uninstall/delete the release `my-release`
 
 The command removes all the Kubernetes components associated with the chart and deletes the release.
 
+### Uninstalling CRDs
+
+> **Note**: The following command will delete all Ingress Controller related Custom Resources in your cluster across all namespaces. Please ensure there are no Custom Resources in any namespace that you want to keep.
+
+```console
+$ kubectl delete crds transportservers.k8s.nginx.org virtualservers.k8s.nginx.org virtualserverroutes.k8s.nginx.org
+```
+
 ## Configuration
 
 The following tables lists the configurable parameters of the NGINX Ingress controller chart and their default values.

From cfb2eeddd1b0f2e2ab2a4060b34d870f8d2c358a Mon Sep 17 00:00:00 2001
From: Dean Coakley <dean.s.coakley@gmail.com>
Date: Tue, 30 Jun 2020 16:20:09 +0100
Subject: [PATCH 4/6] Improve docs

---
 deployments/helm-chart/README.md | 48 +++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/deployments/helm-chart/README.md b/deployments/helm-chart/README.md
index 35ba8ef999..fe45cd8193 100644
--- a/deployments/helm-chart/README.md
+++ b/deployments/helm-chart/README.md
@@ -15,19 +15,21 @@ This chart deploys the NGINX Ingress controller in your Kubernetes cluster.
 
 ## Installing the Chart
 
-### Installing CRDs
+### Installing the CRDs
 
-The VirtualServer and VirtualServerRoute resources are new load balancing configuration, introduced in release 1.5 as an alternative to the Ingress resource. The resources enable use cases not supported with the Ingress resource, such as [traffic splitting](https://github.com/nginxinc/kubernetes-ingress/tree/master/examples-of-custom-resources/traffic-splitting) and [advanced content-based routing](https://github.com/nginxinc/kubernetes-ingress/tree/master/examples-of-custom-resources/advanced-routing).
+By default, Helm installs a number of custom resource definitions (CRDs). Those CRDs are required for the VirtualServer, VirtualServerRoute and TransportServer custom resources.
 
-To see additional examples of using the resources for specific use cases, see [examples of custom resources](https://github.com/nginxinc/kubernetes-ingress/blob/master/examples-of-custom-resources).
+If you do not use those resources (which corresponds to `controller.enableCustomResources` set to `false`), you can skip the installation of the CRDs:
 
 * Using Helm 3.x client:
 
-    Helm will install CRDs by default. Specify `helm install --skip-crds` to skip installation of CRDs.
+    Specify `--skip-crds` for the helm install command.
 
 * Using a Helm 2.x client:
 
-    Helm will install CRDs if `controller.enableCustomResources` is set.
+    Set `controller.enableCustomResources` to `false`.
+
+> **Note**: If the CRDs are already installed in the cluster, Helm will skip the CRDs installation.
 
 ### Installing via Helm Repository
 
@@ -106,15 +108,19 @@ To see additional examples of using the resources for specific use cases, see [e
 
 > **Tip**: List all releases using `helm list`
 
-### Running Multiple Ingress Controllers
+## Upgrading the Chart
 
-It is recommended to set `controller.reportIngressStatus.enableLeaderElection` so that only one Ingress Controller deployment reports the Ingress, VirtualServer and VirtualServerRoute status.
+### Upgrading the CRDs
 
-> **Note**: CRDs are shared between releases and are not namespaced. Great caution should be taken when removing CRDs as all deployed Custom Resources will also be deleted. It is however, safe to delete a release, the CRDs will be left behind for this reason and must be removed manually via `kubectl`.
+Helm does not upgrade the CRDs during a release upgrade. Before you upgrade a release, run the following command to upgrade the CRDs:
 
-See [running multiple ingress controllers](https://docs.nginx.com/nginx-ingress-controller/installation/running-multiple-ingress-controllers/) for more details.
+```console
+$ kubectl apply -f crds/
+```
 
-## Upgrading the Chart
+> **Note**: Make sure to check the [release notes](https://www.github.com/nginxinc/kubernetes-ingress/releases) for a new release for any special upgrade procedures.
+
+### Upgrading the Release
 
 To upgrade the release `my-release`
 
@@ -130,16 +136,10 @@ To upgrade the release `my-release`
     $ helm upgrade -n my-release
     ```
 
-### Updating CRDs
-
-Helm does not assist in updating of CRDs. Updates should be done via `kubectl`. See [release notes](https://www.github.com/nginxinc/kubernetes-ingress/releases) for detailed instructions for a specific release upgrade.
-
-```console
-$ kubectl apply -f crds/
-```
-
 ## Uninstalling the Chart
 
+### Uninstalling the Release
+
 To uninstall/delete the release `my-release`
 
 * Using Helm 3.x client:
@@ -156,14 +156,22 @@ To uninstall/delete the release `my-release`
 
 The command removes all the Kubernetes components associated with the chart and deletes the release.
 
-### Uninstalling CRDs
+### Uninstalling the CRDs
 
-> **Note**: The following command will delete all Ingress Controller related Custom Resources in your cluster across all namespaces. Please ensure there are no Custom Resources in any namespace that you want to keep.
+Uninstalling the release does not remove the CRDs. To remove the CRDs, run:
 
 ```console
 $ kubectl delete crds transportservers.k8s.nginx.org virtualservers.k8s.nginx.org virtualserverroutes.k8s.nginx.org
 ```
 
+> **Note**: The following command will delete all the corresponding custom resources in your cluster across all namespaces. Please ensure there are no custom resources that you want to keep and there are no other Ingress Controller releases running in the cluster.
+
+## Running Multiple Ingress Controllers
+
+If you are running multiple Ingress Controller releases in your cluster with enabled custom resources, the releases will share a single version of the CRDs. As a result, make sure that the Ingress Controller versions match the version of the CRDs. Additionally, when uninstalling a release, ensure that you don’t remove the CRDs until there are no other Ingress Controller releases running in the cluster.
+
+See [running multiple ingress controllers](https://docs.nginx.com/nginx-ingress-controller/installation/running-multiple-ingress-controllers/) for more details.
+
 ## Configuration
 
 The following tables lists the configurable parameters of the NGINX Ingress controller chart and their default values.

From 2fc3b8ee0bfba9925239ffec53cba5b8015d046e Mon Sep 17 00:00:00 2001
From: Dean Coakley <dean.s.coakley@gmail.com>
Date: Wed, 1 Jul 2020 11:08:13 +0100
Subject: [PATCH 5/6] Add web docs

---
 .../installation/installation-with-helm.md    | 68 ++++++++++++++++++-
 1 file changed, 65 insertions(+), 3 deletions(-)

diff --git a/docs-web/installation/installation-with-helm.md b/docs-web/installation/installation-with-helm.md
index 154f9672a8..064449c994 100644
--- a/docs-web/installation/installation-with-helm.md
+++ b/docs-web/installation/installation-with-helm.md
@@ -13,17 +13,33 @@ This document describes how to install the NGINX Ingress Controller in your Kube
 
 ## Installing the Chart
 
+### Installing the CRDs
+
+By default, Helm installs a number of custom resource definitions (CRDs). Those CRDs are required for the VirtualServer, VirtualServerRoute and TransportServer custom resources.
+
+If you do not use those resources (which corresponds to `controller.enableCustomResources` set to `false`), you can skip the installation of the CRDs:
+
+* Using Helm 3.x client:
+
+    Specify `--skip-crds` for the helm install command.
+
+* Using a Helm 2.x client:
+
+    Set `controller.enableCustomResources` to `false`.
+
+> **Note**: If the CRDs are already installed in the cluster, Helm will skip the CRDs installation.
+
 ### Installing via Helm Repository
 
 1. Add NGINX Helm repository:
-    ```
+    ```console
     $ helm repo add nginx-edge https://helm.nginx.com/edge
     $ helm repo update
     ```
 
 2. To install the chart with the release name my-release (my-release is the name that you choose):
 
-     * Using Helm 3.x client:
+    * Using Helm 3.x client:
 
         For NGINX:
         ```console
@@ -47,7 +63,7 @@ This document describes how to install the NGINX Ingress Controller in your Kube
         $ helm install --name my-release nginx-edge/nginx-ingress --set controller.image.repository=myregistry.example.com/nginx-plus-ingress --set controller.nginxplus=true
         ```
 
-## Installing Using Chart Sources
+### Installing Using Chart Sources
 
 1. Clone the Ingress controller repo:
     ```console
@@ -89,8 +105,38 @@ This document describes how to install the NGINX Ingress Controller in your Kube
 
 > **Tip**: List all releases using `helm list`
 
+## Upgrading the Chart
+
+### Upgrading the CRDs
+
+Helm does not upgrade the CRDs during a release upgrade. Before you upgrade a release, run the following command to upgrade the CRDs:
+
+```console
+$ kubectl apply -f crds/
+```
+
+> **Note**: Make sure to check the [release notes](https://www.github.com/nginxinc/kubernetes-ingress/releases) for a new release for any special upgrade procedures.
+
+### Upgrading the Release
+
+To upgrade the release `my-release`
+
+* Using Helm 3.x client:
+
+    ```console
+    $ helm upgrade my-release
+    ```
+
+* Using Helm 2.x client:
+
+    ```console
+    $ helm upgrade -n my-release
+    ```
+
 ## Uninstalling the Chart
 
+### Uninstalling the Release
+
 To uninstall/delete the release `my-release`
 
 * Using Helm 3.x client:
@@ -107,6 +153,22 @@ To uninstall/delete the release `my-release`
 
 The command removes all the Kubernetes components associated with the chart and deletes the release.
 
+### Uninstalling the CRDs
+
+Uninstalling the release does not remove the CRDs. To remove the CRDs, run:
+
+```console
+$ kubectl delete crds transportservers.k8s.nginx.org virtualservers.k8s.nginx.org virtualserverroutes.k8s.nginx.org
+```
+
+> **Note**: The following command will delete all the corresponding custom resources in your cluster across all namespaces. Please ensure there are no custom resources that you want to keep and there are no other Ingress Controller releases running in the cluster.
+
+## Running Multiple Ingress Controllers
+
+If you are running multiple Ingress Controller releases in your cluster with enabled custom resources, the releases will share a single version of the CRDs. As a result, make sure that the Ingress Controller versions match the version of the CRDs. Additionally, when uninstalling a release, ensure that you don’t remove the CRDs until there are no other Ingress Controller releases running in the cluster.
+
+See [running multiple ingress controllers](https://docs.nginx.com/nginx-ingress-controller/installation/running-multiple-ingress-controllers/) for more details.
+
 ## Configuration
 
 The following tables lists the configurable parameters of the NGINX Ingress controller chart and their default values.

From e07cd66861f81319371e75e3200bb6f751001ace Mon Sep 17 00:00:00 2001
From: Dean Coakley <dean.s.coakley@gmail.com>
Date: Wed, 1 Jul 2020 11:23:27 +0100
Subject: [PATCH 6/6] Use relative url

---
 docs-web/installation/installation-with-helm.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs-web/installation/installation-with-helm.md b/docs-web/installation/installation-with-helm.md
index 064449c994..c11bb7fa7a 100644
--- a/docs-web/installation/installation-with-helm.md
+++ b/docs-web/installation/installation-with-helm.md
@@ -167,7 +167,7 @@ $ kubectl delete crds transportservers.k8s.nginx.org virtualservers.k8s.nginx.or
 
 If you are running multiple Ingress Controller releases in your cluster with enabled custom resources, the releases will share a single version of the CRDs. As a result, make sure that the Ingress Controller versions match the version of the CRDs. Additionally, when uninstalling a release, ensure that you don’t remove the CRDs until there are no other Ingress Controller releases running in the cluster.
 
-See [running multiple ingress controllers](https://docs.nginx.com/nginx-ingress-controller/installation/running-multiple-ingress-controllers/) for more details.
+See [running multiple ingress controllers](/nginx-ingress-controller/installation/running-multiple-ingress-controllers/) for more details.
 
 ## Configuration