You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
9.1 KiB

  1. Installation Guide
  2. ==================
  3. Contents
  4. --------
  5. - [Mandatory commands](#mandatory-commands)
  6. - [Install without RBAC roles](#install-without-rbac-roles)
  7. - [Install with RBAC roles](#install-with-rbac-roles)
  8. - [Custom Provider](#custom-provider)
  9. - [minikube](#minikube)
  10. - [AWS](#aws)
  11. - [GCE - GKE](#gce---gke)
  12. - [Azure](#azure)
  13. - [Baremetal](#baremetal)
  14. - [Using Helm](#using-helm)
  15. - [Verify installation](#verify-installation)
  16. - [Detect installed version](#detect-installed-version)
  17. - [Deploying the config-map](#deploying-the-config-map)
  18. Generic Deployment
  19. ------------------
  20. The following resources are required for a generic deployment.
  21. ### Mandatory commands
  22. ``` console
  23. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/namespace.yaml \
  24. | kubectl apply -f -
  25. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/default-backend.yaml \
  26. | kubectl apply -f -
  27. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/configmap.yaml \
  28. | kubectl apply -f -
  29. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/tcp-services-configmap.yaml \
  30. | kubectl apply -f -
  31. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/udp-services-configmap.yaml \
  32. | kubectl apply -f -
  33. ```
  34. ### Install without RBAC roles
  35. ``` console
  36. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/without-rbac.yaml \
  37. | kubectl apply -f -
  38. ```
  39. ### Install with RBAC roles
  40. Please check the [RBAC](rbac.md) document.
  41. ``` console
  42. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/rbac.yaml \
  43. | kubectl apply -f -
  44. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/with-rbac.yaml \
  45. | kubectl apply -f -
  46. ```
  47. Custom Service Provider Deployment
  48. ----------------------------------
  49. There are cloud provider specific yaml files.
  50. ### minikube
  51. For standard usage:
  52. ``` console
  53. minikube addons enable ingress
  54. ```
  55. For development:
  56. 1. Disable the ingress addon:
  57. ``` console
  58. $ minikube addons disable ingress
  59. ```
  60. 2. Use the [docker daemon](https://github.com/kubernetes/minikube/blob/master/docs/reusing_the_docker_daemon.md)
  61. 3. [Build the image](../docs/development.md)
  62. 4. Perform [Mandatory commands](#mandatory-commands)
  63. 5. Install the `nginx-ingress-controller` deployment [without RBAC roles](#install-without-rbac-roles) or [with RBAC roles](#install-with-rbac-roles)
  64. 6. Edit the `nginx-ingress-controller` deployment to use your custom image. Local images can be seen by performing `docker images`.
  65. ``` console
  66. $ kubectl edit deployment nginx-ingress-controller -n ingress-nginx
  67. ```
  68. edit the following section:
  69. ``` yaml
  70. image: <IMAGE-NAME>:<TAG>
  71. imagePullPolicy: IfNotPresent
  72. name: nginx-ingress-controller
  73. ```
  74. 7. Confirm the `nginx-ingress-controller` deployment exists:
  75. ``` console
  76. $ kubectl get pods -n ingress-nginx
  77. NAME READY STATUS RESTARTS AGE
  78. default-http-backend-66b447d9cf-rrlf9 1/1 Running 0 12s
  79. nginx-ingress-controller-fdcdcd6dd-vvpgs 1/1 Running 0 11s
  80. ```
  81. ### AWS
  82. In AWS we use an Elastic Load Balancer (ELB) to expose the NGINX Ingress controller behind a Service of `Type=LoadBalancer`.
  83. This setup requires to choose in which layer (L4 or L7) we want to configure the ELB:
  84. - [Layer 4](https://en.wikipedia.org/wiki/OSI_model#Layer_4:_Transport_Layer): use TCP as the listener protocol for ports 80 and 443.
  85. - [Layer 7](https://en.wikipedia.org/wiki/OSI_model#Layer_7:_Application_Layer): use HTTP as the listener protocol for port 80 and terminate TLS in the ELB
  86. Patch the nginx ingress controller deployment to add the flag `--publish-service`
  87. ``` console
  88. kubectl patch deployment -n ingress-nginx nginx-ingress-controller --type='json' \
  89. --patch="$(curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/publish-service-patch.yaml)"
  90. ```
  91. For L4:
  92. ``` console
  93. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/aws/service-l4.yaml
  94. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/aws/patch-configmap-l4.yaml
  95. ```
  96. For L7:
  97. Change line of the file `provider/aws/service-l7.yaml` replacing the dummy id with a valid one `"arn:aws:acm:us-west-2:XXXXXXXX:certificate/XXXXXX-XXXXXXX-XXXXXXX-XXXXXXXX"`
  98. Then execute:
  99. ``` console
  100. kubectl apply -f provider/aws/service-l7.yaml
  101. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/aws/patch-configmap-l7.yaml
  102. ```
  103. This example creates an ELB with just two listeners, one in port 80 and another in port 443
  104. ![Listeners](../docs/images/elb-l7-listener.png)
  105. If the ingress controller uses RBAC run:
  106. ``` console
  107. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/patch-service-with-rbac.yaml
  108. ```
  109. If not run:
  110. ``` console
  111. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/patch-service-without-rbac.yaml
  112. ```
  113. ### GCE - GKE
  114. Patch the nginx ingress controller deployment to add the flag `--publish-service`
  115. ``` console
  116. kubectl patch deployment -n ingress-nginx nginx-ingress-controller --type='json' \
  117. --patch="$(curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/publish-service-patch.yaml)"
  118. ```
  119. ``` console
  120. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/gce-gke/service.yaml \
  121. | kubectl apply -f -
  122. ```
  123. If the ingress controller uses RBAC run:
  124. ``` console
  125. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/patch-service-with-rbac.yaml
  126. ```
  127. If not run:
  128. ``` console
  129. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/patch-service-without-rbac.yaml
  130. ```
  131. **Important Note:** proxy protocol is not supported in GCE/GKE
  132. ### Azure
  133. Patch the nginx ingress controller deployment to add the flag `--publish-service`
  134. ``` console
  135. kubectl patch deployment -n ingress-nginx nginx-ingress-controller --type='json' \
  136. --patch="$(curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/publish-service-patch.yaml)"
  137. ```
  138. ``` console
  139. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/azure/service.yaml \
  140. | kubectl apply -f -
  141. ```
  142. If the ingress controller uses RBAC run:
  143. ``` console
  144. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/patch-service-with-rbac.yaml
  145. ```
  146. If not run:
  147. ``` console
  148. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/patch-service-without-rbac.yaml
  149. ```
  150. **Important Note:** proxy protocol is not supported in GCE/GKE
  151. ### Baremetal
  152. Using [NodePort](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport):
  153. ``` console
  154. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml \
  155. | kubectl apply -f -
  156. ```
  157. Using Helm
  158. ----------
  159. NGINX Ingress controller can be installed via [Helm](https://helm.sh/) using the chart [stable/nginx](https://github.com/kubernetes/charts/tree/master/stable/nginx-ingress) from the official charts repository.
  160. To install the chart with the release name `my-nginx`:
  161. ``` console
  162. helm install stable/nginx-ingress --name my-nginx
  163. ```
  164. If the kubernetes cluster has RBAC enabled, then run:
  165. ``` console
  166. helm install stable/nginx-ingress --name my-nginx --set rbac.create=true
  167. ```
  168. Verify installation
  169. -------------------
  170. To check if the ingress controller pods have started, run the following command:
  171. ``` console
  172. kubectl get pods --all-namespaces -l app=ingress-nginx --watch
  173. ```
  174. Once the operator pods are running, you can cancel the above command by typing `Ctrl+C`.
  175. Now, you are ready to create your first ingress.
  176. Detect installed version
  177. ------------------------
  178. To detect which version of the ingress controller is running, exec into the pod and run `nginx-ingress-controller version` command.
  179. ``` console
  180. POD_NAMESPACE=ingress-nginx
  181. POD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app=ingress-nginx -o jsonpath={.items[0].metadata.name})
  182. kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version
  183. ```
  184. Deploying the config-map
  185. ------------------------
  186. A config map can be used to configure system components for the nginx-controller. In order to begin using a config-map
  187. make sure it has been created and is being used in the deployment.
  188. It is created as seen in the [Mandatory Commands](#mandatory-commands) section above.
  189. ``` console
  190. curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/configmap.yaml \
  191. | kubectl apply -f -
  192. ```
  193. and is setup to be used in the deployment [without-rbac](without-rbac.yaml) or [with-rbac](with-rbac.yaml) with the following line:
  194. ``` yaml
  195. - --configmap=$(POD_NAMESPACE)/nginx-configuration
  196. ```
  197. For information on using the config-map, see its [user-guide](../docs/user-guide/configmap.md).